diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 255638109090409a43390b12fc77aa3740038847..f8a842e405b6fac85fc15a9b97bb88da53c85290 100755 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -144,6 +144,7 @@ #include "PHY/TOOLS/time_meas.h" #include "PHY/CODING/defs.h" #include "PHY/TOOLS/defs.h" +#include "platform_types.h" #ifdef OPENAIR_LTE @@ -180,30 +181,30 @@ enum transmission_access_mode{ /// Top-level PHY Data Structure for eNB typedef struct { /// Module ID indicator for this instance - u8 Mod_id; - u8 local_flag; - unsigned int rx_total_gain_eNB_dB; - u32 frame; - LTE_DL_FRAME_PARMS lte_frame_parms; + module_id_t Mod_id; + u8 local_flag; + unsigned int rx_total_gain_eNB_dB; + frame_t frame; + LTE_DL_FRAME_PARMS lte_frame_parms; PHY_MEASUREMENTS_eNB PHY_measurements_eNB[NUMBER_OF_eNB_SECTORS_MAX]; /// Measurement variables - LTE_eNB_COMMON lte_eNB_common_vars; - LTE_eNB_SRS lte_eNB_srs_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PBCH lte_eNB_pbch; - LTE_eNB_PUSCH *lte_eNB_pusch_vars[NUMBER_OF_UE_MAX]; - LTE_eNB_PRACH lte_eNB_prach_vars; - LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams + LTE_eNB_COMMON lte_eNB_common_vars; + LTE_eNB_SRS lte_eNB_srs_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_PBCH lte_eNB_pbch; + LTE_eNB_PUSCH *lte_eNB_pusch_vars[NUMBER_OF_UE_MAX]; + LTE_eNB_PRACH lte_eNB_prach_vars; + LTE_eNB_DLSCH_t *dlsch_eNB[NUMBER_OF_UE_MAX][2]; // Nusers times two spatial streams // old: LTE_eNB_DLSCH_t **dlsch_eNB[2]; // Nusers times two spatial streams - LTE_eNB_ULSCH_t *ulsch_eNB[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA - LTE_eNB_DLSCH_t *dlsch_eNB_SI,*dlsch_eNB_ra; - LTE_eNB_DLSCH_t *dlsch_eNB_MCH; - LTE_eNB_UE_stats eNB_UE_stats[NUMBER_OF_UE_MAX]; - LTE_eNB_UE_stats *eNB_UE_stats_ptr[NUMBER_OF_UE_MAX]; + LTE_eNB_ULSCH_t *ulsch_eNB[NUMBER_OF_UE_MAX+1]; // Nusers + number of RA + LTE_eNB_DLSCH_t *dlsch_eNB_SI,*dlsch_eNB_ra; + LTE_eNB_DLSCH_t *dlsch_eNB_MCH; + LTE_eNB_UE_stats eNB_UE_stats[NUMBER_OF_UE_MAX]; + LTE_eNB_UE_stats *eNB_UE_stats_ptr[NUMBER_OF_UE_MAX]; /// cell-specific reference symbols - unsigned int lte_gold_table[20][2][14]; + unsigned int lte_gold_table[20][2][14]; /// mbsfn reference symbols - unsigned int lte_gold_mbsfn_table[10][3][42]; + unsigned int lte_gold_mbsfn_table[10][3][42]; u32 X_u[64][839]; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 0740174ee66d46891d078189a72dfb674e679c98..95e0a6740f461dc6c1ff6039465a0fdb849d3cab 100755 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -1010,7 +1010,7 @@ void phy_procedures_UE_TX(u8 next_slot,PHY_VARS_UE *phy_vars_ue,u8 eNB_id,u8 abs // Check for SR and do ACK/NACK accordingly if (is_SR_TXOp(phy_vars_ue,eNB_id,next_slot>>1)==1) { - LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d: got SR_TXOp, Checking for SR for PUSCH from MAC\n", + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d: got SR_TXOp, Checking for SR for PUSCH from MAC\n", phy_vars_ue->Mod_id,phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->crnti,phy_vars_ue->frame,next_slot>>1); #ifdef OPENAIR2 SR_payload = mac_xface->ue_get_SR(phy_vars_ue->Mod_id, @@ -1024,7 +1024,7 @@ void phy_procedures_UE_TX(u8 next_slot,PHY_VARS_UE *phy_vars_ue,u8 eNB_id,u8 abs if (SR_payload>0) { generate_ul_signal = 1; - LOG_I(PHY,"[UE %d][SR %x] Frame %d subframe %d got the SR for PUSCH is %d\n", + LOG_D(PHY,"[UE %d][SR %x] Frame %d subframe %d got the SR for PUSCH is %d\n", phy_vars_ue->Mod_id,phy_vars_ue->lte_ue_pdcch_vars[eNB_id]->crnti,phy_vars_ue->frame,next_slot>>1,SR_payload); } else { diff --git a/openair2/COMMON/mac_rrc_primitives.h b/openair2/COMMON/mac_rrc_primitives.h index 9b53a0ab5ca6dc18bd8281285699a5b2d7d4fea6..4e83ecc11955b40b092490a967f4971e8ef2bc21 100644 --- a/openair2/COMMON/mac_rrc_primitives.h +++ b/openair2/COMMON/mac_rrc_primitives.h @@ -333,8 +333,8 @@ typedef struct{ //RRC_INTERFACE_FUNCTIONS char (*openair_rrc_eNB_init)(u8 ); char (*openair_rrc_UE_init)(u8, u8); RRC_status_t (*rrc_rx_tx)(u8,u32,u8,u8); - u8 (*mac_rrc_data_ind)(u8,u32,u16,u8 *,u16,u8 eNB_flag, u8 eNB_index); - u8 (*mac_rrc_data_req)(u8,u32,u16,u8,u8 *,u8 eNB_flag, u8 eNB_index); + u8 (*mac_rrc_data_ind)(u8,u32,u16,u8 *,u16,eNB_flag_t eNB_flag, u8 eNB_index); + u8 (*mac_rrc_data_req)(u8,u32,u16,u8,u8 *,eNB_flag_t eNB_flag, u8 eNB_index); void (*mac_rrc_meas_ind)(u8,MAC_MEAS_REQ_ENTRY*); void (*def_meas_ind)(u8, u8); void (*rrc_data_indP) (module_id_t , rb_id_t , sdu_size_t , char*); @@ -352,12 +352,7 @@ typedef struct{ unsigned short (*mac_config_req)(u8,u8,MAC_CONFIG_REQ*); MAC_MEAS_REQ_ENTRY* (*mac_meas_req)(u8 , MAC_MEAS_REQ*); void (*mac_out_of_sync_ind)(u8,u32,unsigned short); - //u8 (*mac_rrc_data_ind)(u8,unsigned short,char *,u8); - //u8 (*mac_rrc_data_req)( u8, unsigned short, u8,char *); - //void (*mac_switch_node_function)(u8); - // void (*mac_rlc_exit)(void); //RLC_INTERFACE_FUNCTIONS - // void (*pdcp_run)(unsigned int); void (*pdcp_run)(void); void (*pdcp_data_req)(module_id_t, rb_id_t, sdu_size_t, char*); signed int (*rrc_rlc_config_req)(unsigned int, unsigned int, unsigned int, unsigned int, rlc_info_t ); @@ -373,21 +368,18 @@ typedef struct{ u16 *SIperiod #ifdef Rel10 , - u8 MBMS_Flag, + MBMS_flag_t MBMS_Flag, struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList, MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, struct PMCH_InfoList_r9 *pmch_InfoList #endif ); unsigned int (*mac_rlc_data_req)(module_id_t, unsigned int, char*); - void (*mac_rlc_data_ind)(module_id_t, chan_id_t, char*, tb_size_t, num_tb_t, crc_t* ); - mac_rlc_status_resp_t (*mac_rlc_status_ind) (module_id_t, chan_id_t, tb_size_t, num_tb_t); + void (*mac_rlc_data_ind)(module_id_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, crc_t* ); + mac_rlc_status_resp_t (*mac_rlc_status_ind) (module_id_t, logical_chan_id_t, tb_size_t, num_tb_t); signed int (*rrc_rlc_data_req)(module_id_t, rb_id_t, mui_t, confirm_t, sdu_size_t, char *); void (*rrc_rlc_register_rrc) (void (*rrc_data_indP)(module_id_t , rb_id_t , sdu_size_t , char* ), void (*rrc_data_confP) (module_id_t , rb_id_t , mui_t ) ) ; - //rlc_op_status_t rrc_rlc_config_req (module_id_t, rb_id_t, rb_type_t, rlc_info_t ); - //rlc_op_status_t rrc_rlc_data_req (module_id_t, rb_id_t, mui_t, confirm_t, sdu_size_t, mem_block_t*); - //void rrc_rlc_register_rrc ( void(*rrc_data_indP) (module_id_t , rb_id_t , sdu_size_t , mem_block_t*),void(*rrc_data_conf) (module_id_t , rb_id_t , mui_t) ); void (*mrbch_phy_sync_failure) (u8 Mod_id, u32 frame, u8 Free_ch_index); void (*dl_phy_sync_success) (u8 Mod_id, u32 frame, u8 eNB_index); }MAC_RLC_XFACE; diff --git a/openair2/COMMON/platform_constants.h b/openair2/COMMON/platform_constants.h index e79eb691d9369fb2068ca4c5a956676acc79cdb5..a5f64e5641a627ee99743741ad5baf27a1b1f56d 100755 --- a/openair2/COMMON/platform_constants.h +++ b/openair2/COMMON/platform_constants.h @@ -55,8 +55,8 @@ #define MAX_MANAGED_RG_PER_MOBILE 2 #define DEFAULT_RAB_ID 3 -#define NB_RB_MAX 11 -#define NB_RAB_MAX 8 +#define NB_RB_MAX (maxDRB + 3) /* was 11, now 14, maxDRB comes from asn1_constants.h, + 3 because of 3 SRB, one invisible id 0, then id 1 and 2 */ +#define NB_RAB_MAX maxDRB /* was 8, now 11 */ #define RAB_SHIFT1 9 #define RAB_SHIFT2 3 #define RAB_OFFSET 0x0007 @@ -69,36 +69,36 @@ #ifdef MESH -# define MAX_RB_MOBILE NB_RB_MAX * ( MAX_MANAGED_RG_PER_MOBILE + MAX_MOBILES_PER_RG - 1 ) -# define MAX_RAB_MOBILE NB_RAB_MAX * ( MAX_MANAGED_RG_PER_MOBILE + MAX_MOBILES_PER_RG - 1 ) -# define MAX_RB_RG MAX_RB_MOBILE //NB_RB_MAX * MAX_MOBILES_PER_RG -# define MAX_RAB_RG (NB_RB_MAX+1) * (MAX_MOBILES_PER_RG + 1) -# define MAX_RAB MAX_RAB_RG -# define MAX_RB MAX_RB_RG +//# define MAX_RB_MOBILE NB_RB_MAX * ( MAX_MANAGED_RG_PER_MOBILE + MAX_MOBILES_PER_RG - 1 ) +//# define MAX_RAB_MOBILE NB_RAB_MAX * ( MAX_MANAGED_RG_PER_MOBILE + MAX_MOBILES_PER_RG - 1 ) +//# define MAX_RB_RG MAX_RB_MOBILE //NB_RB_MAX * MAX_MOBILES_PER_RG +//# define MAX_RAB_RG (NB_RB_MAX+1) * (MAX_MOBILES_PER_RG + 1) +//# define MAX_RAB MAX_RAB_RG +//# define MAX_RB MAX_RB_RG #else -# define MAX_RB_MOBILE NB_RB_MAX * MAX_MANAGED_RG_PER_MOBILE -# define MAX_RAB_MOBILE NB_RAB_MAX * MAX_MANAGED_RG_PER_MOBILE -# define MAX_RB_RG NB_RB_MAX * MAX_MOBILES_PER_RG -# define MAX_RAB_RG NB_RB_MAX * MAX_MOBILES_PER_RG -# //ifdef NODE_RG -# define MAX_RAB MAX_RAB_RG -# define MAX_RB MAX_RB_RG -# //else -# // ifdef NODE_MT -# // define MAX_RAB MAX_RAB_MOBILE -# // define MAX_RB MAX_RB_MOBILE -# //else -# //error NODE_RG or NODE_MT must be defined -# //endif +//# define MAX_RB_MOBILE NB_RB_MAX * MAX_MANAGED_RG_PER_MOBILE +//# define MAX_RAB_MOBILE NB_RAB_MAX * MAX_MANAGED_RG_PER_MOBILE +//# define MAX_RB_RG NB_RB_MAX * MAX_MOBILES_PER_RG +//# define MAX_RAB_RG NB_RB_MAX * MAX_MOBILES_PER_RG +//# ifdef NODE_RG +//# define MAX_RAB MAX_RAB_RG +//# define MAX_RB MAX_RB_RG +//# else +//# // ifdef NODE_MT +//# // define MAX_RAB MAX_RAB_MOBILE +//# // define MAX_RB MAX_RB_MOBILE +//# //else +//# //error NODE_RG or NODE_MT must be defined +//# //endif //# endif #endif //MESH // RLC_MODE -# define RLC_NONE 0 -# define RLC_MODE_AM 1 -# define RLC_MODE_TM 2 -# define RLC_MODE_UM 3 +# define RLC_NONE (rlc_mode_t)0 +# define RLC_MODE_AM (rlc_mode_t)1 +# define RLC_MODE_TM (rlc_mode_t)2 +# define RLC_MODE_UM (rlc_mode_t)3 //E_R # define E_R_RLC_ER_RELEASE 1 diff --git a/openair2/COMMON/platform_types.h b/openair2/COMMON/platform_types.h index 3d0cfe17c1fcbcfe1d22a5393a2df09abed91ba1..cee057831a3e9fe3bf434ad53e7c2eac9cb5907e 100755 --- a/openair2/COMMON/platform_types.h +++ b/openair2/COMMON/platform_types.h @@ -25,19 +25,29 @@ typedef signed long int s64_t; typedef unsigned int config_action_t; -typedef unsigned int sdu_size_t; +typedef u16_t sdu_size_t; +typedef s16_t sdu_ssize_t; typedef unsigned int tbs_size_t; typedef unsigned int tb_size_t; -typedef unsigned int rb_id_t; -typedef unsigned int module_id_t; +typedef u16_t rb_id_t; +typedef u16_t srb_id_t; +typedef u32_t frame_t; +typedef u32_t sub_frame_t; +typedef u8_t module_id_t; typedef unsigned int mui_t; typedef unsigned int confirm_t; typedef unsigned int rb_type_t; -typedef rb_id_t chan_id_t; +typedef unsigned int logical_chan_id_t; typedef unsigned int num_tb_t; typedef unsigned int crc_t; typedef unsigned int rlc_tx_status_t; typedef unsigned int rlc_mode_t; +typedef s16_t rlc_sn_t; +typedef u16_t rlc_usn_t; +typedef int traffic_type_t; +typedef u32_t mbms_session_id_t; +typedef u16_t mbms_service_id_t; +typedef u16_t rnti_t; typedef signed int rlc_op_status_t; @@ -47,8 +57,17 @@ typedef unsigned int crc32_t; typedef signed char boolean_t; +typedef enum MBMS_flag_e { + MBMS_FLAG_NO = 0, + MBMS_FLAG_YES = 1, +} MBMS_flag_t; + +typedef enum eNB_flag_e { + ENB_FLAG_NO = 0, + ENB_FLAG_YES = 1, +} eNB_flag_t; // just for integration -extern unsigned int frame; +extern frame_t frame; #endif diff --git a/openair2/COMMON/rrm_config_structs.h b/openair2/COMMON/rrm_config_structs.h index 5b673e34732f981634f9ab4e3736c99cd56d0597..7865cd63edcc8b73989ad05ee7be9b841b3eda99 100755 --- a/openair2/COMMON/rrm_config_structs.h +++ b/openair2/COMMON/rrm_config_structs.h @@ -10,7 +10,7 @@ ***************************************************************************/ - +#ifdef OLD_RRC_CELLULAR # ifndef __RRM_CONFIG_STRUCTS_H__ # define __RRM_CONFIG_STRUCTS_H__ @@ -171,4 +171,4 @@ typedef volatile struct { //typedef RG_CONFIG MAIN_RADIO_GATEWAY; # endif - +#endif diff --git a/openair2/LAYER2/MAC/config.c b/openair2/LAYER2/MAC/config.c index 97a9c750a003328cd8160ff816029e5b87ae6e7f..29137acb58584f1953715612d529d50ac3b1edc0 100644 --- a/openair2/LAYER2/MAC/config.c +++ b/openair2/LAYER2/MAC/config.c @@ -25,16 +25,16 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file config.c -* \brief UE and eNB configuration -* \author Raymond Knopp, Navid Nikaein -* \date 2013 -* \version 0.1 -* \email: navid.nikaein@eurecom.fr -* @ingroup _mac + * \brief UE and eNB configuration + * \author Raymond Knopp, Navid Nikaein + * \date 2013 + * \version 0.1 + * \email: navid.nikaein@eurecom.fr + * @ingroup _mac -*/ + */ #include "COMMON/platform_types.h" #include "COMMON/platform_constants.h" @@ -56,197 +56,197 @@ #endif /* sec 5.9, 36.321: MAC Reset Procedure */ -void ue_mac_reset(u8 Mod_id,u8 eNB_index) { - +void ue_mac_reset(module_id_t module_idP,u8 eNB_index) { + //Resetting Bj - UE_mac_inst[Mod_id].scheduling_info.Bj[0] = 0; - UE_mac_inst[Mod_id].scheduling_info.Bj[1] = 0; - UE_mac_inst[Mod_id].scheduling_info.Bj[2] = 0; + UE_mac_inst[module_idP].scheduling_info.Bj[0] = 0; + UE_mac_inst[module_idP].scheduling_info.Bj[1] = 0; + UE_mac_inst[module_idP].scheduling_info.Bj[2] = 0; //Stopping all timers - + //timeAlignmentTimer expires - + // PHY changes for UE MAC reset - mac_xface->phy_reset_ue(Mod_id,eNB_index); - + mac_xface->phy_reset_ue(module_idP,eNB_index); + // notify RRC to relase PUCCH/SRS // cancel all pending SRs - UE_mac_inst[Mod_id].scheduling_info.SR_pending=0; - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER=0; - + UE_mac_inst[module_idP].scheduling_info.SR_pending=0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + // stop ongoing RACH procedure - + // discard explicitly signaled ra_PreambleIndex and ra_RACH_MaskIndex, if any - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = 0; // check! - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - - ue_init_mac(Mod_id); //This will hopefully do the rest of the MAC reset procedure - + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = 0; // check! + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + + ue_init_mac(module_idP); //This will hopefully do the rest of the MAC reset procedure + } -int rrc_mac_config_req(u8 Mod_id,u8 eNB_flag,u8 UE_id,u8 eNB_index, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - struct PhysicalConfigDedicated *physicalConfigDedicated, - MeasObjectToAddMod_t **measObj, - MAC_MainConfig_t *mac_MainConfig, - long logicalChannelIdentity, - LogicalChannelConfig_t *logicalChannelConfig, - MeasGapConfig_t *measGapConfig, - TDD_Config_t *tdd_Config, - MobilityControlInfo_t *mobilityControlInfo, - u8 *SIwindowsize, - u16 *SIperiod, - ARFCN_ValueEUTRA_t *ul_CarrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList +int rrc_mac_config_req(module_id_t Mod_id, eNB_flag_t eNB_flagP,u8 UE_id,u8 eNB_index, + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, + struct PhysicalConfigDedicated *physicalConfigDedicated, + MeasObjectToAddMod_t **measObj, + MAC_MainConfig_t *mac_MainConfig, + long logicalChannelIdentity, + LogicalChannelConfig_t *logicalChannelConfig, + MeasGapConfig_t *measGapConfig, + TDD_Config_t *tdd_Config, + MobilityControlInfo_t *mobilityControlInfo, + u8 *SIwindowsize, + u16 *SIperiod, + ARFCN_ValueEUTRA_t *ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t *additionalSpectrumEmission, + struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList #ifdef Rel10 - ,u8 MBMS_Flag, - MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, - PMCH_InfoList_r9_t *pmch_InfoList + ,u8 MBMS_Flag, + MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, + PMCH_InfoList_r9_t *pmch_InfoList #endif #ifdef CBA - ,u8 num_active_cba_groups, - u16 cba_rnti + ,u8 num_active_cba_groups, + u16 cba_rnti #endif - ) { +) { int i; vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RRC_MAC_CONFIG, VCD_FUNCTION_IN); - if (eNB_flag==0) { - LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_id,eNB_index); - if (tdd_Config != NULL) - UE_mac_inst[Mod_id].tdd_Config = tdd_Config; + if (eNB_flagP==0) { + LOG_I(MAC,"[CONFIG][UE %d] Configuring MAC/PHY from eNB %d\n",Mod_id,eNB_index); + if (tdd_Config != NULL) + UE_mac_inst[Mod_id].tdd_Config = tdd_Config; }else { - if (physicalConfigDedicated == NULL){ - LOG_I(MAC,"[CONFIG][eNB %d] Configuring MAC/PHY\n",Mod_id); - } else{ - LOG_I(MAC,"[CONFIG][eNB %d] Configuring MAC/PHY for UE %d (%x)\n",Mod_id,UE_id,find_UE_RNTI(Mod_id,UE_id)); - } + if (physicalConfigDedicated == NULL){ + LOG_I(MAC,"[CONFIG][eNB %d] Configuring MAC/PHY\n",Mod_id); + } else{ + LOG_I(MAC,"[CONFIG][eNB %d] Configuring MAC/PHY for UE %d (%x)\n",Mod_id,UE_id,find_UE_RNTI(Mod_id,UE_id)); + } } - + if ((tdd_Config!=NULL)||(SIwindowsize!=NULL)||(SIperiod!=NULL)){ - if (eNB_flag==1) - mac_xface->phy_config_sib1_eNB(Mod_id,tdd_Config,*SIwindowsize,*SIperiod); - else - mac_xface->phy_config_sib1_ue(Mod_id,eNB_index,tdd_Config,*SIwindowsize,*SIperiod); + if (eNB_flagP==1) + mac_xface->phy_config_sib1_eNB(Mod_id,tdd_Config,*SIwindowsize,*SIperiod); + else + mac_xface->phy_config_sib1_ue(Mod_id,eNB_index,tdd_Config,*SIwindowsize,*SIperiod); } if (radioResourceConfigCommon!=NULL) { - if (eNB_flag==1) { - LOG_I(MAC,"[CONFIG]SIB2/3 Contents (partial)\n"); - LOG_I(MAC,"[CONFIG]pusch_config_common.n_SB = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB); - LOG_I(MAC,"[CONFIG]pusch_config_common.hoppingMode = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); - LOG_I(MAC,"[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); - LOG_I(MAC,"[CONFIG]pusch_config_common.enable64QAM = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); - LOG_I(MAC,"[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); - LOG_I(MAC,"[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); - LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); - LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); - mac_xface->phy_config_sib2_eNB(Mod_id,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList); - } - else { - UE_mac_inst[Mod_id].radioResourceConfigCommon = radioResourceConfigCommon; - mac_xface->phy_config_sib2_ue(Mod_id,eNB_index,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList); - } + if (eNB_flagP==1) { + LOG_I(MAC,"[CONFIG]SIB2/3 Contents (partial)\n"); + LOG_I(MAC,"[CONFIG]pusch_config_common.n_SB = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.n_SB); + LOG_I(MAC,"[CONFIG]pusch_config_common.hoppingMode = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.hoppingMode); + LOG_I(MAC,"[CONFIG]pusch_config_common.pusch_HoppingOffset = %ld\n", radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.pusch_HoppingOffset); + LOG_I(MAC,"[CONFIG]pusch_config_common.enable64QAM = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.pusch_ConfigBasic.enable64QAM); + LOG_I(MAC,"[CONFIG]pusch_config_common.groupHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupHoppingEnabled); + LOG_I(MAC,"[CONFIG]pusch_config_common.groupAssignmentPUSCH = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH); + LOG_I(MAC,"[CONFIG]pusch_config_common.sequenceHoppingEnabled = %d\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled); + LOG_I(MAC,"[CONFIG]pusch_config_common.cyclicShift = %ld\n",radioResourceConfigCommon->pusch_ConfigCommon.ul_ReferenceSignalsPUSCH.cyclicShift); + mac_xface->phy_config_sib2_eNB(Mod_id,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList); + } + else { + UE_mac_inst[Mod_id].radioResourceConfigCommon = radioResourceConfigCommon; + mac_xface->phy_config_sib2_ue(Mod_id,eNB_index,radioResourceConfigCommon,ul_CarrierFreq,ul_Bandwidth,additionalSpectrumEmission,mbsfn_SubframeConfigList); + } } // SRB2_lchan_config->choice.explicitValue.ul_SpecificParameters->logicalChannelGroup if (logicalChannelConfig!= NULL) { - if (eNB_flag==0){ - LOG_I(MAC,"[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n",Mod_id,eNB_index); - UE_mac_inst[Mod_id].logicalChannelConfig[logicalChannelIdentity]=logicalChannelConfig; - UE_mac_inst[Mod_id].scheduling_info.Bj[logicalChannelIdentity]=0; // initilize the bucket for this lcid - if (logicalChannelConfig->ul_SpecificParameters) { - UE_mac_inst[Mod_id].scheduling_info.bucket_size[logicalChannelIdentity]=logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * - logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size - UE_mac_inst[Mod_id].scheduling_info.LCGID[logicalChannelIdentity]=*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; - LOG_D(MAC,"[CONFIG][UE %d] LCID %d is attached to the LCGID %d\n",Mod_id,logicalChannelIdentity,*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup); - } else { - LOG_E(MAC,"[CONFIG][UE %d] LCID %d NULL ul_SpecificParameters\n",Mod_id,logicalChannelIdentity); - mac_xface->macphy_exit(""); + if (eNB_flagP==0){ + LOG_I(MAC,"[CONFIG][UE %d] Applying RRC logicalChannelConfig from eNB%d\n",Mod_id,eNB_index); + UE_mac_inst[Mod_id].logicalChannelConfig[logicalChannelIdentity]=logicalChannelConfig; + UE_mac_inst[Mod_id].scheduling_info.Bj[logicalChannelIdentity]=0; // initilize the bucket for this lcid + if (logicalChannelConfig->ul_SpecificParameters) { + UE_mac_inst[Mod_id].scheduling_info.bucket_size[logicalChannelIdentity]=logicalChannelConfig->ul_SpecificParameters->prioritisedBitRate * + logicalChannelConfig->ul_SpecificParameters->bucketSizeDuration; // set the max bucket size + UE_mac_inst[Mod_id].scheduling_info.LCGID[logicalChannelIdentity]=*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup; + LOG_D(MAC,"[CONFIG][UE %d] LCID %d is attached to the LCGID %d\n",Mod_id,logicalChannelIdentity,*logicalChannelConfig->ul_SpecificParameters->logicalChannelGroup); + } else { + LOG_E(MAC,"[CONFIG][UE %d] LCID %d NULL ul_SpecificParameters\n",Mod_id,logicalChannelIdentity); + mac_xface->macphy_exit(""); + } } - } } if (mac_MainConfig != NULL){ - if (eNB_flag==0){ - LOG_I(MAC,"[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n",Mod_id,eNB_index); - UE_mac_inst[Mod_id].macConfig=mac_MainConfig; - UE_mac_inst[Mod_id].measGapConfig=measGapConfig; - if (mac_MainConfig->ul_SCH_Config) { - - if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) - UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (u16) *mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; - else - UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (u16) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; - - if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) - UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (u16) *mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; - else - UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (u16) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; - if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) - UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (u16) mac_MainConfig->ul_SCH_Config->retxBSR_Timer; - else - UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (u16)MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; - } + if (eNB_flagP==0){ + LOG_I(MAC,"[CONFIG][UE%d] Applying RRC macMainConfig from eNB%d\n",Mod_id,eNB_index); + UE_mac_inst[Mod_id].macConfig=mac_MainConfig; + UE_mac_inst[Mod_id].measGapConfig=measGapConfig; + if (mac_MainConfig->ul_SCH_Config) { + + if (mac_MainConfig->ul_SCH_Config->periodicBSR_Timer) + UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (u16) *mac_MainConfig->ul_SCH_Config->periodicBSR_Timer; + else + UE_mac_inst[Mod_id].scheduling_info.periodicBSR_Timer = (u16) MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; + + if (mac_MainConfig->ul_SCH_Config->maxHARQ_Tx) + UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (u16) *mac_MainConfig->ul_SCH_Config->maxHARQ_Tx; + else + UE_mac_inst[Mod_id].scheduling_info.maxHARQ_Tx = (u16) MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + if (mac_MainConfig->ul_SCH_Config->retxBSR_Timer) + UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (u16) mac_MainConfig->ul_SCH_Config->retxBSR_Timer; + else + UE_mac_inst[Mod_id].scheduling_info.retxBSR_Timer = (u16)MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; + } #ifdef Rel10 - if (mac_MainConfig->sr_ProhibitTimer_r9) - UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (u16) *mac_MainConfig->sr_ProhibitTimer_r9; - else - UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (u16) 0; + if (mac_MainConfig->sr_ProhibitTimer_r9) + UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (u16) *mac_MainConfig->sr_ProhibitTimer_r9; + else + UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer = (u16) 0; #endif - 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.drx_config = mac_MainConfig->drx_Config; - UE_mac_inst[Mod_id].scheduling_info.phr_config = mac_MainConfig->phr_Config; - if (mac_MainConfig->phr_Config){ - UE_mac_inst[Mod_id].PHR_state = mac_MainConfig->phr_Config->present; - UE_mac_inst[Mod_id].PHR_reconfigured = 1; - UE_mac_inst[Mod_id].scheduling_info.periodicPHR_Timer = mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer; - UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_Timer = mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer; - UE_mac_inst[Mod_id].scheduling_info.PathlossChange = mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange; - } else { - UE_mac_inst[Mod_id].PHR_reconfigured = 0; - UE_mac_inst[Mod_id].PHR_state = MAC_MainConfig__phr_Config_PR_setup; - 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 = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; - } - 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); - LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", - Mod_id,mac_MainConfig->phr_Config->present, - UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF, - UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF, - UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db); - } + 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.drx_config = mac_MainConfig->drx_Config; + UE_mac_inst[Mod_id].scheduling_info.phr_config = mac_MainConfig->phr_Config; + if (mac_MainConfig->phr_Config){ + UE_mac_inst[Mod_id].PHR_state = mac_MainConfig->phr_Config->present; + UE_mac_inst[Mod_id].PHR_reconfigured = 1; + UE_mac_inst[Mod_id].scheduling_info.periodicPHR_Timer = mac_MainConfig->phr_Config->choice.setup.periodicPHR_Timer; + UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_Timer = mac_MainConfig->phr_Config->choice.setup.prohibitPHR_Timer; + UE_mac_inst[Mod_id].scheduling_info.PathlossChange = mac_MainConfig->phr_Config->choice.setup.dl_PathlossChange; + } else { + UE_mac_inst[Mod_id].PHR_reconfigured = 0; + UE_mac_inst[Mod_id].PHR_state = MAC_MainConfig__phr_Config_PR_setup; + 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 = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + } + 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); + LOG_D(MAC,"[UE %d] config PHR (%d): periodic %d (SF) prohibit %d (SF) pathlosschange %d (db) \n", + Mod_id,mac_MainConfig->phr_Config->present, + UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF, + UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF, + UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db); + } } if (physicalConfigDedicated != NULL) { - if (eNB_flag==1){ - mac_xface->phy_config_dedicated_eNB(Mod_id,find_UE_RNTI(Mod_id,UE_id),physicalConfigDedicated); - }else{ - mac_xface->phy_config_dedicated_ue(Mod_id,eNB_index,physicalConfigDedicated); - UE_mac_inst[Mod_id].physicalConfigDedicated=physicalConfigDedicated; // for SR proc - } + if (eNB_flagP==1){ + mac_xface->phy_config_dedicated_eNB(Mod_id,find_UE_RNTI(Mod_id,UE_id),physicalConfigDedicated); + }else{ + mac_xface->phy_config_dedicated_ue(Mod_id,eNB_index,physicalConfigDedicated); + UE_mac_inst[Mod_id].physicalConfigDedicated=physicalConfigDedicated; // for SR proc + } } - if (eNB_flag == 0) { - if (measObj!= NULL) { - if (measObj[0]!= NULL){ - UE_mac_inst[Mod_id].n_adj_cells = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.count; - LOG_I(MAC,"Number of adjacent cells %d\n",UE_mac_inst[Mod_id].n_adj_cells); - for (i=0;i<UE_mac_inst[Mod_id].n_adj_cells;i++) { - UE_mac_inst[Mod_id].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_id].adj_cell_id[i]); - } - mac_xface->phy_config_meas_ue(Mod_id,eNB_index,UE_mac_inst[Mod_id].n_adj_cells,UE_mac_inst[Mod_id].adj_cell_id); - } - /* + if (eNB_flagP == 0) { + if (measObj!= NULL) { + if (measObj[0]!= NULL){ + UE_mac_inst[Mod_id].n_adj_cells = measObj[0]->measObject.choice.measObjectEUTRA.cellsToAddModList->list.count; + LOG_I(MAC,"Number of adjacent cells %d\n",UE_mac_inst[Mod_id].n_adj_cells); + for (i=0;i<UE_mac_inst[Mod_id].n_adj_cells;i++) { + UE_mac_inst[Mod_id].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_id].adj_cell_id[i]); + } + mac_xface->phy_config_meas_ue(Mod_id,eNB_index,UE_mac_inst[Mod_id].n_adj_cells,UE_mac_inst[Mod_id].adj_cell_id); + } + /* if (quantityConfig != NULL) { if (quantityConfig[0] != NULL) { UE_mac_inst[Mod_id].quantityConfig = quantityConfig[0]; @@ -254,193 +254,193 @@ int rrc_mac_config_req(u8 Mod_id,u8 eNB_flag,u8 UE_id,u8 eNB_index, mac_xface->phy_config_meas_ue } } - */ - } - } - if (eNB_flag==0) { - if(mobilityControlInfo != NULL) { - - LOG_D(MAC,"[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",Mod_id,eNB_index); - ue_mac_reset(Mod_id,eNB_index); - - if(mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon, - sizeof(RACH_ConfigCommon_t)); + */ } - - memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->prach_Config.prach_ConfigInfo, - (void *)mobilityControlInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo, - sizeof(PRACH_ConfigInfo_t)); - UE_mac_inst[Mod_id].radioResourceConfigCommon->prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex; - - if(mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_id].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_id].radioResourceConfigCommon->pusch_ConfigCommon, - (void *)&mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon, - sizeof(PUSCH_ConfigCommon_t)); - - if(mobilityControlInfo->radioResourceConfigCommon.phich_Config) { - /* memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->phich_Config, + } + if (eNB_flagP==0) { + if(mobilityControlInfo != NULL) { + + LOG_D(MAC,"[UE%d] MAC Reset procedure triggered by RRC eNB %d \n",Mod_id,eNB_index); + ue_mac_reset(Mod_id,eNB_index); + + if(mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon) { + memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon, + (void *)mobilityControlInfo->radioResourceConfigCommon.rach_ConfigCommon, + sizeof(RACH_ConfigCommon_t)); + } + + memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->prach_Config.prach_ConfigInfo, + (void *)mobilityControlInfo->radioResourceConfigCommon.prach_Config.prach_ConfigInfo, + sizeof(PRACH_ConfigInfo_t)); + UE_mac_inst[Mod_id].radioResourceConfigCommon->prach_Config.rootSequenceIndex = mobilityControlInfo->radioResourceConfigCommon.prach_Config.rootSequenceIndex; + + if(mobilityControlInfo->radioResourceConfigCommon.pdsch_ConfigCommon) { + memcpy((void *)&UE_mac_inst[Mod_id].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_id].radioResourceConfigCommon->pusch_ConfigCommon, + (void *)&mobilityControlInfo->radioResourceConfigCommon.pusch_ConfigCommon, + sizeof(PUSCH_ConfigCommon_t)); + + if(mobilityControlInfo->radioResourceConfigCommon.phich_Config) { + /* memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->phich_Config, (void *)mobilityControlInfo->radioResourceConfigCommon.phich_Config, sizeof(PHICH_Config_t)); */ + } + if(mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon) { + memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->pucch_ConfigCommon, + (void *)mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon, + sizeof(PUCCH_ConfigCommon_t)); + } + if(mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { + memcpy((void *)&UE_mac_inst[Mod_id].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_id].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_id].tdd_Config = mobilityControlInfo->radioResourceConfigCommon.tdd_Config; + } + if(mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength) { + memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->ul_CyclicPrefixLength, + (void *)mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength, + sizeof(UL_CyclicPrefixLength_t)); + } + // store the previous rnti in case of failure, and set thenew rnti + UE_mac_inst[Mod_id].crnti_before_ho = UE_mac_inst[Mod_id].crnti; + UE_mac_inst[Mod_id].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_id, UE_mac_inst[Mod_id].crnti, eNB_index); + UE_mac_inst[Mod_id].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated)); + if (mobilityControlInfo->rach_ConfigDedicated){ + memcpy((void*)UE_mac_inst[Mod_id].rach_ConfigDedicated, + (void*)mobilityControlInfo->rach_ConfigDedicated, + sizeof(*mobilityControlInfo->rach_ConfigDedicated)); + } + mac_xface->phy_config_afterHO_ue(Mod_id,eNB_index,mobilityControlInfo,0); } - if(mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->pucch_ConfigCommon, - (void *)mobilityControlInfo->radioResourceConfigCommon.pucch_ConfigCommon, - sizeof(PUCCH_ConfigCommon_t)); - } - if(mobilityControlInfo->radioResourceConfigCommon.soundingRS_UL_ConfigCommon) { - memcpy((void *)&UE_mac_inst[Mod_id].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_id].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_id].tdd_Config = mobilityControlInfo->radioResourceConfigCommon.tdd_Config; - } - if(mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength) { - memcpy((void *)&UE_mac_inst[Mod_id].radioResourceConfigCommon->ul_CyclicPrefixLength, - (void *)mobilityControlInfo->radioResourceConfigCommon.ul_CyclicPrefixLength, - sizeof(UL_CyclicPrefixLength_t)); - } - // store the previous rnti in case of failure, and set thenew rnti - UE_mac_inst[Mod_id].crnti_before_ho = UE_mac_inst[Mod_id].crnti; - UE_mac_inst[Mod_id].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_id, UE_mac_inst[Mod_id].crnti, eNB_index); - UE_mac_inst[Mod_id].rach_ConfigDedicated = malloc(sizeof(*mobilityControlInfo->rach_ConfigDedicated)); - if (mobilityControlInfo->rach_ConfigDedicated){ - memcpy((void*)UE_mac_inst[Mod_id].rach_ConfigDedicated, - (void*)mobilityControlInfo->rach_ConfigDedicated, - sizeof(*mobilityControlInfo->rach_ConfigDedicated)); - } - mac_xface->phy_config_afterHO_ue(Mod_id,eNB_index,mobilityControlInfo,0); - } } - + if (mbsfn_SubframeConfigList != NULL) { - if (eNB_flag == 1) { - LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_id, mbsfn_SubframeConfigList->list.count); - eNB_mac_inst[Mod_id].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count; - for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { - eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; - LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", Mod_id, i, - eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); - } + if (eNB_flagP == 1) { + LOG_I(MAC,"[eNB %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_id, mbsfn_SubframeConfigList->list.count); + eNB_mac_inst[Mod_id].num_sf_allocation_pattern= mbsfn_SubframeConfigList->list.count; + for (i=0; i<mbsfn_SubframeConfigList->list.count; i++) { + eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; + LOG_I(MAC, "[eNB %d][CONFIG] MBSFN_SubframeConfig[%d] pattern is %x\n", Mod_id, i, + eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); + } #ifdef Rel10 - eNB_mac_inst[Mod_id].MBMS_flag = MBMS_Flag; + eNB_mac_inst[Mod_id].MBMS_flag = MBMS_Flag; #endif - } - else { // UE - LOG_I(MAC,"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_id, mbsfn_SubframeConfigList->list.count); - UE_mac_inst[Mod_id].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_id, i); - UE_mac_inst[Mod_id].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; - // LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_id, - // UE_mac_inst[Mod_id].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); } - } + else { // UE + LOG_I(MAC,"[UE %d][CONFIG] Received %d subframe allocation pattern for MBSFN\n", Mod_id, mbsfn_SubframeConfigList->list.count); + UE_mac_inst[Mod_id].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_id, i); + UE_mac_inst[Mod_id].mbsfn_SubframeConfig[i] = mbsfn_SubframeConfigList->list.array[i]; + // LOG_I("[UE %d] MBSFN_SubframeConfig[%d] pattern is %ld\n", Mod_id, + // UE_mac_inst[Mod_id].mbsfn_SubframeConfig[i]->subframeAllocation.choice.oneFrame.buf[0]); + } + } } #ifdef Rel10 if (mbsfn_AreaInfoList != NULL) { - if (eNB_flag == 1) { - // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time - LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_id, mbsfn_AreaInfoList->list.count); - eNB_mac_inst[Mod_id].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; - for (i =0; i< mbsfn_AreaInfoList->list.count; i++) { - eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i]; - LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_id,i, - eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - mac_xface->phy_config_sib13_eNB(Mod_id,i,eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); + if (eNB_flagP == 1) { + // One eNB could be part of multiple mbsfn syc area, this could change over time so reset each time + LOG_I(MAC,"[eNB %d][CONFIG] Received %d MBSFN Area Info\n", Mod_id, mbsfn_AreaInfoList->list.count); + eNB_mac_inst[Mod_id].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; + for (i =0; i< mbsfn_AreaInfoList->list.count; i++) { + eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i]; + LOG_I(MAC,"[eNB %d][CONFIG] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n", Mod_id,i, + eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + mac_xface->phy_config_sib13_eNB(Mod_id,i,eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); + } } - } - else { // UE - LOG_I(MAC,"[UE %d][CONFIG] Received %d MBSFN Area Info\n", Mod_id, mbsfn_AreaInfoList->list.count); - UE_mac_inst[Mod_id].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; - for (i =0; i< mbsfn_AreaInfoList->list.count; i++) { - UE_mac_inst[Mod_id].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i]; - LOG_I(MAC,"[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n",Mod_id, i, - UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - mac_xface->phy_config_sib13_ue(Mod_id,eNB_index,i,UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mbsfn_AreaId_r9); + else { // UE + LOG_I(MAC,"[UE %d][CONFIG] Received %d MBSFN Area Info\n", Mod_id, mbsfn_AreaInfoList->list.count); + UE_mac_inst[Mod_id].num_active_mbsfn_area = mbsfn_AreaInfoList->list.count; + for (i =0; i< mbsfn_AreaInfoList->list.count; i++) { + UE_mac_inst[Mod_id].mbsfn_AreaInfo[i] = mbsfn_AreaInfoList->list.array[i]; + LOG_I(MAC,"[UE %d] MBSFN_AreaInfo[%d]: MCCH Repetition Period = %ld\n",Mod_id, i, + UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + mac_xface->phy_config_sib13_ue(Mod_id,eNB_index,i,UE_mac_inst[Mod_id].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,"DUY: lcid when entering rrc_mac config_req is %02d\n",(pmch_InfoList->list.array[0]->mbms_SessionInfoList_r9.list.array[0]->logicalChannelIdentity_r9)); - if (eNB_flag == 1) { + if (eNB_flagP == 1) { - LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count); + LOG_I(MAC, "[CONFIG] Number of PMCH in this MBSFN Area %d\n", pmch_InfoList->list.count); - for (i =0; i< pmch_InfoList->list.count; i++) { - eNB_mac_inst[Mod_id].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9; + for (i =0; i< pmch_InfoList->list.count; i++) { + eNB_mac_inst[Mod_id].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9; - LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop at subframe %ldth\n", i, - eNB_mac_inst[Mod_id].pmch_Config[i]->sf_AllocEnd_r9); - LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i, - eNB_mac_inst[Mod_id].pmch_Config[i]->mch_SchedulingPeriod_r9); - LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i, - eNB_mac_inst[Mod_id].pmch_Config[i]->dataMCS_r9); + LOG_I(MAC, "[CONFIG] PMCH[%d]: This PMCH stop at subframe %ldth\n", i, + eNB_mac_inst[Mod_id].pmch_Config[i]->sf_AllocEnd_r9); + LOG_I(MAC, "[CONFIG] PMCH[%d]: mch_Scheduling_Period = %ld\n", i, + eNB_mac_inst[Mod_id].pmch_Config[i]->mch_SchedulingPeriod_r9); + LOG_I(MAC, "[CONFIG] PMCH[%d]: dataMCS = %ld\n", i, + eNB_mac_inst[Mod_id].pmch_Config[i]->dataMCS_r9); - // MBMS session info list in each MCH - eNB_mac_inst[Mod_id].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; - LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, eNB_mac_inst[Mod_id].mbms_SessionList[i]->list.count); + // MBMS session info list in each MCH + eNB_mac_inst[Mod_id].mbms_SessionList[i] = &pmch_InfoList->list.array[i]->mbms_SessionInfoList_r9; + LOG_I(MAC, "PMCH[%d] Number of session (MTCH) is: %d\n",i, eNB_mac_inst[Mod_id].mbms_SessionList[i]->list.count); + } } - } - else { // UE - LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n",Mod_id); - for (i =0; i< pmch_InfoList->list.count; i++) { - UE_mac_inst[Mod_id].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9; - LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", Mod_id, i, - UE_mac_inst[Mod_id].pmch_Config[i]->mch_SchedulingPeriod_r9); + else { // UE + LOG_I(MAC, "[UE %d] Configuring PMCH_config from MCCH MESSAGE \n",Mod_id); + for (i =0; i< pmch_InfoList->list.count; i++) { + UE_mac_inst[Mod_id].pmch_Config[i] = &pmch_InfoList->list.array[i]->pmch_Config_r9; + LOG_I(MAC, "[UE %d] PMCH[%d]: MCH_Scheduling_Period = %ld\n", Mod_id, i, + UE_mac_inst[Mod_id].pmch_Config[i]->mch_SchedulingPeriod_r9); + } + UE_mac_inst[Mod_id].mcch_status = 1; } - UE_mac_inst[Mod_id].mcch_status = 1; - } } - + #endif #ifdef CBA - if (eNB_flag == 0){ - if (cba_rnti) { - UE_mac_inst[Mod_id].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_id,Mod_id%num_active_cba_groups, cba_rnti,eNB_index,num_active_cba_groups); - mac_xface->phy_config_cba_rnti(Mod_id,eNB_flag,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups); - } + if (eNB_flagP == 0){ + if (cba_rnti) { + UE_mac_inst[Mod_id].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_id,Mod_id%num_active_cba_groups, cba_rnti,eNB_index,num_active_cba_groups); + mac_xface->phy_config_cba_rnti(Mod_id,eNB_flagP,eNB_index,cba_rnti,num_active_cba_groups-1, num_active_cba_groups); + } }else { - if (cba_rnti) { - LOG_D(MAC,"[eNB %d] configure CBA RNTI for UE %d (total active cba groups %d)\n", - Mod_id, UE_id, num_active_cba_groups); - eNB_mac_inst[Mod_id].num_active_cba_groups=num_active_cba_groups; - for (i=0; i < num_active_cba_groups; i ++){ - if (eNB_mac_inst[Mod_id].cba_rnti[i] != cba_rnti + i) - eNB_mac_inst[Mod_id].cba_rnti[i] = cba_rnti + i; - //only configure UE ids up to num_active_cba_groups - //we use them as candidates for the transmission of dci format0) - if (UE_id%num_active_cba_groups == i){ - mac_xface->phy_config_cba_rnti(Mod_id,eNB_flag,UE_id,cba_rnti + i,i,num_active_cba_groups ); - LOG_D(MAC,"[eNB %d] configure CBA groups %d with RNTI %x for UE %d (total active cba groups %d)\n", - Mod_id, i, eNB_mac_inst[Mod_id].cba_rnti[i],UE_id, num_active_cba_groups); - } + if (cba_rnti) { + LOG_D(MAC,"[eNB %d] configure CBA RNTI for UE %d (total active cba groups %d)\n", + Mod_id, UE_id, num_active_cba_groups); + eNB_mac_inst[Mod_id].num_active_cba_groups=num_active_cba_groups; + for (i=0; i < num_active_cba_groups; i ++){ + if (eNB_mac_inst[Mod_id].cba_rnti[i] != cba_rnti + i) + eNB_mac_inst[Mod_id].cba_rnti[i] = cba_rnti + i; + //only configure UE ids up to num_active_cba_groups + //we use them as candidates for the transmission of dci format0) + if (UE_id%num_active_cba_groups == i){ + mac_xface->phy_config_cba_rnti(Mod_id,eNB_flagP,UE_id,cba_rnti + i,i,num_active_cba_groups ); + LOG_D(MAC,"[eNB %d] configure CBA groups %d with RNTI %x for UE %d (total active cba groups %d)\n", + Mod_id, i, eNB_mac_inst[Mod_id].cba_rnti[i],UE_id, num_active_cba_groups); + } + } } - } } #endif diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index 891df48d7ccc9498327077fb14b751c00d1ce07d..adee2caf608c8b2a16ef040d922e59bbb5d965e9 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -333,7 +333,7 @@ typedef enum { // temp struct for sched typedef struct { - u16 rnti; + rnti_t rnti; u16 subframe; u16 serving_num; UE_ULSCH_STATUS status; @@ -341,7 +341,7 @@ typedef struct { // temp struct for sched typedef struct { - u16 rnti; + rnti_t rnti; u16 weight; u16 subframe; u16 serving_num; @@ -383,7 +383,7 @@ typedef struct{ typedef struct{ /// CRNTI of UE - uint16_t crnti; ///user id (rnti) of connected UEs + rnti_t crnti; ///user id (rnti) of connected UEs // rrc status uint8_t rrc_status; /// harq pid @@ -466,7 +466,7 @@ typedef struct{ typedef struct{ /// C-RNTI of UE - u16 rnti; + rnti_t rnti; /// NDI from last scheduling uint8_t oldNDI[8]; /// NDI from last UL scheduling @@ -566,7 +566,7 @@ typedef struct { /// Flag to indicate that eNB is waiting for ACK that UE has received Msg3. u8 wait_ack_Msg4; /// UE RNTI allocated during RAR - u16 rnti; + rnti_t rnti; /// RA RNTI allocated from received PRACH u16 RA_rnti; /// Received preamble_index @@ -597,9 +597,9 @@ typedef struct{ /// u16 Node_id; /// frame counter - u32 frame; + frame_t frame; /// subframe counter - u32 subframe; + sub_frame_t subframe; /// Outgoing DCI for PHY generated by eNB scheduler DCI_PDU DCI_pdu; /// Outgoing BCCH pdu for PHY @@ -711,13 +711,13 @@ typedef struct { typedef struct{ u16 Node_id; /// frame counter - u32 frame; + frame_t frame; /// subframe counter - u32 subframe; + sub_frame_t subframe; /// C-RNTI of UE u16 crnti; /// C-RNTI of UE before HO - uint16_t crnti_before_ho; ///user id (rnti) of connected UEs + rnti_t crnti_before_ho; ///user id (rnti) of connected UEs /// uplink active flag uint8_t ul_active; /// pointer to RRC PHY configuration @@ -858,33 +858,36 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, @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(u8 Mod_id,u8 eNB_flag,u8 UE_id,u8 eNB_index, - RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, - struct PhysicalConfigDedicated *physicalConfigDedicated, - MeasObjectToAddMod_t **measObj, - MAC_MainConfig_t *mac_MainConfig, - long logicalChannelIdentity, - LogicalChannelConfig_t *logicalChannelConfig, - MeasGapConfig_t *measGapConfig, - TDD_Config_t *tdd_Config, - MobilityControlInfo_t *mobilityControlInfo, - u8 *SIwindowsize, - u16 *SIperiod, - ARFCN_ValueEUTRA_t *ul_CarrierFreq, - long *ul_Bandwidth, - AdditionalSpectrumEmission_t *additionalSpectrumEmission, - struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList +int rrc_mac_config_req(module_id_t module_idP, + eNB_flag_t eNB_flag, + u8 UE_id, + u8 eNB_index, + RadioResourceConfigCommonSIB_t *radioResourceConfigCommon, + struct PhysicalConfigDedicated *physicalConfigDedicated, + MeasObjectToAddMod_t **measObj, + MAC_MainConfig_t *mac_MainConfig, + long logicalChannelIdentity, + LogicalChannelConfig_t *logicalChannelConfig, + MeasGapConfig_t *measGapConfig, + TDD_Config_t *tdd_Config, + MobilityControlInfo_t *mobilityControlInfo, + u8 *SIwindowsize, + u16 *SIperiod, + ARFCN_ValueEUTRA_t *ul_CarrierFreq, + long *ul_Bandwidth, + AdditionalSpectrumEmission_t *additionalSpectrumEmission, + struct MBSFN_SubframeConfigList *mbsfn_SubframeConfigList #ifdef Rel10 - , - u8 MBMS_Flag, - MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, - PMCH_InfoList_r9_t *pmch_InfoList + , + u8 MBMS_Flag, + MBSFN_AreaInfoList_r9_t *mbsfn_AreaInfoList, + PMCH_InfoList_r9_t *pmch_InfoList #endif #ifdef CBA - , - u8 num_active_cba_groups, - u16 cba_rnti + , + u8 num_active_cba_groups, + u16 cba_rnti #endif ); @@ -897,7 +900,7 @@ for the message. @param nprb Pointer to current PRB count @param nCCE Pointer to current nCCE count */ -void schedule_RA(u8 Mod_id,u32 frame,u8 subframe,u8 Msg3_subframe,u8 *nprb,unsigned int *nCCE); +void schedule_RA(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,u8 Msg3_subframe,u8 *nprb,unsigned int *nCCE); /** \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 @@ -907,21 +910,21 @@ void schedule_RA(u8 Mod_id,u32 frame,u8 subframe,u8 Msg3_subframe,u8 *nprb,unsig @param nprb Pointer to current PRB count @param nCCE Pointer to current nCCE count */ -void schedule_SI(u8 Mod_id,u32 frame,u8 *nprb,unsigned int *nCCE); +void schedule_SI(module_id_t module_idP,frame_t frameP,u8 *nprb,unsigned int *nCCE); /** \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(unsigned char Mod_id,u32 frame, u8 subframe); +int schedule_MBMS(module_id_t module_idP,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 */ -s8 get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area); +s8 get_mbsfn_sf_alloction (module_id_t module_idP, u8 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 @@ -929,7 +932,7 @@ s8 get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area); @param eNB_index index of eNB @param[out] index of sf pattern */ -s8 ue_get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area, unsigned char eNB_index); +s8 ue_get_mbsfn_sf_alloction (module_id_t module_idP, u8 mbsfn_sync_area, unsigned char eNB_index); /** \brief top ULSCH Scheduling for TDD (config 1-6). @param Mod_id Instance ID of eNB @@ -938,7 +941,7 @@ s8 ue_get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area, unsigned @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) @param nCCE Pointer to current nCCE count */ -void schedule_ulsch(unsigned char Mod_id,u32 frame,unsigned char cooperation_flag,unsigned char subframe,unsigned char sched_subframe,unsigned int *nCCE); +void schedule_ulsch(module_id_t module_idP,frame_t frameP,unsigned char cooperation_flag,sub_frame_t subframe,unsigned char sched_subframe,unsigned int *nCCE); /** \brief ULSCH Scheduling per RNTI TDD config (config 1-6). @param Mod_id Instance ID of eNB @@ -947,7 +950,7 @@ void schedule_ulsch(unsigned char Mod_id,u32 frame,unsigned char cooperation_fla @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) @param nCCE Pointer to current nCCE count */ -void schedule_ulsch_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 frame, unsigned char subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb); +void schedule_ulsch_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb); /** \brief ULSCH Scheduling for CBA RNTI TDD config (config 1-6). @param Mod_id Instance ID of eNB @@ -956,7 +959,7 @@ void schedule_ulsch_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 frame, u @param sched_subframe Subframe number where PUSCH is transmitted (for DAI lookup) @param nCCE Pointer to current nCCE count */ -void schedule_ulsch_cba_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 frame, unsigned char subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb); +void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, sub_frame_t subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *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 @@ -966,7 +969,7 @@ void schedule_ulsch_cba_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 fram @param RA_scheduled RA was scheduled in this subframe @param mbsfn_flag Indicates that this subframe is for MCH/MCCH */ -void fill_DLSCH_dci(u8 Mod_id,u32 frame,u8 subframe,u32 rballoc,u8 RA_scheduled,int mbsfn_flag); +void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,u32 rballoc,u8 RA_scheduled,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 @@ -976,45 +979,45 @@ void fill_DLSCH_dci(u8 Mod_id,u32 frame,u8 subframe,u32 rballoc,u8 RA_scheduled, @param nCCE_used Number of CCE used by SI/RA @param mbsfn_flag Indicates that MCH/MCCH is in this subframe */ -void schedule_ue_spec(u8 Mod_id,u32 frame,u8 subframe,u16 nb_rb_used0,unsigned int *nCCE_used,int mbsfn_flag); +void schedule_ue_spec(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,u16 nb_rb_used0,unsigned int *nCCE_used,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 */ -s8 get_Po_NOMINAL_PUSCH(u8 Mod_id); +s8 get_Po_NOMINAL_PUSCH(module_id_t module_idP); /** \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 */ -s8 get_DELTA_PREAMBLE(u8 Mod_id); +s8 get_DELTA_PREAMBLE(module_id_t module_idP); /** \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 @returns deltaP_rampup */ -s8 get_deltaP_rampup(u8 Mod_id); +s8 get_deltaP_rampup(module_id_t module_idP); //main.c -void chbch_phy_sync_success(u8 Mod_id,u32 frame,u8 eNB_index); +void chbch_phy_sync_success(module_id_t module_idP,frame_t frameP,u8 eNB_index); -void mrbch_phy_sync_failure(u8 Mod_id, u32 frame,u8 free_eNB_index); +void mrbch_phy_sync_failure(module_id_t module_idP, frame_t frameP,u8 free_eNB_index); int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active); -char layer2_init_UE(u8 Mod_id); +char layer2_init_UE(module_id_t module_idP); -char layer2_init_eNB(u8 Mod_id, u8 Free_ch_index); +char layer2_init_eNB(module_id_t module_idP, u8 Free_ch_index); -void mac_switch_node_function(u8 Mod_id); +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(u8 Mod_id,u32 frame, u16 eNB_index); +void mac_UE_out_of_sync_ind(module_id_t module_idP,frame_t frameP, u16 eNB_index); // eNB functions @@ -1029,13 +1032,13 @@ void mac_UE_out_of_sync_ind(u8 Mod_id,u32 frame, u16 eNB_index); */ -void dlsch_scheduler_pre_processor (unsigned char Mod_id, - u32 frame, - unsigned char subframe, - u8 *dl_pow_off, - u16 *pre_nb_available_rbs, - int N_RBGS, - unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX]); +void dlsch_scheduler_pre_processor (module_id_t module_idP, + frame_t frameP, + sub_frame_t subframe, + u8 *dl_pow_off, + u16 *pre_nb_available_rbs, + int N_RBGS, + unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_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. The resultant DCI_PDU is @@ -1046,7 +1049,7 @@ can be scheduled. @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(u8 Mod_id, u8 cooperation_flag, u32 frame, u8 subframe);//, int calibration_flag); +void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, u8 cooperation_flag, frame_t frameP, sub_frame_t subframe);//, int calibration_flag); /* \brief Function to retrieve result of scheduling (DCI) in current subframe. Can be called an arbitrary numeber of times after eNB_dlsch_ulsch_scheduler in a given subframe. @@ -1054,14 +1057,14 @@ in a given subframe. @param subframe Index of current subframe @returns Pointer to generated DCI for subframe */ -DCI_PDU *get_dci_sdu(u8 Mod_id,u32 frame,u8 subframe); +DCI_PDU *get_dci_sdu(module_id_t module_idP,frame_t frameP,sub_frame_t subframe); /* \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 */ -void initiate_ra_proc(u8 Mod_id,u32 frame, u16 preamble_index,s16 timing_offset,u8 sect_id,u8 subframe,u8 f_id); +void initiate_ra_proc(module_id_t module_idP,frame_t frameP, u16 preamble_index,s16 timing_offset,u8 sect_id,sub_frame_t subframe,u8 f_id); /* \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 @@ -1069,39 +1072,40 @@ void initiate_ra_proc(u8 Mod_id,u32 frame, u16 preamble_index,s16 timing_offset, @param N_RB_UL Number of UL resource blocks @returns t_CRNTI */ -u16 fill_rar(u8 Mod_id,u32 frame, - u8 *dlsch_buffer, - u16 N_RB_UL, - u8 input_buffer_length); +u16 fill_rar(module_id_t module_idP, + frame_t frameP, + u8 *dlsch_buffer, + u16 N_RB_UL, + u8 input_buffer_length); /* \brief This function indicates the end of RA procedure and provides the l3msg received on ULSCH. @param Mod_id Instance ID of eNB @param rnti RNTI of UE transmitting l3msg @param l3msg Pointer to received l3msg */ -void terminate_ra_proc(u8 Mod_id,u32 frame,u16 rnti, u8 *l3msg, u16 l3msg_len); +void terminate_ra_proc(module_id_t module_idP,frame_t frameP, rnti_t rnti, u8 *l3msg, u16 l3msg_len); /* \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(u8 Mod_id,u32 frame, u16 preamble_index); +void cancel_ra_proc(module_id_t module_idP,frame_t frameP, u16 preamble_index); /* \brief Function to indicate a received SDU on ULSCH. @param Mod_id Instance ID of eNB @param rnti RNTI of UE transmitting the SR @param sdu Pointer to received SDU */ -void rx_sdu(u8 Mod_id,u32 frame,u16 rnti, u8 *sdu, u16 sdu_len); +void rx_sdu(module_id_t module_idP, frame_t frameP, rnti_t rnti, u8 *sdu, u16 sdu_len); /* \brief Function to indicate a scheduled schduling request (SR) was received by eNB. @param Mod_id Instance ID of eNB @param rnti RNTI of UE transmitting the SR @param subframe Index of subframe where SR was received */ -void SR_indication(u8 Mod_id,u32 frame,u16 rnti, u8 subframe); +void SR_indication(module_id_t module_idP,frame_t frameP,rnti_t rnti, sub_frame_t subframe); -u8 *get_dlsch_sdu(u8 Mod_id,u32 frame,u16 rnti,u8 TBindex); +u8 *get_dlsch_sdu(module_id_t module_idP,frame_t frameP,rnti_t rnti,u8 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 @@ -1114,41 +1118,41 @@ MCH_PDU *get_mch_sdu(uint8_t Mod_id,uint32_t frame,uint32_t subframe); //added for ALU icic purpose -u32 Get_Cell_SBMap(u8 Mod_id); -void UpdateSBnumber(unsigned char Mod_id); +u32 Get_Cell_SBMap(module_id_t module_idP); +void UpdateSBnumber(module_id_t module_idP); //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); -s8 find_UE_id(u8 Mod_id,u16 rnti) ; -u16 find_UE_RNTI(u8 Mod_id, u8 UE_id); -s8 find_active_UEs(u8 Mod_id); -u8 is_UE_active(unsigned char Mod_id, unsigned char UE_id ); -u16 find_ulgranted_UEs(u8 Mod_id); -u16 find_dlgranted_UEs(u8 Mod_id); -u8 process_ue_cqi (u8 Mod_id, u8 UE_id); +void ue_mac_reset (module_id_t module_idP,u8 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, module_id_t ue_mod_idP, sub_frame_t subframe,UE_ULSCH_STATUS status); +void add_ue_dlsch_info (module_id_t module_idP, module_id_t ue_mod_idP, sub_frame_t subframe,UE_DLSCH_STATUS status); +module_id_t find_UE_id (module_id_t module_idP, rnti_t rnti) ; +u16 find_UE_RNTI (module_id_t module_idP, module_id_t ue_mod_idP); +u8 find_active_UEs (module_id_t module_idP); +u8 is_UE_active (module_id_t module_idP, module_id_t ue_mod_idP ); +u8 find_ulgranted_UEs(module_id_t module_idP); +u8 find_dlgranted_UEs(module_id_t module_idP); +u8 process_ue_cqi (module_id_t module_idP, module_id_t ue_mod_idP); -s8 find_active_UEs_with_traffic(unsigned char Mod_id); +s8 find_active_UEs_with_traffic(module_id_t module_idP); -u8 find_num_active_UEs_in_cbagroup(unsigned char Mod_id, unsigned char group_id); -u8 UE_is_to_be_scheduled(u8 Mod_id,u8 UE_id); +u8 find_num_active_UEs_in_cbagroup(module_id_t module_idP, unsigned char group_id); +u8 UE_is_to_be_scheduled(module_id_t module_idP,u8 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 */ -u8 schedule_next_ulue(u8 Mod_id, u8 UE_id,u8 subframe); +module_id_t schedule_next_ulue(module_id_t module_idP, module_id_t ue_mod_idP,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 */ -u8 schedule_next_dlue(u8 Mod_id, u8 subframe); +module_id_t schedule_next_dlue(module_id_t module_idP, 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 @@ -1156,14 +1160,14 @@ u8 schedule_next_dlue(u8 Mod_id, u8 subframe); @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). */ -u32 allocate_prbs(u8 UE_id,u8 nb_rb, u32 *rballoc); +u32 allocate_prbs(module_id_t ue_mod_idP,u8 nb_rb, u32 *rballoc); -/* \fn u32 req_new_ulsch(u8 Mod_id) +/* \fn u32 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 */ -u32 req_new_ulsch(u8 Mod_id); +u32 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 @@ -1172,17 +1176,17 @@ u32 req_new_ulsch(u8 Mod_id); @param subframe subframe number @returns 0 for no SR, 1 for SR */ -u32 ue_get_SR(u8 Mod_id, u32 frame, u8 eNB_id,u16 rnti,u8 subframe); +u32 ue_get_SR(module_id_t module_idP, frame_t frameP, u8 eNB_id,rnti_t rnti,sub_frame_t subframe); -u8 get_ue_weight(u8 Mod_id, u8 UE_id); +u8 get_ue_weight(module_id_t module_idP, module_id_t ue_mod_idP); // UE functions -void mac_out_of_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index); +void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, u16 CH_index); -void ue_decode_si(u8 Mod_id, u32 frame, u8 CH_index, void *pdu, u16 len); +void ue_decode_si(module_id_t module_idP, frame_t frame, u8 CH_index, void *pdu, u16 len); -void ue_send_sdu(u8 Mod_id, u32 frame, u8 *sdu,u16 sdu_len,u8 CH_index); +void ue_send_sdu(module_id_t module_idP, frame_t frame, u8 *sdu,u16 sdu_len,u8 CH_index); #ifdef Rel10 @@ -1194,7 +1198,7 @@ void ue_send_sdu(u8 Mod_id, u32 frame, u8 *sdu,u16 sdu_len,u8 CH_index); @param eNB_index Index of attached eNB @param sync_area the index of MBSFN sync area */ -void ue_send_mch_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index,u8 sync_area) ; +void ue_send_mch_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eNB_index,u8 sync_area) ; /*\brief Function to check if UE PHY needs to decode MCH for MAC. @param Mod_id Index of protocol instance @@ -1204,7 +1208,7 @@ void ue_send_mch_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index,u8 syn @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,uint32_t frame,uint32_t subframe, uint8_t eNB_index, uint8_t *sync_area, uint8_t *mcch_active); +int ue_query_mch(uint8_t Mod_id,uint32_t frame,sub_frame_t subframe, uint8_t eNB_index, uint8_t *sync_area, uint8_t *mcch_active); #endif @@ -1215,14 +1219,14 @@ int ue_query_mch(uint8_t Mod_id,uint32_t frame,uint32_t subframe, uint8_t eNB_in @param subframe subframe number @returns 0 for no SR, 1 for SR */ -void ue_get_sdu(u8 Mod_id, u32 frame, u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen,u8 *access_mode); +void ue_get_sdu(module_id_t module_idP, frame_t frameP, sub_frame_t subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen,u8 *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 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(u8 Mod_id,u32 frame,u8 new_Msg3,u8 subframe); +PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,frame_t frameP,u8 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 @@ -1232,7 +1236,7 @@ PRACH_RESOURCES_t *ue_get_rach(u8 Mod_id,u32 frame,u8 new_Msg3,u8 subframe); random-access procedure @returns timing advance or 0xffff if preamble doesn't match */ -u16 ue_process_rar(u8 Mod_id,u32 frame,u8 *dlsch_buffer,u16 *t_crnti,u8 preamble_index); +u16 ue_process_rar(module_id_t module_idP, frame_t frameP,u8 *dlsch_buffer,u16 *t_crnti,u8 preamble_index); /* \brief Generate header for UL-SCH. This function parses the desired control elements and sdus and generates the header as described @@ -1252,16 +1256,16 @@ in the ULSCH buffer. @returns Number of bytes used for header */ unsigned char generate_ulsch_header(u8 *mac_header, - u8 num_sdus, - u8 short_padding, - u16 *sdu_lengths, - u8 *sdu_lcids, - POWER_HEADROOM_CMD *power_headroom, - u16 *crnti, - BSR_SHORT *truncated_bsr, - BSR_SHORT *short_bsr, - BSR_LONG *long_bsr, - unsigned short post_padding); + u8 num_sdus, + u8 short_padding, + u16 *sdu_lengths, + u8 *sdu_lcids, + POWER_HEADROOM_CMD *power_headroom, + u16 *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 @@ -1275,30 +1279,30 @@ in the ULSCH buffer. @returns Pointer to payload following header */ u8 *parse_ulsch_header(u8 *mac_header, - u8 *num_ce, - u8 *num_sdu, - u8 *rx_ces, - u8 *rx_lcids, - u16 *rx_lengths, - u16 tx_lenght); + u8 *num_ce, + u8 *num_sdu, + u8 *rx_ces, + u8 *rx_lcids, + u16 *rx_lengths, + u16 tx_lenght); int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_active, u8 HO_active); int mac_init(void); -s8 add_new_ue(u8 Mod_id, u16 rnti); -s8 mac_remove_ue(u8 Mod_id, u8 UE_id); +s8 add_new_ue(module_id_t module_idP, rnti_t rnti); +s8 mac_remove_ue(module_id_t enb_mod_idP, module_id_t ue_mod_idP); -/*! \fn UE_L2_state_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t direction,u8 eNB_index) +/*! \fn UE_L2_state_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframe, lte_subframe_t direction,u8 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] Mod_id instance of the UE -\param[in] subframe the subframe number -\param[in] direction subframe direction -\param[in] eNB_index instance of eNB +\param[in] module_idP instance of the UE +\param[in] subframe t the 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(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t direction,u8 eNB_index); +UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframe, lte_subframe_t direction,u8 eNB_index); -/*! \fn int use_cba_access(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index); +/*! \fn int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, u8 eNB_index); \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 @@ -1306,46 +1310,46 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire \param[in] eNB_index instance of eNB \param[out] access(1) or postpone (0) */ -int use_cba_access(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index); +int use_cba_access(module_id_t module_idP,frame_t frameP,sub_frame_t subframe, u8 eNB_index); -/*! \fn int get_bsr_lcgid (u8 Mod_id); +/*! \fn int get_bsr_lcgid (module_id_t module_idP); \brief determine the lcgid for the bsr \param[in] Mod_id instance of the UE \param[out] lcgid */ -int get_bsr_lcgid (u8 Mod_id); +int get_bsr_lcgid (module_id_t module_idP); -/*! \fn u8 get_bsr_len (u8 Mod_id, u16 bufflen); +/*! \fn u8 get_bsr_len (module_id_t module_idP, u16 bufflen); \brief determine whether the bsr is short or long assuming that the MAC pdu is built \param[in] Mod_id instance of the UE \param[in] bufflen size of phy transport block \param[out] bsr_len size of bsr control element */ -u8 get_bsr_len (u8 Mod_id, u16 buflen); +u8 get_bsr_len (module_id_t module_idP, u16 buflen); -/*! \fn BSR_SHORT * get_bsr_short(u8 Mod_id, u8 bsr_len) +/*! \fn BSR_SHORT * get_bsr_short(module_id_t module_idP, u8 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(u8 Mod_id, u8 bsr_len); +BSR_SHORT *get_bsr_short(module_id_t module_idP, u8 bsr_len); -/*! \fn BSR_LONG * get_bsr_long(u8 Mod_id, u8 bsr_len) +/*! \fn BSR_LONG * get_bsr_long(module_id_t module_idP, u8 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(u8 Mod_id, u8 bsr_len); +BSR_LONG * get_bsr_long(module_id_t module_idP, u8 bsr_len); -/*! \fn int update_bsr(u8 Mod_id, u32 frame, u8 lcid) +/*! \fn int update_bsr(module_id_t module_idP, frame_t frameP, u8 lcid) \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 \param[in] lcid logical channel identifier */ -int update_bsr(u8 Mod_id, u32 frame, u8 lcid, u8 lcgid); +int update_bsr(module_id_t module_idP, frame_t frameP, u8 lcid, u8 lcgid); /*! \fn locate (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. @@ -1399,25 +1403,25 @@ int get_sf_prohibitPHR_Timer(u8 prohibitPHR_Timer); */ int get_db_dl_PathlossChange(u8 dl_PathlossChange); -/*! \fn u8 get_phr_mapping (u8 Mod_id, u8 eNB_index) +/*! \fn u8 get_phr_mapping (module_id_t module_idP, u8 eNB_index) \brief get phr mapping as described in 36.313 \param[in] Mod_id index of eNB \return phr mapping */ -u8 get_phr_mapping (u8 Mod_id, u8 eNB_index); +u8 get_phr_mapping (module_id_t module_idP, u8 eNB_index); -/*! \fn void update_phr (u8 Mod_id) +/*! \fn void update_phr (module_id_t module_idP) \brief update/reset the phr timers \param[in] Mod_id index of eNB \return void */ -void update_phr (u8 Mod_id); +void update_phr (module_id_t module_idP); /*! \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(u8 Mod_id,u32 frame,u8 eNB_id); +void Msg3_tx(module_id_t module_idP,frame_t frameP,u8 eNB_id); /*! \brief Function to indicate the transmission of msg1/rach @@ -1425,12 +1429,12 @@ void Msg3_tx(u8 Mod_id,u32 frame,u8 eNB_id); \param[in] eNB_id Index of eNB */ -void Msg1_tx(u8 Mod_id,u32 frame, u8 eNB_id); +void Msg1_tx(module_id_t module_idP,frame_t frameP, u8 eNB_id); -void dl_phy_sync_success(unsigned char Mod_id, - u32 frame, - unsigned char eNB_index, - u8 first_sync); +void dl_phy_sync_success(module_id_t module_idP, + frame_t frameP, + unsigned char eNB_index, + u8 first_sync); int dump_eNB_l2_stats(char *buffer, int length); diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index b911d4d6fa871bc9048d03dd41308b817c0d2ab6..1778fea3c0f457b5f4801fd827c48c7fe2b6325c 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -25,7 +25,7 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file eNB_scheduler.c * \brief procedures related to UE * \author Raymond Knopp, Navid Nikaein @@ -73,84 +73,84 @@ #ifndef USER_MODE #define msg debug_msg #endif -*/ + */ extern inline unsigned int taus(void); void init_ue_sched_info(void){ - int i,j; + module_id_t i,j; for (i=0;i<NUMBER_OF_eNB_MAX;i++){ - for (j=0;j<NUMBER_OF_UE_MAX;j++){ - // init DL - eNB_dlsch_info[i][j].weight = 0; - eNB_dlsch_info[i][j].subframe = 0; - eNB_dlsch_info[i][j].serving_num = 0; - eNB_dlsch_info[i][j].status = S_DL_NONE; - // init UL - eNB_ulsch_info[i][j].subframe = 0; - eNB_ulsch_info[i][j].serving_num = 0; - eNB_ulsch_info[i][j].status = S_UL_NONE; - } + for (j=0;j<NUMBER_OF_UE_MAX;j++){ + // init DL + eNB_dlsch_info[i][j].weight = 0; + eNB_dlsch_info[i][j].subframe = 0; + eNB_dlsch_info[i][j].serving_num = 0; + eNB_dlsch_info[i][j].status = S_DL_NONE; + // init UL + eNB_ulsch_info[i][j].subframe = 0; + eNB_ulsch_info[i][j].serving_num = 0; + eNB_ulsch_info[i][j].status = S_UL_NONE; + } } } -void add_ue_ulsch_info(unsigned char Mod_id, unsigned char UE_id, unsigned char subframe, UE_ULSCH_STATUS status){ +void add_ue_ulsch_info(module_id_t module_idP, module_id_t ue_mod_idP, sub_frame_t subframeP, UE_ULSCH_STATUS status){ - eNB_ulsch_info[Mod_id][UE_id].rnti = find_UE_RNTI(Mod_id,UE_id); - eNB_ulsch_info[Mod_id][UE_id].subframe = subframe; - eNB_ulsch_info[Mod_id][UE_id].status = status; + eNB_ulsch_info[module_idP][ue_mod_idP].rnti = find_UE_RNTI(module_idP,ue_mod_idP); + eNB_ulsch_info[module_idP][ue_mod_idP].subframe = subframeP; + eNB_ulsch_info[module_idP][ue_mod_idP].status = status; - eNB_ulsch_info[Mod_id][UE_id].serving_num++; + eNB_ulsch_info[module_idP][ue_mod_idP].serving_num++; } -void add_ue_dlsch_info(unsigned char Mod_id, unsigned char UE_id, unsigned char subframe, UE_DLSCH_STATUS status){ +void add_ue_dlsch_info(module_id_t module_idP, module_id_t ue_mod_idP, sub_frame_t subframeP, UE_DLSCH_STATUS status){ - eNB_dlsch_info[Mod_id][UE_id].rnti = find_UE_RNTI(Mod_id,UE_id); - // eNB_dlsch_info[Mod_id][UE_id].weight = weight; - eNB_dlsch_info[Mod_id][UE_id].subframe = subframe; - eNB_dlsch_info[Mod_id][UE_id].status = status; + eNB_dlsch_info[module_idP][ue_mod_idP].rnti = find_UE_RNTI(module_idP,ue_mod_idP); + // eNB_dlsch_info[module_idP][ue_mod_idP].weight = weight; + eNB_dlsch_info[module_idP][ue_mod_idP].subframe = subframeP; + eNB_dlsch_info[module_idP][ue_mod_idP].status = status; - eNB_dlsch_info[Mod_id][UE_id].serving_num++; + eNB_dlsch_info[module_idP][ue_mod_idP].serving_num++; } -unsigned char get_ue_weight(unsigned char Mod_id, unsigned char UE_id){ +unsigned char get_ue_weight(module_id_t module_idP, module_id_t ue_mod_idP){ - return(eNB_dlsch_info[Mod_id][UE_id].weight); + return(eNB_dlsch_info[module_idP][ue_mod_idP].weight); } // return is rnti ??? -unsigned char schedule_next_ulue(unsigned char Mod_id, unsigned char UE_id, unsigned char subframe){ +module_id_t schedule_next_ulue(module_id_t module_idP, module_id_t ue_mod_idP, sub_frame_t subframeP){ - unsigned char next_ue; + module_id_t next_ue; // first phase: scheduling for ACK - switch (subframe) { - // scheduling for subframe 2: for scheduled user during subframe 5 and 6 + switch (subframeP) { + // scheduling for subframeP 2: for scheduled user during subframeP 5 and 6 case 8: - if ((eNB_dlsch_info[Mod_id][UE_id].status == S_DL_SCHEDULED) && - (eNB_dlsch_info[Mod_id][UE_id].subframe == 5 || eNB_dlsch_info[Mod_id][UE_id].subframe == 6)){ - // set the downlink status - eNB_dlsch_info[Mod_id][UE_id].status = S_DL_BUFFERED; - return UE_id; + if ((eNB_dlsch_info[module_idP][ue_mod_idP].status == S_DL_SCHEDULED) && + (eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 5 || eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 6)){ + // set the downlink status + eNB_dlsch_info[module_idP][ue_mod_idP].status = S_DL_BUFFERED; + return ue_mod_idP; } break; - // scheduling for subframe 3: for scheduled user during subframe 7 and 8 + // scheduling for subframeP 3: for scheduled user during subframeP 7 and 8 case 9: - if ((eNB_dlsch_info[Mod_id][UE_id].status == S_DL_SCHEDULED) && - (eNB_dlsch_info[Mod_id][UE_id].subframe == 7 || eNB_dlsch_info[Mod_id][UE_id].subframe == 8)){ - eNB_dlsch_info[Mod_id][UE_id].status = S_DL_BUFFERED; - return UE_id; + if ((eNB_dlsch_info[module_idP][ue_mod_idP].status == S_DL_SCHEDULED) && + (eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 7 || eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 8)){ + eNB_dlsch_info[module_idP][ue_mod_idP].status = S_DL_BUFFERED; + return ue_mod_idP; } break; - // scheduling UL subframe 4: for scheduled user during subframe 9 and 0 + // scheduling UL subframeP 4: for scheduled user during subframeP 9 and 0 case 0 : - if ((eNB_dlsch_info[Mod_id][UE_id].status == S_DL_SCHEDULED) && - (eNB_dlsch_info[Mod_id][UE_id].subframe == 9 || eNB_dlsch_info[Mod_id][UE_id].subframe == 0)){ - eNB_dlsch_info[Mod_id][UE_id].status = S_DL_BUFFERED; - return UE_id; + if ((eNB_dlsch_info[module_idP][ue_mod_idP].status == S_DL_SCHEDULED) && + (eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 9 || eNB_dlsch_info[module_idP][ue_mod_idP].subframe == 0)){ + eNB_dlsch_info[module_idP][ue_mod_idP].status = S_DL_BUFFERED; + return ue_mod_idP; } break; default: @@ -160,82 +160,82 @@ unsigned char schedule_next_ulue(unsigned char Mod_id, unsigned char UE_id, unsi // second phase for (next_ue=0; next_ue <NUMBER_OF_UE_MAX; next_ue++ ){ - if (eNB_ulsch_info[Mod_id][next_ue].status == S_UL_WAITING ) - return next_ue; - else if (eNB_ulsch_info[Mod_id][next_ue].status == S_UL_SCHEDULED){ - eNB_ulsch_info[Mod_id][next_ue].status = S_UL_BUFFERED; - } + if (eNB_ulsch_info[module_idP][next_ue].status == S_UL_WAITING ) + return next_ue; + else if (eNB_ulsch_info[module_idP][next_ue].status == S_UL_SCHEDULED){ + eNB_ulsch_info[module_idP][next_ue].status = S_UL_BUFFERED; + } } for (next_ue=0; next_ue <NUMBER_OF_UE_MAX; next_ue++ ){ - if (eNB_ulsch_info[Mod_id][next_ue].status != S_UL_NONE )// do this just for active UEs - eNB_ulsch_info[Mod_id][next_ue].status = S_UL_WAITING; + if (eNB_ulsch_info[module_idP][next_ue].status != S_UL_NONE )// do this just for active UEs + eNB_ulsch_info[module_idP][next_ue].status = S_UL_WAITING; } next_ue = 0; return next_ue; } -unsigned char schedule_next_dlue(unsigned char Mod_id, unsigned char subframe){ +module_id_t schedule_next_dlue(module_id_t module_idP, sub_frame_t subframeP){ - unsigned char next_ue; + module_id_t next_ue; - for (next_ue=0; next_ue <NUMBER_OF_UE_MAX; next_ue++ ){ - if (eNB_dlsch_info[Mod_id][next_ue].status == S_DL_WAITING) - return next_ue; + for (next_ue=0; next_ue < NUMBER_OF_UE_MAX; next_ue++ ){ + if (eNB_dlsch_info[module_idP][next_ue].status == S_DL_WAITING) + return next_ue; } for (next_ue=0; next_ue <NUMBER_OF_UE_MAX; next_ue++ ) - if (eNB_dlsch_info[Mod_id][next_ue].status == S_DL_BUFFERED) { - eNB_dlsch_info[Mod_id][next_ue].status = S_DL_WAITING; + if (eNB_dlsch_info[module_idP][next_ue].status == S_DL_BUFFERED) { + eNB_dlsch_info[module_idP][next_ue].status = S_DL_WAITING; } // next_ue = -1; - return (-1);//next_ue; + return (module_id_t)(-1);//next_ue; } -void initiate_ra_proc(u8 Mod_id, u32 frame, u16 preamble_index,s16 timing_offset,u8 sect_id,u8 subframe,u8 f_id) { +void initiate_ra_proc(module_id_t module_idP, frame_t frameP, u16 preamble_index,s16 timing_offset,u8 sect_id,sub_frame_t subframeP,u8 f_id) { u8 i; - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Initiating RA procedure for preamble index %d\n",Mod_id,frame,preamble_index); + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Initiating RA procedure for preamble index %d\n",module_idP,frameP,preamble_index); for (i=0;i<NB_RA_PROC_MAX;i++) { - if (eNB_mac_inst[Mod_id].RA_template[i].RA_active==0) { - eNB_mac_inst[Mod_id].RA_template[i].RA_active=1; - eNB_mac_inst[Mod_id].RA_template[i].generate_rar=1; - eNB_mac_inst[Mod_id].RA_template[i].generate_Msg4=0; - eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4=0; - eNB_mac_inst[Mod_id].RA_template[i].timing_offset=timing_offset; - // Put in random rnti (to be replaced with proper procedure!!) - eNB_mac_inst[Mod_id].RA_template[i].rnti = taus(); - eNB_mac_inst[Mod_id].RA_template[i].RA_rnti = 1+subframe+(10*f_id); - eNB_mac_inst[Mod_id].RA_template[i].preamble_index = preamble_index; - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n", - Mod_id,frame,i,eNB_mac_inst[Mod_id].RA_template[i].rnti, - eNB_mac_inst[Mod_id].RA_template[i].RA_active); - - return; - } + if (eNB_mac_inst[module_idP].RA_template[i].RA_active==0) { + eNB_mac_inst[module_idP].RA_template[i].RA_active=1; + eNB_mac_inst[module_idP].RA_template[i].generate_rar=1; + eNB_mac_inst[module_idP].RA_template[i].generate_Msg4=0; + eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4=0; + eNB_mac_inst[module_idP].RA_template[i].timing_offset=timing_offset; + // Put in random rnti (to be replaced with proper procedure!!) + eNB_mac_inst[module_idP].RA_template[i].rnti = taus(); + eNB_mac_inst[module_idP].RA_template[i].RA_rnti = 1+subframeP+(10*f_id); + eNB_mac_inst[module_idP].RA_template[i].preamble_index = preamble_index; + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Activating RAR generation for process %d, rnti %x, RA_active %d\n", + module_idP,frameP,i,eNB_mac_inst[module_idP].RA_template[i].rnti, + eNB_mac_inst[module_idP].RA_template[i].RA_active); + + return; + } } } -void cancel_ra_proc(u8 Mod_id, u32 frame, u16 rnti) { +void cancel_ra_proc(module_id_t module_idP, frame_t frameP, rnti_t rnti) { unsigned char i; - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Cancelling RA procedure for UE rnti %x\n",Mod_id,frame,rnti); + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Cancelling RA procedure for UE rnti %x\n",module_idP,frameP,rnti); for (i=0;i<NB_RA_PROC_MAX;i++) { - if (rnti == eNB_mac_inst[Mod_id].RA_template[i].rnti) { - eNB_mac_inst[Mod_id].RA_template[i].RA_active=0; - eNB_mac_inst[Mod_id].RA_template[i].generate_rar=0; - eNB_mac_inst[Mod_id].RA_template[i].generate_Msg4=0; - eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4=0; - eNB_mac_inst[Mod_id].RA_template[i].timing_offset=0; - eNB_mac_inst[Mod_id].RA_template[i].RRC_timer=20; - eNB_mac_inst[Mod_id].RA_template[i].rnti = 0; - } + if (rnti == eNB_mac_inst[module_idP].RA_template[i].rnti) { + eNB_mac_inst[module_idP].RA_template[i].RA_active=0; + eNB_mac_inst[module_idP].RA_template[i].generate_rar=0; + eNB_mac_inst[module_idP].RA_template[i].generate_Msg4=0; + eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4=0; + eNB_mac_inst[module_idP].RA_template[i].timing_offset=0; + eNB_mac_inst[module_idP].RA_template[i].RRC_timer=20; + eNB_mac_inst[module_idP].RA_template[i].rnti = 0; + } } } -void terminate_ra_proc(u8 Mod_id,u32 frame,u16 rnti,unsigned char *msg3, u16 msg3_len) { +void terminate_ra_proc(module_id_t module_idP,frame_t frameP,rnti_t rnti,unsigned char *msg3, u16 msg3_len) { unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -243,216 +243,215 @@ void terminate_ra_proc(u8 Mod_id,u32 frame,u16 rnti,unsigned char *msg3, u16 msg s8 UE_id; LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, Received msg3 %x.%x.%x.%x.%x.%x, Terminating RA procedure for UE rnti %x\n", - Mod_id,frame, - msg3[3],msg3[4],msg3[5],msg3[6],msg3[7], msg3[8], rnti); + module_idP,frameP, + msg3[3],msg3[4],msg3[5],msg3[6],msg3[7], msg3[8], rnti); for (i=0;i<NB_RA_PROC_MAX;i++) { - LOG_D(MAC,"[RAPROC] Checking proc %d : rnti (%x, %x), active %d\n",i, - eNB_mac_inst[Mod_id].RA_template[i].rnti, rnti, - eNB_mac_inst[Mod_id].RA_template[i].RA_active); - if ((eNB_mac_inst[Mod_id].RA_template[i].rnti==rnti) && - (eNB_mac_inst[Mod_id].RA_template[i].RA_active==1)) { - - payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Received CCCH: length %d, offset %d\n", - Mod_id,frame,rx_lengths[0],payload_ptr-msg3); - if ((num_ce == 0) && (num_sdu==1) && (rx_lcids[0] == CCCH)) { // This is an RRCConnectionRequest/Restablishment - memcpy(&eNB_mac_inst[Mod_id].RA_template[i].cont_res_id[0],payload_ptr,6); - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Received CCCH: length %d, offset %d\n", - Mod_id,frame,rx_lengths[0],payload_ptr-msg3); - UE_id=add_new_ue(Mod_id,eNB_mac_inst[Mod_id].RA_template[i].rnti); - if (UE_id==-1) { - mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n"); - } - else { - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Added user with rnti %x => UE %d\n", - Mod_id,frame,eNB_mac_inst[Mod_id].RA_template[i].rnti,UE_id); - } - - if (Is_rrc_registered == 1) - mac_rrc_data_ind(Mod_id,frame,CCCH,(u8 *)payload_ptr,rx_lengths[0],1,Mod_id,0); - // add_user. This is needed to have the rnti for configuring UE (PHY). The UE is removed if RRC - // doesn't provide a CCCH SDU - - } - else if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest - // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); - } - - eNB_mac_inst[Mod_id].RA_template[i].generate_Msg4 = 1; - eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4 = 0; - - return; - } // if process is active + LOG_D(MAC,"[RAPROC] Checking proc %d : rnti (%x, %x), active %d\n",i, + eNB_mac_inst[module_idP].RA_template[i].rnti, rnti, + eNB_mac_inst[module_idP].RA_template[i].RA_active); + if ((eNB_mac_inst[module_idP].RA_template[i].rnti==rnti) && + (eNB_mac_inst[module_idP].RA_template[i].RA_active==1)) { + + payload_ptr = parse_ulsch_header(msg3,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,msg3_len); + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Received CCCH: length %d, offset %d\n", + module_idP,frameP,rx_lengths[0],payload_ptr-msg3); + if ((num_ce == 0) && (num_sdu==1) && (rx_lcids[0] == CCCH)) { // This is an RRCConnectionRequest/Restablishment + memcpy(&eNB_mac_inst[module_idP].RA_template[i].cont_res_id[0],payload_ptr,6); + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d Received CCCH: length %d, offset %d\n", + module_idP,frameP,rx_lengths[0],payload_ptr-msg3); + UE_id=add_new_ue(module_idP,eNB_mac_inst[module_idP].RA_template[i].rnti); + if (UE_id==-1) { + mac_xface->macphy_exit("[MAC][eNB] Max user count reached\n"); + } + else { + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Added user with rnti %x => UE %d\n", + module_idP,frameP,eNB_mac_inst[module_idP].RA_template[i].rnti,UE_id); + } + + if (Is_rrc_registered == 1) + mac_rrc_data_ind(module_idP,frameP,CCCH,(u8 *)payload_ptr,rx_lengths[0],1,module_idP,0); + // add_user. This is needed to have the rnti for configuring UE (PHY). The UE is removed if RRC + // doesn't provide a CCCH SDU + + } + else if (num_ce >0) { // handle msg3 which is not RRCConnectionRequest + // process_ra_message(msg3,num_ce,rx_lcids,rx_ces); + } + + eNB_mac_inst[module_idP].RA_template[i].generate_Msg4 = 1; + eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4 = 0; + + return; + } // if process is active } // loop on RA processes } -DCI_PDU *get_dci_sdu(u8 Mod_id, u32 frame, u8 subframe) { +DCI_PDU *get_dci_sdu(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { - return(&eNB_mac_inst[Mod_id].DCI_pdu); + return(&eNB_mac_inst[module_idP].DCI_pdu); } -s8 find_UE_id(unsigned char Mod_id,u16 rnti) { +module_id_t find_UE_id(module_id_t module_idP, rnti_t rnti) { - unsigned char i; + module_id_t ue_mod_id; - for (i=0;i<NUMBER_OF_UE_MAX;i++) { - if (eNB_mac_inst[Mod_id].UE_template[i].rnti==rnti) { - return(i); - } + for (ue_mod_id=0;ue_mod_id<NUMBER_OF_UE_MAX;ue_mod_id++) { + if (eNB_mac_inst[module_idP].UE_template[ue_mod_id].rnti==rnti) { + return(ue_mod_id); + } } - return(-1); + return(module_id_t)(-1); } -u16 find_UE_RNTI(unsigned char Mod_id, unsigned char UE_id) { +u16 find_UE_RNTI(module_id_t module_idP, module_id_t ue_mod_idP) { - return (eNB_mac_inst[Mod_id].UE_template[UE_id].rnti); + return (eNB_mac_inst[module_idP].UE_template[ue_mod_idP].rnti); } -u8 is_UE_active(unsigned char Mod_id, unsigned char UE_id ){ - if (eNB_mac_inst[Mod_id].UE_template[UE_id].rnti !=0 ) +u8 is_UE_active(module_id_t module_idP, module_id_t ue_mod_idP ){ + if (eNB_mac_inst[module_idP].UE_template[ue_mod_idP].rnti !=0 ) return 1; else return 0 ; } -s8 find_active_UEs(unsigned char Mod_id){ +u8 find_active_UEs(module_id_t module_idP){ - unsigned char UE_id; - u16 rnti; - unsigned char nb_active_ue=0; + module_id_t ue_mod_id = 0; + rnti_t rnti = 0; + u8 nb_active_ue = 0; - for (UE_id=0;UE_id<NUMBER_OF_UE_MAX;UE_id++) { + for (ue_mod_id=0;ue_mod_id<NUMBER_OF_UE_MAX;ue_mod_id++) { - if (((rnti=eNB_mac_inst[Mod_id].UE_template[UE_id].rnti) !=0)&&(eNB_mac_inst[Mod_id].UE_template[UE_id].ul_active==1)){ + if (((rnti=eNB_mac_inst[module_idP].UE_template[ue_mod_id].rnti) !=0)&&(eNB_mac_inst[module_idP].UE_template[ue_mod_id].ul_active==1)){ - if (mac_xface->get_eNB_UE_stats(Mod_id,rnti) != NULL){ // check at the phy enb_ue state for this rnti - nb_active_ue++; - } - else { // this ue is removed at the phy => remove it at the mac as well - mac_remove_ue(Mod_id, UE_id); + if (mac_xface->get_eNB_UE_stats(module_idP,rnti) != NULL){ // check at the phy enb_ue state for this rnti + nb_active_ue++; + } + else { // this ue is removed at the phy => remove it at the mac as well + mac_remove_ue(module_idP, ue_mod_id); + } } - } } return(nb_active_ue); } // function for determining which active ue should be granted resources in uplink based on BSR+QoS -u16 find_ulgranted_UEs(unsigned char Mod_id){ +u8 find_ulgranted_UEs(module_id_t module_idP){ // all active users should be granted - return(find_active_UEs(Mod_id)); + return(find_active_UEs(module_idP)); } // function for determining which active ue should be granted resources in downlink based on CQI, SI, and BSR -u16 find_dlgranted_UEs(unsigned char Mod_id){ +u8 find_dlgranted_UEs(module_id_t module_idP){ // all active users should be granted - return(find_active_UEs(Mod_id)); + return(find_active_UEs(module_idP)); } // get aggregatiob form phy for a give UE -unsigned char process_ue_cqi (unsigned char Mod_id, unsigned char UE_id) { - +unsigned char process_ue_cqi (module_id_t module_idP, module_id_t ue_mod_idP) { unsigned char aggregation=2; // check the MCS and SNR and set the aggregation accordingly - return aggregation; } #ifdef CBA -u8 find_num_active_UEs_in_cbagroup(unsigned char Mod_id, unsigned char group_id){ +u8 find_num_active_UEs_in_cbagroup(module_id_t module_idP, unsigned char group_id){ - u8 UE_id; - u16 rnti; + module_id_t UE_id; + rnti_t rnti; unsigned char nb_ue_in_pusch=0; LTE_eNB_UE_stats* eNB_UE_stats; - - for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=eNB_mac_inst[Mod_id].num_active_cba_groups) { - - if (((rnti=eNB_mac_inst[Mod_id].UE_template[UE_id].rnti) !=0) && - (eNB_mac_inst[Mod_id].UE_template[UE_id].ul_active==1) && - (mac_get_rrc_status(Mod_id,1,UE_id) > RRC_CONNECTED)){ - // && (UE_is_to_be_scheduled(Mod_id,UE_id))) - // check at the phy enb_ue state for this rnti - if ((eNB_UE_stats= mac_xface->get_eNB_UE_stats(Mod_id,rnti)) != NULL){ - if ((eNB_UE_stats->mode == PUSCH) && (UE_is_to_be_scheduled(Mod_id,UE_id) == 0)){ - nb_ue_in_pusch++; - } + + for (UE_id=group_id;UE_id<NUMBER_OF_UE_MAX;UE_id+=eNB_mac_inst[module_idP].num_active_cba_groups) { + + if (((rnti=eNB_mac_inst[module_idP].UE_template[UE_id].rnti) !=0) && + (eNB_mac_inst[module_idP].UE_template[UE_id].ul_active==1) && + (mac_get_rrc_status(module_idP,1,UE_id) > RRC_CONNECTED)){ + // && (UE_is_to_be_scheduled(module_idP,UE_id))) + // check at the phy enb_ue state for this rnti + if ((eNB_UE_stats= mac_xface->get_eNB_UE_stats(module_idP,rnti)) != NULL){ + if ((eNB_UE_stats->mode == PUSCH) && (UE_is_to_be_scheduled(module_idP,UE_id) == 0)){ + nb_ue_in_pusch++; + } + } } - } } return(nb_ue_in_pusch); } #endif -s8 add_new_ue(unsigned char Mod_id, u16 rnti) { - int i,j; - - for (i=0;i<NUMBER_OF_UE_MAX;i++) { - if (eNB_mac_inst[Mod_id].UE_template[i].rnti==0) { - eNB_mac_inst[Mod_id].UE_template[i].rnti=rnti; - for (j=0;j<8;j++) { - eNB_mac_inst[Mod_id].UE_template[i].oldNDI[j]=0; - eNB_mac_inst[Mod_id].UE_template[i].oldNDI_UL[j]=0; +s8 add_new_ue(module_id_t enb_mod_idP, u16 rntiP) { + module_id_t ue_mod_id; + int j; + + for (ue_mod_id=0;ue_mod_id<NUMBER_OF_UE_MAX;ue_mod_id++) { + if (eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].rnti == 0) { + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].rnti = rntiP; + for (j=0;j<8;j++) { + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].oldNDI[j] = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].oldNDI_UL[j] = 0; + } + eNB_ulsch_info[enb_mod_idP][ue_mod_id].status = S_UL_WAITING; + eNB_dlsch_info[enb_mod_idP][ue_mod_id].status = S_UL_WAITING; + LOG_D(MAC,"[eNB] Add UE_id %d : rnti %x\n",ue_mod_id,eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].rnti); + return((s8)ue_mod_id); } - eNB_ulsch_info[Mod_id][i].status = S_UL_WAITING; - eNB_dlsch_info[Mod_id][i].status = S_UL_WAITING; - LOG_D(MAC,"[eNB] Add UE_id %d : rnti %x\n",i,eNB_mac_inst[Mod_id].UE_template[i].rnti); - return((s8)i); - } } return(-1); } -s8 mac_remove_ue(unsigned char Mod_id, unsigned char UE_id) { +s8 mac_remove_ue(module_id_t enb_mod_idP, module_id_t ue_mod_idP) { - LOG_I(MAC,"Removing UE %d (rnti %x)\n",UE_id,eNB_mac_inst[Mod_id].UE_template[UE_id].rnti); + LOG_I(MAC,"Removing UE %d (rnti %x)\n",ue_mod_idP,eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].rnti); // clear all remaining pending transmissions - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].bsr_info[LCGID0] = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].bsr_info[LCGID1] = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].bsr_info[LCGID2] = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].bsr_info[LCGID3] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_SR = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].rnti = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_active = 0; - eNB_ulsch_info[Mod_id][UE_id].rnti = 0; - eNB_ulsch_info[Mod_id][UE_id].status = S_UL_NONE; - eNB_dlsch_info[Mod_id][UE_id].rnti = 0; - eNB_dlsch_info[Mod_id][UE_id].status = S_DL_NONE; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].ul_SR = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].rnti = 0; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_idP].ul_active = 0; + eNB_ulsch_info[enb_mod_idP][ue_mod_idP].rnti = 0; + eNB_ulsch_info[enb_mod_idP][ue_mod_idP].status = S_UL_NONE; + eNB_dlsch_info[enb_mod_idP][ue_mod_idP].rnti = 0; + eNB_dlsch_info[enb_mod_idP][ue_mod_idP].status = S_DL_NONE; - rrc_eNB_free_UE_index(Mod_id,UE_id); + rrc_eNB_free_UE_index(enb_mod_idP,ue_mod_idP); return(1); } -unsigned char *get_dlsch_sdu(u8 Mod_id,u32 frame,u16 rnti,u8 TBindex) { +unsigned char *get_dlsch_sdu(module_id_t module_idP, frame_t frameP, rnti_t rntiP, u8 TBindex) { - unsigned char UE_id; + module_id_t ue_mod_id; - if (rnti==SI_RNTI) { - LOG_D(MAC,"[eNB %d] Frame %d Get DLSCH sdu for BCCH \n",Mod_id,frame); + if (rntiP==SI_RNTI) { + LOG_D(MAC,"[eNB %d] Frame %d Get DLSCH sdu for BCCH \n",module_idP,frameP); - return((unsigned char *)&eNB_mac_inst[Mod_id].BCCH_pdu.payload[0]); + return((unsigned char *)&eNB_mac_inst[module_idP].BCCH_pdu.payload[0]); } else { - UE_id = find_UE_id(Mod_id,rnti); - LOG_D(MAC,"[eNB %d] Frame %d Get DLSCH sdu for rnti %x => UE_id %d\n",Mod_id,frame,rnti,UE_id); + ue_mod_id = find_UE_id(module_idP,rntiP); + LOG_D(MAC,"[eNB %d] Frame %d Get DLSCH sdu for rnti %x => UE_id %d\n",module_idP,frameP,rntiP,ue_mod_id); - return((unsigned char *)&eNB_mac_inst[Mod_id].DLSCH_pdu[UE_id][TBindex].payload[0]); + return((unsigned char *)&eNB_mac_inst[module_idP].DLSCH_pdu[ue_mod_id][TBindex].payload[0]); } } unsigned char *parse_ulsch_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) { + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { unsigned char not_done=1,num_ces=0,num_sdus=0,lcid,num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; @@ -460,49 +459,49 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, while (not_done==1) { - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) - not_done = 0; - - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - if (lcid < EXTENDED_POWER_HEADROOM) { - if (not_done==0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length-(mac_header_ptr-mac_header)-ce_len; - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) - length -= rx_lengths[num_sdu_cnt]; - } - else { - if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT); - } - else { // F = 1 - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG); - } + if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) + not_done = 0; + + lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; + if (lcid < EXTENDED_POWER_HEADROOM) { + if (not_done==0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length-(mac_header_ptr-mac_header)-ce_len; + for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) + length -= rx_lengths[num_sdu_cnt]; + } + else { + if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; + mac_header_ptr += 2;//sizeof(SCH_SUBHEADER_SHORT); + } + else { // F = 1 + length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); + mac_header_ptr += 3;//sizeof(SCH_SUBHEADER_LONG); + } + } + LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %d)\n", + num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header); + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; } - LOG_D(MAC,"[eNB] sdu %d lcid %d tb_length %d length %d (offset now %d)\n", - num_sdus,lcid,tb_length, length,mac_header_ptr-mac_header); - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } - else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI - if (lcid == SHORT_PADDING) { - mac_header_ptr++; - } - else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr++; - if (lcid==LONG_BSR) - ce_len+=4; - else if (lcid==CRNTI) - ce_len+=2; - else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) - ce_len++; + else { // This is a control element subheader POWER_HEADROOM, BSR and CRNTI + if (lcid == SHORT_PADDING) { + mac_header_ptr++; + } + else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr++; + if (lcid==LONG_BSR) + ce_len+=4; + else if (lcid==CRNTI) + ce_len+=2; + else if ((lcid==POWER_HEADROOM) || (lcid==TRUNCATED_BSR)|| (lcid== SHORT_BSR)) + ce_len++; + } } - } } *num_ce = num_ces; *num_sdu = num_sdus; @@ -510,138 +509,142 @@ unsigned char *parse_ulsch_header(unsigned char *mac_header, return(mac_header_ptr); } -void SR_indication(u8 Mod_id,u32 frame, u16 rnti, u8 subframe) { +void SR_indication(module_id_t enb_mod_idP, frame_t frameP, rnti_t rntiP, sub_frame_t subframeP) { - u8 UE_id = find_UE_id(Mod_id,rnti); + s8 ue_mod_id = find_UE_id(enb_mod_idP, rntiP); - LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframe %d Signaling SR for UE %d \n",Mod_id,rnti,frame,subframe, UE_id); - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_SR = 1; - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_active = 1; + if (ue_mod_id >= 0) { + LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d \n",enb_mod_idP,rntiP,frameP,subframeP, ue_mod_id); + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].ul_SR = 1; + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].ul_active = 1; + } else { + AssertFatal(0, "find_UE_id(%u,rnti %d) not found", enb_mod_idP, rntiP); + } } -void rx_sdu(u8 Mod_id,u32 frame,u16 rnti,u8 *sdu, u16 sdu_len) { +void rx_sdu(module_id_t enb_mod_idP,frame_t frameP,rnti_t rntiP,u8 *sdu, u16 sdu_len) { - unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; - unsigned char rx_lcids[NB_RB_MAX]; + unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; + unsigned char rx_lcids[NB_RB_MAX]; unsigned short rx_lengths[NB_RB_MAX]; - unsigned char UE_id = find_UE_id(Mod_id,rnti); + module_id_t ue_mod_id = find_UE_id(enb_mod_idP,rntiP); int ii,j; for(ii=0; ii<NB_RB_MAX; ii++) rx_lengths[ii] = 0; - + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,1); - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].total_pdu_bytes_rx+=sdu_len; - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].total_num_pdus_rx+=1; + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].total_pdu_bytes_rx+=sdu_len; + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].total_num_pdus_rx+=1; - LOG_D(MAC,"[eNB %d] Received ULSCH sdu from PHY (rnti %x, UE_id %d), parsing header\n",Mod_id,rnti,UE_id); + LOG_D(MAC,"[eNB %d] Received ULSCH sdu from PHY (rnti %x, UE_id %d), parsing header\n",enb_mod_idP,rntiP,ue_mod_id); payload_ptr = parse_ulsch_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len); // control element for (i=0;i<num_ce;i++) { - switch (rx_ces[i]) { // implement and process BSR + CRNTI + - case POWER_HEADROOM: - eNB_mac_inst[Mod_id].UE_template[UE_id].phr_info = (payload_ptr[0] & 0x3f);// - PHR_MAPPING_OFFSET; - LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received PHR PH = %d (db)\n", rx_ces[i], eNB_mac_inst[Mod_id].UE_template[UE_id].phr_info); - payload_ptr+=sizeof(POWER_HEADROOM_CMD); - break; - case CRNTI: - LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received CRNTI %d \n", rx_ces[i], payload_ptr[0]); - payload_ptr+=1; - break; - case TRUNCATED_BSR: - case SHORT_BSR: { - u8 lcgid; - - lcgid = (payload_ptr[0] >> 6); - LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", + switch (rx_ces[i]) { // implement and process BSR + CRNTI + + case POWER_HEADROOM: + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].phr_info = (payload_ptr[0] & 0x3f);// - PHR_MAPPING_OFFSET; + LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received PHR PH = %d (db)\n", rx_ces[i], eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].phr_info); + payload_ptr+=sizeof(POWER_HEADROOM_CMD); + break; + case CRNTI: + LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received CRNTI %d \n", rx_ces[i], payload_ptr[0]); + payload_ptr+=1; + break; + case TRUNCATED_BSR: + case SHORT_BSR: { + u8 lcgid; + + lcgid = (payload_ptr[0] >> 6); + LOG_D(MAC, "[eNB] MAC CE_LCID %d : Received short BSR LCGID = %u bsr = %d\n", rx_ces[i], lcgid, payload_ptr[0] & 0x3f); - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); - payload_ptr += 1;//sizeof(SHORT_BSR); // fixme - } break; - case LONG_BSR: - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] = ((payload_ptr[0] & 0xFC) >> 2); - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] = - ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] = - ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F); - LOG_D(MAC, "[eNB] MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " - "%u LCGID2 = %u LCGID3 = %u\n", + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[lcgid] = (payload_ptr[0] & 0x3f); + payload_ptr += 1;//sizeof(SHORT_BSR); // fixme + } break; + case LONG_BSR: + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID0] = ((payload_ptr[0] & 0xFC) >> 2); + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID1] = + ((payload_ptr[0] & 0x03) << 4) | ((payload_ptr[1] & 0xF0) >> 4); + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID2] = + ((payload_ptr[1] & 0x0F) << 2) | ((payload_ptr[2] & 0xC0) >> 6); + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID3] = (payload_ptr[2] & 0x3F); + LOG_D(MAC, "[eNB] MAC CE_LCID %d: Received long BSR LCGID0 = %u LCGID1 = " + "%u LCGID2 = %u LCGID3 = %u\n", rx_ces[i], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]); - payload_ptr += 3;////sizeof(LONG_BSR); - break; - default: - LOG_E(MAC, "[eNB] Received unknown MAC header (0x%02x)\n", rx_ces[i]); - break; - } + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID0], + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID1], + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID2], + eNB_mac_inst[enb_mod_idP].UE_template[ue_mod_id].bsr_info[LCGID3]); + payload_ptr += 3;////sizeof(LONG_BSR); + break; + default: + LOG_E(MAC, "[eNB] Received unknown MAC header (0x%02x)\n", rx_ces[i]); + break; + } } for (i=0;i<num_sdu;i++) { - LOG_D(MAC,"SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]); - - if ((rx_lcids[i] == DCCH)||(rx_lcids[i] == DCCH1)) { - // if(eNB_mac_inst[Mod_id].Dcch_lchan[UE_id].Active==1){ + LOG_D(MAC,"SDU Number %d MAC Subheader SDU_LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]); + + if ((rx_lcids[i] == DCCH)||(rx_lcids[i] == DCCH1)) { + // if(eNB_mac_inst[module_idP].Dcch_lchan[UE_id].Active==1){ #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sdu)); - for (j=0;j<32;j++) - LOG_T(MAC,"%x ",payload_ptr[j]); - LOG_T(MAC,"\n"); + LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sdu)); + for (j=0;j<32;j++) + LOG_T(MAC,"%x ",payload_ptr[j]); + LOG_T(MAC,"\n"); #endif - // This check is just to make sure we didn't get a bogus SDU length, to be removed ... - if (rx_lengths[i]<CCCH_PAYLOAD_SIZE_MAX) { - LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d(%d) \n", - Mod_id,frame, rx_lengths[i], UE_id, rx_lcids[i], rx_lcids[i]+(UE_id*NB_RB_MAX)); - - mac_rlc_data_ind(Mod_id,frame,1,RLC_MBMS_NO, - rx_lcids[i]+(UE_id*NB_RB_MAX), - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL);//(unsigned int*)crc_status); - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].num_pdu_rx[rx_lcids[i]]+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; - - } - // } - } else if (rx_lcids[i] >= DTCH) { - // if(eNB_mac_inst[Mod_id].Dcch_lchan[UE_id].Active==1){ + // This check is just to make sure we didn't get a bogus SDU length, to be removed ... + if (rx_lengths[i]<CCCH_PAYLOAD_SIZE_MAX) { + LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DCCH, received %d bytes form UE %d on LCID %d(%d) \n", + enb_mod_idP,frameP, rx_lengths[i], ue_mod_id, rx_lcids[i], rx_lcids[i]); + + mac_rlc_data_ind(enb_mod_idP,ue_mod_id, frameP,1,RLC_MBMS_NO, + rx_lcids[i], + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL);//(unsigned int*)crc_status); + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].num_pdu_rx[rx_lcids[i]]+=1; + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; + + } + // } + } else if (rx_lcids[i] >= DTCH) { + // if(eNB_mac_inst[module_idP].Dcch_lchan[UE_id].Active==1){ #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sdu)); - - for (j=0;j<32;j++) - LOG_T(MAC,"%x ",payload_ptr[j]); - LOG_T(MAC,"\n"); + LOG_T(MAC,"offset: %d\n",(unsigned char)((unsigned char*)payload_ptr-sdu)); + + for (j=0;j<32;j++) + LOG_T(MAC,"%x ",payload_ptr[j]); + LOG_T(MAC,"\n"); #endif - LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d (%d)\n", - Mod_id,frame, rx_lengths[i], UE_id,rx_lcids[i],rx_lcids[i]+(UE_id*NB_RB_MAX)); - - if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block - mac_rlc_data_ind(Mod_id,frame,1,RLC_MBMS_NO, - DTCH+(UE_id*NB_RB_MAX), - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL);//(unsigned int*)crc_status); - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].num_pdu_rx[rx_lcids[i]]+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; - + LOG_D(MAC,"[eNB %d] Frame %d : ULSCH -> UL-DTCH, received %d bytes from UE %d for lcid %d (%d)\n", + enb_mod_idP,frameP, rx_lengths[i], ue_mod_id,rx_lcids[i],rx_lcids[i]); + + if ((rx_lengths[i] <SCH_PAYLOAD_SIZE_MAX) && (rx_lengths[i] > 0) ) { // MAX SIZE OF transport block + mac_rlc_data_ind(enb_mod_idP,ue_mod_id, frameP,1,RLC_MBMS_NO, + DTCH, + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL);//(unsigned int*)crc_status); + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].num_pdu_rx[rx_lcids[i]]+=1; + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].num_bytes_rx[rx_lcids[i]]+=rx_lengths[i]; + + } + // } + } else { + eNB_mac_inst[enb_mod_idP].eNB_UE_stats[ue_mod_id].num_errors_rx+=1; + LOG_E(MAC,"[eNB %d] received unknown LCID %d from UE %d ", rx_lcids[i], ue_mod_id); } - // } - } else { - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].num_errors_rx+=1; - LOG_E(MAC,"[eNB %d] received unknown LCID %d from UE %d ", rx_lcids[i], UE_id); - } - - payload_ptr+=rx_lengths[i]; + + payload_ptr+=rx_lengths[i]; } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_RX_SDU,0); @@ -649,14 +652,14 @@ void rx_sdu(u8 Mod_id,u32 frame,u16 rnti,u8 *sdu, u16 sdu_len) { } unsigned char generate_dlsch_header(unsigned char *mac_header, - unsigned char num_sdus, - unsigned short *sdu_lengths, - unsigned char *sdu_lcids, - unsigned char drx_cmd, - short timing_advance_cmd, - unsigned char *ue_cont_res_id, - unsigned char short_padding, - unsigned short post_padding) { + unsigned char num_sdus, + unsigned short *sdu_lengths, + unsigned char *sdu_lcids, + unsigned char drx_cmd, + short timing_advance_cmd, + unsigned char *ue_cont_res_id, + unsigned char short_padding, + unsigned short post_padding) { SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header; u8 first_element=0,last_size=0,i; @@ -665,137 +668,137 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, ce_ptr = &mac_header_control_elements[0]; // compute header components - + if ((short_padding == 1) || (short_padding == 2)) { - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - first_element=1; - last_size=1; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + first_element=1; + last_size=1; } if (short_padding == 2) { - mac_header_ptr->E = 1; - mac_header_ptr++; - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - last_size=1; + mac_header_ptr->E = 1; + mac_header_ptr++; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + last_size=1; } if (drx_cmd != 255) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } - else { - first_element=1; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = DRX_CMD; - last_size=1; + if (first_element>0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } + else { + first_element=1; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = DRX_CMD; + last_size=1; } if (timing_advance_cmd != 0) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } - else { - first_element=1; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = TIMING_ADV_CMD; - last_size=1; - // msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - ((TIMING_ADVANCE_CMD *)ce_ptr)->R=0; - ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=timing_advance_cmd&0x3f; - LOG_I(MAC,"timing advance =%d (%d)\n",timing_advance_cmd,((TIMING_ADVANCE_CMD *)ce_ptr)->TA); - ce_ptr+=sizeof(TIMING_ADVANCE_CMD); - //msg("offset %d\n",ce_ptr-mac_header_control_elements); + if (first_element>0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } + else { + first_element=1; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = TIMING_ADV_CMD; + last_size=1; + // msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + ((TIMING_ADVANCE_CMD *)ce_ptr)->R=0; + ((TIMING_ADVANCE_CMD *)ce_ptr)->TA=timing_advance_cmd&0x3f; + LOG_I(MAC,"timing advance =%d (%d)\n",timing_advance_cmd,((TIMING_ADVANCE_CMD *)ce_ptr)->TA); + ce_ptr+=sizeof(TIMING_ADVANCE_CMD); + //msg("offset %d\n",ce_ptr-mac_header_control_elements); } if (ue_cont_res_id) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* + if (first_element>0) { + mac_header_ptr->E = 1; + /* printf("[eNB][MAC] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } - else { - first_element=1; - } + */ + mac_header_ptr++; + } + else { + first_element=1; + } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = UE_CONT_RES; - last_size=1; - - LOG_T(MAC,"[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", - ue_cont_res_id[0], - ue_cont_res_id[1], - ue_cont_res_id[2], - ue_cont_res_id[3], - ue_cont_res_id[4], - ue_cont_res_id[5]); - - memcpy(ce_ptr,ue_cont_res_id,6); - ce_ptr+=6; - // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = UE_CONT_RES; + last_size=1; + + LOG_T(MAC,"[eNB ][RAPROC] Generate contention resolution msg: %x.%x.%x.%x.%x.%x\n", + ue_cont_res_id[0], + ue_cont_res_id[1], + ue_cont_res_id[2], + ue_cont_res_id[3], + ue_cont_res_id[4], + ue_cont_res_id[5]); + + memcpy(ce_ptr,ue_cont_res_id,6); + ce_ptr+=6; + // msg("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); for (i=0;i<num_sdus;i++) { - LOG_T(MAC,"[eNB] Generate DLSCH header num sdu %d len sdu %d\n",num_sdus, sdu_lengths[i]); + LOG_T(MAC,"[eNB] Generate DLSCH header num sdu %d len sdu %d\n",num_sdus, sdu_lengths[i]); - if (first_element>0) { - mac_header_ptr->E = 1; - /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + if (first_element>0) { + mac_header_ptr->E = 1; + /*msg("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr+=last_size; - //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } - else { - first_element=1; - } - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; - last_size=2; - } - else { - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; - last_size=3; + */ + mac_header_ptr+=last_size; + //msg("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } + else { + first_element=1; + } + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; + last_size=2; + } + else { + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; + last_size=3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", - sdu_lengths[i], - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB, - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB); + LOG_D(MAC,"[eNB] generate long sdu, size %x (MSB %x, LSB %x)\n", + sdu_lengths[i], + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB, + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB); #endif - } + } } /* printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - + printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, @@ -808,27 +811,27 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, else printf("F = 1, sdu len (L field) %d\n",(((SCH_SUBHEADER_LONG*)mac_header_ptr)->L)); } - */ + */ if (post_padding>0) {// we have lots of padding at the end of the packet - mac_header_ptr->E = 1; - mac_header_ptr+=last_size; - // add a padding element - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - mac_header_ptr++; + mac_header_ptr->E = 1; + mac_header_ptr+=last_size; + // add a padding element + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + mac_header_ptr++; } else { // no end of packet padding - // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) - mac_header_ptr++; + // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) + mac_header_ptr++; } //msg("After subheaders %d\n",(u8*)mac_header_ptr - mac_header); - + if ((ce_ptr-mac_header_control_elements) > 0) { - // printf("Copying %d bytes for control elements\n",ce_ptr-mac_header_control_elements); - memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); - mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); + // printf("Copying %d bytes for control elements\n",ce_ptr-mac_header_control_elements); + memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); + mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); } //msg("After CEs %d\n",(u8*)mac_header_ptr - mac_header); @@ -895,7 +898,7 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, } // Create the MSI MAC Control Element here } - + // SUBHEADER for MAC SDU (MCCH+MTCHs) for (i=0;i<num_sdus;i++) { if (first_element>0) { @@ -947,15 +950,15 @@ unsigned char generate_dlsch_header(unsigned char *mac_header, return((unsigned char*)mac_header_ptr - mac_header); } #endif -*/ + */ void add_common_dci(DCI_PDU *DCI_pdu, - void *pdu, - u16 rnti, - unsigned char dci_size_bytes, - unsigned char aggregation, - unsigned char dci_size_bits, - unsigned char dci_fmt, - u8 ra_flag) { + void *pdu, + rnti_t rnti, + unsigned char dci_size_bytes, + unsigned char aggregation, + unsigned char dci_size_bits, + unsigned char dci_fmt, + u8 ra_flag) { memcpy(&DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci].dci_pdu[0],pdu,dci_size_bytes); DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci].dci_length = dci_size_bits; @@ -968,7 +971,7 @@ void add_common_dci(DCI_PDU *DCI_pdu, DCI_pdu->Num_common_dci++; } -void add_ue_spec_dci(DCI_PDU *DCI_pdu,void *pdu,u16 rnti,unsigned char dci_size_bytes,unsigned char aggregation,unsigned char dci_size_bits,unsigned char dci_fmt,u8 ra_flag) { +void add_ue_spec_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,u8 ra_flag) { memcpy(&DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci].dci_pdu[0],pdu,dci_size_bytes); DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci].dci_length = dci_size_bits; @@ -980,134 +983,142 @@ void add_ue_spec_dci(DCI_PDU *DCI_pdu,void *pdu,u16 rnti,unsigned char dci_size_ DCI_pdu->Num_ue_spec_dci++; } -void schedule_SI(unsigned char Mod_id,u32 frame, unsigned char *nprb,unsigned int *nCCE) { +void schedule_SI(module_id_t module_idP,frame_t frameP, unsigned char *nprb,unsigned int *nCCE) { unsigned char bcch_sdu_length; int mcs = -1; - void *BCCH_alloc_pdu=(void*)&eNB_mac_inst[Mod_id].BCCH_alloc_pdu; - - bcch_sdu_length = mac_rrc_data_req(Mod_id, - frame, - BCCH,1, - &eNB_mac_inst[Mod_id].BCCH_pdu.payload[0], - 1, - Mod_id, - 0); // not used in this case + void *BCCH_alloc_pdu=(void*)&eNB_mac_inst[module_idP].BCCH_alloc_pdu; + + bcch_sdu_length = mac_rrc_data_req(module_idP, + frameP, + BCCH,1, + &eNB_mac_inst[module_idP].BCCH_pdu.payload[0], + 1, + module_idP, + 0); // not used in this case if (bcch_sdu_length > 0) { - LOG_D(MAC,"[eNB %d] Frame %d : BCCH->DLSCH, Received %d bytes \n",Mod_id,frame,bcch_sdu_length); - - - if (bcch_sdu_length <= (mac_xface->get_TBS_DL(0,3))) - mcs=0; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(1,3))) - mcs=1; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(2,3))) - mcs=2; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(3,3))) - mcs=3; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(4,3))) - mcs=4; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(5,3))) - mcs=5; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(6,3))) - mcs=6; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(7,3))) - mcs=7; - else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(8,3))) - mcs=8; - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 25: - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 50: - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 100: - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; - break; + LOG_D(MAC,"[eNB %d] Frame %d : BCCH->DLSCH, Received %d bytes \n",module_idP,frameP,bcch_sdu_length); + + + if (bcch_sdu_length <= (mac_xface->get_TBS_DL(0,3))) + mcs=0; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(1,3))) + mcs=1; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(2,3))) + mcs=2; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(3,3))) + mcs=3; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(4,3))) + mcs=4; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(5,3))) + mcs=5; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(6,3))) + mcs=6; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(7,3))) + mcs=7; + else if (bcch_sdu_length <= (mac_xface->get_TBS_DL(8,3))) + mcs=8; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 25: + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 50: + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 100: + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + + } } - } - else { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 25: - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 50: - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - case 100: - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; - break; - + else { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 25: + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 50: + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + case 100: + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->mcs = mcs; + break; + + } } - } #if defined(USER_MODE) && defined(OAI_EMU) - if (oai_emulation.info.opt_enabled) - trace_pdu(1, &eNB_mac_inst[Mod_id].BCCH_pdu.payload[0], bcch_sdu_length, - 0xffff, 4, 0xffff, eNB_mac_inst[Mod_id].subframe, 0, 0); - LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n", - Mod_id, frame, 0xffff, bcch_sdu_length); + if (oai_emulation.info.opt_enabled) { + trace_pdu(1, + &eNB_mac_inst[module_idP].BCCH_pdu.payload[0], + bcch_sdu_length, + 0xffff, + 4, + 0xffff, + eNB_mac_inst[module_idP].subframe, + 0, + 0); + } + LOG_D(OPT,"[eNB %d][BCH] Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, 0xffff, bcch_sdu_length); #endif - if (mac_xface->lte_frame_parms->frame_type == TDD) { - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n", - frame, - bcch_sdu_length, - mcs, - mac_xface->get_TBS_DL(mcs,3)); - } - else { - LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (FDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n", - frame, - bcch_sdu_length, - mcs, - mac_xface->get_TBS_DL(mcs,3)); - } - eNB_mac_inst[Mod_id].bcch_active=1; - *nprb=3; - *nCCE=4; - return; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (TDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n", + frameP, + bcch_sdu_length, + mcs, + mac_xface->get_TBS_DL(mcs,3)); + } + else { + LOG_D(MAC,"[eNB] Frame %d : Scheduling BCCH->DLSCH (FDD) for SI %d bytes (mcs %d, rb 3, TBS %d)\n", + frameP, + bcch_sdu_length, + mcs, + mac_xface->get_TBS_DL(mcs,3)); + } + eNB_mac_inst[module_idP].bcch_active=1; + *nprb=3; + *nCCE=4; + return; } - eNB_mac_inst[Mod_id].bcch_active=0; + eNB_mac_inst[module_idP].bcch_active=0; *nprb=0; - *nCCE=0; - //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",Mod_id,frame); + *nCCE=0; + //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",module_idP,frameP); } #ifdef Rel10 -s8 get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area){ +s8 get_mbsfn_sf_alloction (module_id_t module_idP, u8 mbsfn_sync_area){ // currently there is one-to-one mapping between sf allocation pattern and sync area if (mbsfn_sync_area > MAX_MBSFN_AREA){ - LOG_W(MAC,"[eNB %d] MBSFN synchronization area %d out of range\n ", Mod_id, mbsfn_sync_area); - return -1; + LOG_W(MAC,"[eNB %d] MBSFN synchronization area %d out of range\n ", module_idP, mbsfn_sync_area); + return -1; } - else if (eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) - return mbsfn_sync_area; + else if (eNB_mac_inst[module_idP].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) + return mbsfn_sync_area; else { - LOG_W(MAC,"[eNB %d] MBSFN Subframe Config pattern %d not found \n ", Mod_id, mbsfn_sync_area); - return -1; + LOG_W(MAC,"[eNB %d] MBSFN Subframe Config pattern %d not found \n ", module_idP, mbsfn_sync_area); + return -1; } } -int schedule_MBMS(unsigned char Mod_id,u32 frame, u8 subframe) { +int schedule_MBMS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) { int mcch_flag=0,mtch_flag=0, msi_flag=0; - int mbsfn_period =0;// 1<<(eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - int mcch_period = 0;//32<<(eNB_mac_inst[Mod_id].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - int mch_scheduling_period = 8<<(eNB_mac_inst[Mod_id].pmch_Config[0]->mch_SchedulingPeriod_r9); + int mbsfn_period =0;// 1<<(eNB_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + int mcch_period = 0;//32<<(eNB_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + int mch_scheduling_period = 8<<(eNB_mac_inst[module_idP].pmch_Config[0]->mch_SchedulingPeriod_r9); unsigned char mcch_sdu_length; - unsigned char header_len_mcch=0,header_len_msi=0,header_len_mtch=0, header_len_mtch_temp=0, header_len_mcch_temp=0, header_len_msi_temp=0; + unsigned char header_len_mcch=0,header_len_msi=0,header_len_mtch=0, header_len_mtch_temp=0, header_len_mcch_temp=0, header_len_msi_temp=0; int ii=0, msi_pos=0; int mcch_mcs = -1; u16 TBS,j,padding=0,post_padding=0; @@ -1118,465 +1129,465 @@ int schedule_MBMS(unsigned char Mod_id,u32 frame, u8 subframe) { u16 sdu_lengths[11], sdu_length_total=0; unsigned char mch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; // check the max value, this is for dlsch only - eNB_mac_inst[Mod_id].MCH_pdu.Pdu_size=0; + eNB_mac_inst[module_idP].MCH_pdu.Pdu_size=0; - for (i=0; - i< eNB_mac_inst[Mod_id].num_active_mbsfn_area; - i++ ){ - // assume, that there is always a mapping - if ((j=get_mbsfn_sf_alloction(Mod_id,i)) == -1) - return 0; - - mbsfn_period = 1<<(eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod); - mcch_period = 32<<(eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - msi_pos=0; ii=0; - LOG_D(MAC,"[eNB %d] Frame %d subframe %d : Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d)\n", - Mod_id,frame, subframe,i,eNB_mac_inst[Mod_id].num_active_mbsfn_area, - j,eNB_mac_inst[Mod_id].num_sf_allocation_pattern,mbsfn_period,mcch_period); - - - switch (eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { - case 0: - mcch_mcs = 2; - break; - case 1: - mcch_mcs = 7; - break; - case 2: - mcch_mcs = 13; - break; - case 3: - mcch_mcs = 19; - break; - } - - // 1st: Check the MBSFN subframes from SIB2 info (SF allocation pattern i, max 8 non-overlapping patterns exist) - if (frame % mbsfn_period == eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frame - if (eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frame format - - // Find the first subframe in this MCH to transmit MSI - if (frame % mch_scheduling_period == eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { - while (ii == 0) { - ii = eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); - msi_pos++; - } - LOG_D(MAC,"[eNB %d] Frame %d subframe %d : sync area %d sf allocation pattern %d sf alloc %x msi pos is %d \n", Mod_id,frame, subframe,i,j,eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0], msi_pos); - } - - // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 - switch (subframe) { - case 1: - if (mac_xface->lte_frame_parms->frame_type == FDD) { - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 2: - if (mac_xface->lte_frame_parms->frame_type == FDD){ - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 3: - if (mac_xface->lte_frame_parms->frame_type == TDD){// TDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else {// FDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 4: - if (mac_xface->lte_frame_parms->frame_type == TDD){ - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 6: - if (mac_xface->lte_frame_parms->frame_type == FDD){ - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 7: - if (mac_xface->lte_frame_parms->frame_type == TDD){ // TDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else {// FDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 8: - if (mac_xface->lte_frame_parms->frame_type == TDD){ //TDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else{ // FDD - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 9: - if (mac_xface->lte_frame_parms->frame_type == TDD){ - if ((eNB_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) - msi_flag = 1; - if ( (frame % mcch_period == eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((eNB_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - }// end switch - // sf allocation is non-overlapping - if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)){ - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", - Mod_id, frame, subframe,i,j,msi_flag,mcch_flag,mtch_flag); - break; - } + for (i=0; + i< eNB_mac_inst[module_idP].num_active_mbsfn_area; + i++ ){ + // assume, that there is always a mapping + if ((j=get_mbsfn_sf_alloction(module_idP,i)) == -1) + return 0; + + mbsfn_period = 1<<(eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationPeriod); + mcch_period = 32<<(eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + msi_pos=0; ii=0; + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d : Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d)\n", + module_idP,frameP, subframeP,i,eNB_mac_inst[module_idP].num_active_mbsfn_area, + j,eNB_mac_inst[module_idP].num_sf_allocation_pattern,mbsfn_period,mcch_period); + + + switch (eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { + case 0: + mcch_mcs = 2; + break; + case 1: + mcch_mcs = 7; + break; + case 2: + mcch_mcs = 13; + break; + case 3: + mcch_mcs = 19; + break; } - else {// four-frame format + + // 1st: Check the MBSFN subframes from SIB2 info (SF allocation pattern i, max 8 non-overlapping patterns exist) + if (frameP % mbsfn_period == eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frameP + if (eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frameP format + + // Find the first subframeP in this MCH to transmit MSI + if (frameP % mch_scheduling_period == eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { + while (ii == 0) { + ii = eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); + msi_pos++; + } + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d : sync area %d sf allocation pattern %d sf alloc %x msi pos is %d \n", module_idP,frameP, subframeP,i,j,eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0], msi_pos); + } + + // Check if the subframeP is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 + switch (subframeP) { + case 1: + if (mac_xface->lte_frame_parms->frame_type == FDD) { + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { + if (msi_pos == 1) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 2: + if (mac_xface->lte_frame_parms->frame_type == FDD){ + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { + if (msi_pos == 2) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 3: + if (mac_xface->lte_frame_parms->frame_type == TDD){// TDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { + if (msi_pos == 1) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else {// FDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { + if (msi_pos == 3) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 4: + if (mac_xface->lte_frame_parms->frame_type == TDD){ + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { + if (msi_pos == 2) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 6: + if (mac_xface->lte_frame_parms->frame_type == FDD){ + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { + if (msi_pos == 4) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 7: + if (mac_xface->lte_frame_parms->frame_type == TDD){ // TDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { + if (msi_pos == 3) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else {// FDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { + if (msi_pos == 5) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 8: + if (mac_xface->lte_frame_parms->frame_type == TDD){ //TDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { + if (msi_pos == 4) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else{ // FDD + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { + if (msi_pos == 6) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 9: + if (mac_xface->lte_frame_parms->frame_type == TDD){ + if ((eNB_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { + if (msi_pos == 5) + msi_flag = 1; + if ( (frameP % mcch_period == eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((eNB_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + }// end switch + // sf allocation is non-overlapping + if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)){ + LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", + module_idP, frameP, subframeP,i,j,msi_flag,mcch_flag,mtch_flag); + break; + } + } + else {// four-frameP format + } } - } - } // end of for loop - eNB_mac_inst[Mod_id].msi_active=0; - eNB_mac_inst[Mod_id].mcch_active=0; - eNB_mac_inst[Mod_id].mtch_active=0; - // Calculate the mcs + } // end of for loop + eNB_mac_inst[module_idP].msi_active=0; + eNB_mac_inst[module_idP].mcch_active=0; + eNB_mac_inst[module_idP].mtch_active=0; + // Calculate the mcs if ((msi_flag==1) || (mcch_flag==1)) { - eNB_mac_inst[Mod_id].MCH_pdu.mcs = mcch_mcs; + eNB_mac_inst[module_idP].MCH_pdu.mcs = mcch_mcs; } - else if (mtch_flag == 1) { // only MTCH in this subframe - eNB_mac_inst[Mod_id].MCH_pdu.mcs = eNB_mac_inst[Mod_id].pmch_Config[0]->dataMCS_r9; + else if (mtch_flag == 1) { // only MTCH in this subframeP + eNB_mac_inst[module_idP].MCH_pdu.mcs = eNB_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; } - - + + // 2nd: Create MSI, get MCCH from RRC and MTCHs from RLC - - // there is MSI (MCH Scheduling Info) + + // there is MSI (MCH Scheduling Info) if (msi_flag == 1) { - // Create MSI here - u16 msi_control_element[29], *msi_ptr; - - msi_ptr = &msi_control_element[0]; - ((MSI_ELEMENT *) msi_ptr)->lcid = MCCH_LCHANID; //MCCH - if (mcch_flag==1) { - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0; - } - else { // no mcch for this MSP - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0x7;// stop value is 2047 - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xff; - } - msi_ptr+= sizeof(MSI_ELEMENT); - - //Header for MTCHs - num_mtch = eNB_mac_inst[Mod_id].mbms_SessionList[0]->list.count; - for (k=0;k<num_mtch;k++) { // loop for all session in this MCH (MCH[0]) at this moment - ((MSI_ELEMENT *) msi_ptr)->lcid = eNB_mac_inst[Mod_id].mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9;//mtch_lcid; - ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; // last subframe of this mtch (only one mtch now) - ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xB; - msi_ptr+=sizeof(MSI_ELEMENT); - } - msi_length = msi_ptr-msi_control_element; - if (msi_length<128) - header_len_msi = 2; - else - header_len_msi = 3; - - LOG_D(MAC,"[eNB %d] Frame %d : MSI->MCH, length of MSI is %d bytes \n",Mod_id,frame,msi_length); - //LOG_D(MAC,"Scheduler: MSI is transmitted in this subframe \n" ); - - // LOG_D(MAC,"Scheduler: MSI length is %d bytes\n",msi_length); - // Store MSI data to mch_buffer[0] - memcpy((char *)&mch_buffer[sdu_length_total], - msi_control_element, - msi_length); - - sdu_lcids[num_sdus] = MCH_SCHDL_INFO; - sdu_lengths[num_sdus] = msi_length; - sdu_length_total += sdu_lengths[num_sdus]; - LOG_I(MAC,"[eNB %d] Create %d bytes for MSI\n",Mod_id,sdu_lengths[num_sdus]); - num_sdus++; - eNB_mac_inst[Mod_id].msi_active=1; + // Create MSI here + u16 msi_control_element[29], *msi_ptr; + + msi_ptr = &msi_control_element[0]; + ((MSI_ELEMENT *) msi_ptr)->lcid = MCCH_LCHANID; //MCCH + if (mcch_flag==1) { + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0; + } + else { // no mcch for this MSP + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0x7;// stop value is 2047 + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xff; + } + msi_ptr+= sizeof(MSI_ELEMENT); + + //Header for MTCHs + num_mtch = eNB_mac_inst[module_idP].mbms_SessionList[0]->list.count; + for (k=0;k<num_mtch;k++) { // loop for all session in this MCH (MCH[0]) at this moment + ((MSI_ELEMENT *) msi_ptr)->lcid = eNB_mac_inst[module_idP].mbms_SessionList[0]->list.array[k]->logicalChannelIdentity_r9;//mtch_lcid; + ((MSI_ELEMENT *) msi_ptr)->stop_sf_MSB = 0; // last subframeP of this mtch (only one mtch now) + ((MSI_ELEMENT *) msi_ptr)->stop_sf_LSB = 0xB; + msi_ptr+=sizeof(MSI_ELEMENT); + } + msi_length = msi_ptr-msi_control_element; + if (msi_length<128) + header_len_msi = 2; + else + header_len_msi = 3; + + LOG_D(MAC,"[eNB %d] Frame %d : MSI->MCH, length of MSI is %d bytes \n",module_idP,frameP,msi_length); + //LOG_D(MAC,"Scheduler: MSI is transmitted in this subframeP \n" ); + + // LOG_D(MAC,"Scheduler: MSI length is %d bytes\n",msi_length); + // Store MSI data to mch_buffer[0] + memcpy((char *)&mch_buffer[sdu_length_total], + msi_control_element, + msi_length); + + sdu_lcids[num_sdus] = MCH_SCHDL_INFO; + sdu_lengths[num_sdus] = msi_length; + sdu_length_total += sdu_lengths[num_sdus]; + LOG_I(MAC,"[eNB %d] Create %d bytes for MSI\n",module_idP,sdu_lengths[num_sdus]); + num_sdus++; + eNB_mac_inst[module_idP].msi_active=1; } // there is MCCH if (mcch_flag == 1) { - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: Schedule MCCH MESSAGE (area %d, sfAlloc %d)\n", - Mod_id,frame, subframe, i, j); - - mcch_sdu_length = mac_rrc_data_req(Mod_id, - frame, - MCCH,1, - &eNB_mac_inst[Mod_id].MCCH_pdu.payload[0], - 1,// this is eNB - Mod_id, // index - i); // this is the mbsfn sync area index - - if (mcch_sdu_length > 0) { - LOG_D(MAC,"[eNB %d] Frame %d subframe %d : MCCH->MCH, Received %d bytes from RRC \n",Mod_id,frame,subframe,mcch_sdu_length); - - header_len_mcch = 2; - if (mac_xface->lte_frame_parms->frame_type == TDD) { - LOG_D(MAC,"[eNB %d] Frame %d subframe %d: Scheduling MCCH->MCH (TDD) for MCCH message %d bytes (mcs %d )\n", - Mod_id, - frame,subframe, - mcch_sdu_length, - mcch_mcs); + LOG_D(MAC,"[eNB %d] Frame %d Subframe %d: Schedule MCCH MESSAGE (area %d, sfAlloc %d)\n", + module_idP,frameP, subframeP, i, j); + + mcch_sdu_length = mac_rrc_data_req(module_idP, + frameP, + MCCH,1, + &eNB_mac_inst[module_idP].MCCH_pdu.payload[0], + 1,// this is eNB + module_idP, // index + i); // this is the mbsfn sync area index + + if (mcch_sdu_length > 0) { + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d : MCCH->MCH, Received %d bytes from RRC \n",module_idP,frameP,subframeP,mcch_sdu_length); + + header_len_mcch = 2; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d: Scheduling MCCH->MCH (TDD) for MCCH message %d bytes (mcs %d )\n", + module_idP, + frameP,subframeP, + mcch_sdu_length, + mcch_mcs); + } + else { + LOG_I(MAC,"[eNB %d] Frame %d subframeP %d: Scheduling MCCH->MCH (FDD) for MCCH message %d bytes (mcs %d)\n", + module_idP, + frameP, subframeP, + mcch_sdu_length, + mcch_mcs); + } + eNB_mac_inst[module_idP].mcch_active=1; + + memcpy((char *)&mch_buffer[sdu_length_total], + &eNB_mac_inst[module_idP].MCCH_pdu.payload[0], + mcch_sdu_length); + sdu_lcids[num_sdus] = MCCH_LCHANID; + sdu_lengths[num_sdus] = mcch_sdu_length; + if (sdu_lengths[num_sdus]>128) + header_len_mcch = 3; + sdu_length_total += sdu_lengths[num_sdus]; + LOG_D(MAC,"[eNB %d] Got %d bytes for MCCH from RRC \n",module_idP,sdu_lengths[num_sdus]); + num_sdus++; } - else { - LOG_I(MAC,"[eNB %d] Frame %d subframe %d: Scheduling MCCH->MCH (FDD) for MCCH message %d bytes (mcs %d)\n", - Mod_id, - frame, subframe, - mcch_sdu_length, - mcch_mcs); - } - eNB_mac_inst[Mod_id].mcch_active=1; - - memcpy((char *)&mch_buffer[sdu_length_total], - &eNB_mac_inst[Mod_id].MCCH_pdu.payload[0], - mcch_sdu_length); - sdu_lcids[num_sdus] = MCCH_LCHANID; - sdu_lengths[num_sdus] = mcch_sdu_length; - if (sdu_lengths[num_sdus]>128) - header_len_mcch = 3; - sdu_length_total += sdu_lengths[num_sdus]; - LOG_D(MAC,"[eNB %d] Got %d bytes for MCCH from RRC \n",Mod_id,sdu_lengths[num_sdus]); - num_sdus++; - } } - TBS = mac_xface->get_TBS_DL(eNB_mac_inst[Mod_id].MCH_pdu.mcs, mac_xface->lte_frame_parms->N_RB_DL); -#ifdef Rel10 - // do not let mcch and mtch multiplexing when relaying is active - // for sync area 1, so not transmit data - //if ((i == 0) && ((eNB_mac_inst[Mod_id].MBMS_flag != multicast_relay) || (eNB_mac_inst[Mod_id].mcch_active==0))) { -#endif - // there is MTCHs, loop if there are more than 1 + TBS = mac_xface->get_TBS_DL(eNB_mac_inst[module_idP].MCH_pdu.mcs, mac_xface->lte_frame_parms->N_RB_DL); +#ifdef Rel10 + // do not let mcch and mtch multiplexing when relaying is active + // for sync area 1, so not transmit data + //if ((i == 0) && ((eNB_mac_inst[module_idP].MBMS_flag != multicast_relay) || (eNB_mac_inst[module_idP].mcch_active==0))) { +#endif + // there is MTCHs, loop if there are more than 1 if (mtch_flag == 1) { - // Calculate TBS - /* if ((msi_flag==1) || (mcch_flag==1)) { + // Calculate TBS + /* if ((msi_flag==1) || (mcch_flag==1)) { TBS = mac_xface->get_TBS(mcch_mcs, mac_xface->lte_frame_parms->N_RB_DL); } - else { // only MTCH in this subframe - TBS = mac_xface->get_TBS(eNB_mac_inst[Mod_id].pmch_Config[0]->dataMCS_r9, mac_xface->lte_frame_parms->N_RB_DL); + else { // only MTCH in this subframeP + TBS = mac_xface->get_TBS(eNB_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9, mac_xface->lte_frame_parms->N_RB_DL); } - */ - - // get MTCH data from RLC (like for DTCH) - LOG_D(MAC,"[eNB %d] Frame %d subframe %d: Schedule MTCH (area %d, sfAlloc %d)\n",Mod_id,frame,subframe,i,j); - - header_len_mtch = 3; - LOG_D(MAC,"[eNB %d], Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", - Mod_id,frame,MTCH,TBS, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); - - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG, - TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); - //printf("frame %d, subframe %d, rlc_status.bytes_in_buffer is %d\n",frame,subframe, rlc_status.bytes_in_buffer); - - if (rlc_status.bytes_in_buffer >0) { - LOG_I(MAC,"[eNB %d][MBMS USER-PLANE], Frame %d, MTCH->MCH, Requesting %d bytes from RLC (header len mtch %d)\n", - Mod_id,frame,TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch,header_len_mtch); - - sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id,frame, RLC_MBMS_YES, - MTCH + (maxDRB + 3) * MAX_MOBILES_PER_RG, - (char*)&mch_buffer[sdu_length_total]); - //sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id,frame, RLC_MBMS_NO, MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]); - LOG_I(MAC,"[eNB %d][MBMS USER-PLANE] Got %d bytes for MTCH %d\n",Mod_id,sdu_lengths[num_sdus],MTCH); - eNB_mac_inst[Mod_id].mtch_active=1; - sdu_lcids[num_sdus] = MTCH; - sdu_length_total += sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) - header_len_mtch = 2; - num_sdus++; - } - else { - header_len_mtch = 0; - } + */ + + // get MTCH data from RLC (like for DTCH) + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d: Schedule MTCH (area %d, sfAlloc %d)\n",module_idP,frameP,subframeP,i,j); + + header_len_mtch = 3; + LOG_D(MAC,"[eNB %d], Frame %d, MTCH->MCH, Checking RLC status (rab %d, tbs %d, len %d)\n", + module_idP,frameP,MTCH,TBS, + TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); + + rlc_status = mac_rlc_status_ind(module_idP,frameP,1,RLC_MBMS_YES,MTCH+ (maxDRB + 3) * MAX_MOBILES_PER_RG, + TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch); + //printf("frameP %d, subframeP %d, rlc_status.bytes_in_buffer is %d\n",frameP,subframeP, rlc_status.bytes_in_buffer); + + if (rlc_status.bytes_in_buffer >0) { + LOG_I(MAC,"[eNB %d][MBMS USER-PLANE], Frame %d, MTCH->MCH, Requesting %d bytes from RLC (header len mtch %d)\n", + module_idP,frameP,TBS-header_len_mcch-header_len_msi-sdu_length_total-header_len_mtch,header_len_mtch); + + sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, 1, RLC_MBMS_YES, + MTCH + (maxDRB + 3) * MAX_MOBILES_PER_RG, + (char*)&mch_buffer[sdu_length_total]); + //sdu_lengths[num_sdus] = mac_rlc_data_req(module_idP,frameP, RLC_MBMS_NO, MTCH+(MAX_NUM_RB*(NUMBER_OF_UE_MAX+1)), (char*)&mch_buffer[sdu_length_total]); + LOG_I(MAC,"[eNB %d][MBMS USER-PLANE] Got %d bytes for MTCH %d\n",module_idP,sdu_lengths[num_sdus],MTCH); + eNB_mac_inst[module_idP].mtch_active=1; + sdu_lcids[num_sdus] = MTCH; + sdu_length_total += sdu_lengths[num_sdus]; + if (sdu_lengths[num_sdus] < 128) + header_len_mtch = 2; + num_sdus++; + } + else { + header_len_mtch = 0; + } } #ifdef Rel10 // } #endif // FINAL STEP: Prepare and multiplexe MSI, MCCH and MTCHs if ((sdu_length_total + header_len_msi + header_len_mcch + header_len_mtch) >0) { - // Adjust the last subheader - /* if ((msi_flag==1) || (mcch_flag==1)) { - eNB_mac_inst[Mod_id].MCH_pdu.mcs = mcch_mcs; + // Adjust the last subheader + /* if ((msi_flag==1) || (mcch_flag==1)) { + eNB_mac_inst[module_idP].MCH_pdu.mcs = mcch_mcs; } - else if (mtch_flag == 1) { // only MTCH in this subframe - eNB_mac_inst[Mod_id].MCH_pdu.mcs = eNB_mac_inst[Mod_id].pmch_Config[0]->dataMCS_r9; + else if (mtch_flag == 1) { // only MTCH in this subframeP + eNB_mac_inst[module_idP].MCH_pdu.mcs = eNB_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; } - */ - header_len_mtch_temp = header_len_mtch; - header_len_mcch_temp = header_len_mcch; - header_len_msi_temp = header_len_msi; - if (header_len_mtch>0) - header_len_mtch=1; // remove Length field in the subheader for the last PDU - else if (header_len_mcch>0) - header_len_mcch=1; - else header_len_msi=1; - // Calculate the padding - if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total) <= 2) { - padding = (TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total); - post_padding = 0; - } - else {// using post_padding, give back the Length field of subheader for the last PDU - padding = 0; + */ + header_len_mtch_temp = header_len_mtch; + header_len_mcch_temp = header_len_mcch; + header_len_msi_temp = header_len_msi; if (header_len_mtch>0) - header_len_mtch = header_len_mtch_temp; + header_len_mtch=1; // remove Length field in the subheader for the last PDU else if (header_len_mcch>0) - header_len_mcch = header_len_mcch_temp; - else header_len_msi = header_len_msi_temp; - post_padding = TBS - sdu_length_total - header_len_msi - header_len_mcch - header_len_mtch; - } - // Generate the MAC Header for MCH - // here we use the function for DLSCH because DLSCH & MCH have the same Header structure - offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[Mod_id].MCH_pdu.payload, - num_sdus, - sdu_lengths, - sdu_lcids, - 255, // no drx - 0, // no timing advance - NULL, // no contention res id - padding, - post_padding); - - eNB_mac_inst[Mod_id].MCH_pdu.Pdu_size=TBS; - eNB_mac_inst[Mod_id].MCH_pdu.sync_area=i; - eNB_mac_inst[Mod_id].MCH_pdu.msi_active= eNB_mac_inst[Mod_id].msi_active; - eNB_mac_inst[Mod_id].MCH_pdu.mcch_active= eNB_mac_inst[Mod_id].mcch_active; - eNB_mac_inst[Mod_id].MCH_pdu.mtch_active= eNB_mac_inst[Mod_id].mtch_active; - LOG_D(MAC," MCS for this sf is %d (mcch active %d, mtch active %d)\n", eNB_mac_inst[Mod_id].MCH_pdu.mcs, - eNB_mac_inst[Mod_id].MCH_pdu.mcch_active,eNB_mac_inst[Mod_id].MCH_pdu.mtch_active ); - LOG_I(MAC,"[eNB %d][MBMS USER-PLANE ] Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n", - Mod_id,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,eNB_mac_inst[Mod_id].MCH_pdu.mcs,TBS,header_len_mtch, header_len_mcch, header_len_msi); - // copy SDU to mch_pdu after the MAC Header - memcpy(&eNB_mac_inst[Mod_id].MCH_pdu.payload[offset],mch_buffer,sdu_length_total); - // filling remainder of MCH with random data if necessery - for (j=0;j<(TBS-sdu_length_total-offset);j++) - eNB_mac_inst[Mod_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); - + header_len_mcch=1; + else header_len_msi=1; + // Calculate the padding + if ((TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total) <= 2) { + padding = (TBS - header_len_mtch - header_len_mcch - header_len_msi - sdu_length_total); + post_padding = 0; + } + else {// using post_padding, give back the Length field of subheader for the last PDU + padding = 0; + if (header_len_mtch>0) + header_len_mtch = header_len_mtch_temp; + else if (header_len_mcch>0) + header_len_mcch = header_len_mcch_temp; + else header_len_msi = header_len_msi_temp; + post_padding = TBS - sdu_length_total - header_len_msi - header_len_mcch - header_len_mtch; + } + // Generate the MAC Header for MCH + // here we use the function for DLSCH because DLSCH & MCH have the same Header structure + offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[module_idP].MCH_pdu.payload, + num_sdus, + sdu_lengths, + sdu_lcids, + 255, // no drx + 0, // no timing advance + NULL, // no contention res id + padding, + post_padding); + + eNB_mac_inst[module_idP].MCH_pdu.Pdu_size=TBS; + eNB_mac_inst[module_idP].MCH_pdu.sync_area=i; + eNB_mac_inst[module_idP].MCH_pdu.msi_active= eNB_mac_inst[module_idP].msi_active; + eNB_mac_inst[module_idP].MCH_pdu.mcch_active= eNB_mac_inst[module_idP].mcch_active; + eNB_mac_inst[module_idP].MCH_pdu.mtch_active= eNB_mac_inst[module_idP].mtch_active; + LOG_D(MAC," MCS for this sf is %d (mcch active %d, mtch active %d)\n", eNB_mac_inst[module_idP].MCH_pdu.mcs, + eNB_mac_inst[module_idP].MCH_pdu.mcch_active,eNB_mac_inst[module_idP].MCH_pdu.mtch_active ); + LOG_I(MAC,"[eNB %d][MBMS USER-PLANE ] Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,padding %d,post_padding %d (mcs %d, TBS %d), header MTCH %d, header MCCH %d, header MSI %d\n", + module_idP,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset,padding,post_padding,eNB_mac_inst[module_idP].MCH_pdu.mcs,TBS,header_len_mtch, header_len_mcch, header_len_msi); + // copy SDU to mch_pdu after the MAC Header + memcpy(&eNB_mac_inst[module_idP].MCH_pdu.payload[offset],mch_buffer,sdu_length_total); + // filling remainder of MCH with random data if necessery + for (j=0;j<(TBS-sdu_length_total-offset);j++) + eNB_mac_inst[module_idP].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); + #if defined(USER_MODE) && defined(OAI_EMU) - /* Tracing of PDU is done on UE side */ - if (oai_emulation.info.opt_enabled) - trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].MCH_pdu.payload, - TBS, Mod_id, 6, 0xffff, // M_RNTI = 6 in wirehsark - eNB_mac_inst[Mod_id].subframe,0,0); - LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n", - Mod_id, frame, TBS); + /* Tracing of PDU is done on UE side */ + if (oai_emulation.info.opt_enabled) + trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].MCH_pdu.payload, + TBS, module_idP, 6, 0xffff, // M_RNTI = 6 in wirehsark + eNB_mac_inst[module_idP].subframeP,0,0); + LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n", + module_idP, frameP, TBS); #endif -/* + /* for (j=0;j<sdu_length_total;j++) - printf("%2x.",eNB_mac_inst[Mod_id].MCH_pdu.payload[j+offset]); + printf("%2x.",eNB_mac_inst[module_idP].MCH_pdu.payload[j+offset]); printf(" \n");*/ - return 1; - } + return 1; + } else { - eNB_mac_inst[Mod_id].MCH_pdu.Pdu_size=0; - eNB_mac_inst[Mod_id].MCH_pdu.sync_area=0; - eNB_mac_inst[Mod_id].MCH_pdu.msi_active=0; - eNB_mac_inst[Mod_id].MCH_pdu.mcch_active=0; - eNB_mac_inst[Mod_id].MCH_pdu.mtch_active=0; - // for testing purpose, fill with random data - //for (j=0;j<(TBS-sdu_length_total-offset);j++) - // eNB_mac_inst[Mod_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); - return 0; + eNB_mac_inst[module_idP].MCH_pdu.Pdu_size=0; + eNB_mac_inst[module_idP].MCH_pdu.sync_area=0; + eNB_mac_inst[module_idP].MCH_pdu.msi_active=0; + eNB_mac_inst[module_idP].MCH_pdu.mcch_active=0; + eNB_mac_inst[module_idP].MCH_pdu.mtch_active=0; + // for testing purpose, fill with random data + //for (j=0;j<(TBS-sdu_length_total-offset);j++) + // eNB_mac_inst[module_idP].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff); + return 0; } - //this is for testing - /* + //this is for testing + /* if (mtch_flag == 1) { // LOG_D(MAC,"DUY: mch_buffer length so far is : %ld\n", &mch_buffer[sdu_length_total]-&mch_buffer[0]); return 1; } - else + else return 0; - */ + */ } -MCH_PDU *get_mch_sdu(uint8_t Mod_id,uint32_t frame, uint32_t subframe) { - // eNB_mac_inst[Mod_id].MCH_pdu.mcs=0; - //LOG_D(MAC," MCH_pdu.mcs is %d\n", eNB_mac_inst[Mod_id].MCH_pdu.mcs); - return(&eNB_mac_inst[Mod_id].MCH_pdu); +MCH_PDU *get_mch_sdu(uint8_t module_idP,uint32_t frameP, sub_frame_t subframeP) { + // eNB_mac_inst[module_idP].MCH_pdu.mcs=0; + //LOG_D(MAC," MCH_pdu.mcs is %d\n", eNB_mac_inst[module_idP].MCH_pdu.mcs); + return(&eNB_mac_inst[module_idP].MCH_pdu); } #endif // First stage of Random-Access Scheduling -void schedule_RA(unsigned char Mod_id,u32 frame, unsigned char subframe,unsigned char Msg3_subframe,unsigned char *nprb,unsigned int *nCCE) { +void schedule_RA(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,unsigned char Msg3_subframe,unsigned char *nprb,unsigned int *nCCE) { - RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[Mod_id].RA_template[0]; + RA_TEMPLATE *RA_template = (RA_TEMPLATE *)&eNB_mac_inst[module_idP].RA_template[0]; unsigned char i;//,harq_pid,round; u16 rrc_sdu_length; unsigned char lcid,offset; @@ -1586,366 +1597,366 @@ void schedule_RA(unsigned char Mod_id,u32 frame, unsigned char subframe,unsigned for (i=0;i<NB_RA_PROC_MAX;i++) { - if (RA_template[i].RA_active == 1) { - - LOG_I(MAC,"[eNB %d][RAPROC] RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n", - Mod_id,i,RA_template[i].generate_rar,RA_template[i].generate_Msg4,RA_template[i].wait_ack_Msg4, RA_template[i].rnti); - - if (RA_template[i].generate_rar == 1) { - *nprb= (*nprb) + 3; - *nCCE = (*nCCE) + 4; - RA_template[i].Msg3_subframe=Msg3_subframe; - } - else if (RA_template[i].generate_Msg4 == 1) { - - // check for Msg4 Message - UE_id = find_UE_id(Mod_id,RA_template[i].rnti); - if (Is_rrc_registered == 1) { - - // Get RRCConnectionSetup for Piggyback - rrc_sdu_length = mac_rrc_data_req(Mod_id, - frame, - CCCH,1, - &eNB_mac_inst[Mod_id].CCCH_pdu.payload[0], - 1, - Mod_id, - 0); // not used in this case - if (rrc_sdu_length == -1) - mac_xface->macphy_exit("[MAC][eNB Scheduler] CCCH not allocated\n"); - else { - //msg("[MAC][eNB %d] Frame %d, subframe %d: got %d bytes from RRC\n",Mod_id,frame, subframe,rrc_sdu_length); - } - } - - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: UE_id %d, Is_rrc_registered %d, rrc_sdu_length %d\n", - Mod_id,frame, subframe,UE_id, Is_rrc_registered,rrc_sdu_length); - - if (rrc_sdu_length>0) { - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: Generating Msg4 with RRC Piggyback (RA proc %d, RNTI %x)\n", - Mod_id,frame, subframe,i,RA_template[i].rnti); - - //msg("[MAC][eNB %d][RAPROC] Frame %d, subframe %d: Received %d bytes for Msg4: \n",Mod_id,frame,subframe,rrc_sdu_length); - // for (j=0;j<rrc_sdu_length;j++) - // msg("%x ",(unsigned char)eNB_mac_inst[Mod_id].CCCH_pdu.payload[j]); - // msg("\n"); - // msg("[MAC][eNB] Frame %d, subframe %d: Generated DLSCH (Msg4) DCI, format 1A, for UE %d\n",frame, subframe,UE_id); - // Schedule Reflection of Connection request - - - - // Compute MCS for 3 PRB - msg4_header = 1+6+1; // CR header, CR CE, SDU header - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 25: - - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 50: - - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 100: - - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - } - } - else { // FDD DCI - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 25: - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 50: - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - case 100: - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; - - if ((rrc_sdu_length+msg4_header) <= 22) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; - TBsize = 22; - } - else if ((rrc_sdu_length+msg4_header) <= 28) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; - TBsize = 28; - } - else if ((rrc_sdu_length+msg4_header) <= 32) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; - TBsize = 32; - } - else if ((rrc_sdu_length+msg4_header) <= 41) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; - TBsize = 41; - } - else if ((rrc_sdu_length+msg4_header) <= 49) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; - TBsize = 49; - } - else if ((rrc_sdu_length+msg4_header) <= 57) { - ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; - TBsize = 57; - } - break; - } - } - RA_template[i].generate_Msg4=0; - RA_template[i].generate_Msg4_dci=1; - RA_template[i].wait_ack_Msg4=1; - RA_template[i].RA_active = 0; - lcid=0; - - if ((TBsize - rrc_sdu_length - msg4_header) <= 2) { - msg4_padding = TBsize - rrc_sdu_length - msg4_header; - msg4_post_padding = 0; - } - else { - msg4_padding = 0; - msg4_post_padding = TBsize - rrc_sdu_length - msg4_header -1; - } - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d subframe %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", - Mod_id,frame,subframe,TBsize,rrc_sdu_length,msg4_header,msg4_padding,msg4_post_padding); - offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)UE_id][0].payload[0], - 1, //num_sdus - &rrc_sdu_length, // - &lcid, // sdu_lcid - 255, // no drx - 0, // no timing advance - RA_template[i].cont_res_id, // contention res id - msg4_padding, // no padding - msg4_post_padding); - - memcpy((void*)&eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)UE_id][0].payload[0][(unsigned char)offset], - &eNB_mac_inst[Mod_id].CCCH_pdu.payload[0], - rrc_sdu_length); + if (RA_template[i].RA_active == 1) { + + LOG_I(MAC,"[eNB %d][RAPROC] RA %d is active (generate RAR %d, generate_Msg4 %d, wait_ack_Msg4 %d, rnti %x)\n", + module_idP,i,RA_template[i].generate_rar,RA_template[i].generate_Msg4,RA_template[i].wait_ack_Msg4, RA_template[i].rnti); + + if (RA_template[i].generate_rar == 1) { + *nprb= (*nprb) + 3; + *nCCE = (*nCCE) + 4; + RA_template[i].Msg3_subframe=Msg3_subframe; + } + else if (RA_template[i].generate_Msg4 == 1) { + + // check for Msg4 Message + UE_id = find_UE_id(module_idP,RA_template[i].rnti); + if (Is_rrc_registered == 1) { + + // Get RRCConnectionSetup for Piggyback + rrc_sdu_length = mac_rrc_data_req(module_idP, + frameP, + CCCH,1, + &eNB_mac_inst[module_idP].CCCH_pdu.payload[0], + 1, + module_idP, + 0); // not used in this case + if (rrc_sdu_length == -1) + mac_xface->macphy_exit("[MAC][eNB Scheduler] CCCH not allocated\n"); + else { + //msg("[MAC][eNB %d] Frame %d, subframeP %d: got %d bytes from RRC\n",module_idP,frameP, subframeP,rrc_sdu_length); + } + } + + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: UE_id %d, Is_rrc_registered %d, rrc_sdu_length %d\n", + module_idP,frameP, subframeP,UE_id, Is_rrc_registered,rrc_sdu_length); + + if (rrc_sdu_length>0) { + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: Generating Msg4 with RRC Piggyback (RA proc %d, RNTI %x)\n", + module_idP,frameP, subframeP,i,RA_template[i].rnti); + + //msg("[MAC][eNB %d][RAPROC] Frame %d, subframeP %d: Received %d bytes for Msg4: \n",module_idP,frameP,subframeP,rrc_sdu_length); + // for (j=0;j<rrc_sdu_length;j++) + // msg("%x ",(unsigned char)eNB_mac_inst[module_idP].CCCH_pdu.payload[j]); + // msg("\n"); + // msg("[MAC][eNB] Frame %d, subframeP %d: Generated DLSCH (Msg4) DCI, format 1A, for UE %d\n",frameP, subframeP,UE_id); + // Schedule Reflection of Connection request + + + + // Compute MCS for 3 PRB + msg4_header = 1+6+1; // CR header, CR CE, SDU header + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_1_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 25: + + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_5MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 50: + + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_10MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 100: + + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_20MHz_TDD_1_6_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + } + } + else { // FDD DCI + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_1_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 25: + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 50: + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_10MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_5MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + case 100: + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->ndi=1; + + if ((rrc_sdu_length+msg4_header) <= 22) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=4; + TBsize = 22; + } + else if ((rrc_sdu_length+msg4_header) <= 28) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=5; + TBsize = 28; + } + else if ((rrc_sdu_length+msg4_header) <= 32) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=6; + TBsize = 32; + } + else if ((rrc_sdu_length+msg4_header) <= 41) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=7; + TBsize = 41; + } + else if ((rrc_sdu_length+msg4_header) <= 49) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=8; + TBsize = 49; + } + else if ((rrc_sdu_length+msg4_header) <= 57) { + ((DCI1A_20MHz_FDD_t*)&RA_template[i].RA_alloc_pdu2[0])->mcs=9; + TBsize = 57; + } + break; + } + } + RA_template[i].generate_Msg4=0; + RA_template[i].generate_Msg4_dci=1; + RA_template[i].wait_ack_Msg4=1; + RA_template[i].RA_active = 0; + lcid=0; + + if ((TBsize - rrc_sdu_length - msg4_header) <= 2) { + msg4_padding = TBsize - rrc_sdu_length - msg4_header; + msg4_post_padding = 0; + } + else { + msg4_padding = 0; + msg4_post_padding = TBsize - rrc_sdu_length - msg4_header -1; + } + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d subframeP %d Msg4 : TBS %d, sdu_len %d, msg4_header %d, msg4_padding %d, msg4_post_padding %d\n", + module_idP,frameP,subframeP,TBsize,rrc_sdu_length,msg4_header,msg4_padding,msg4_post_padding); + offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[module_idP].DLSCH_pdu[(unsigned char)UE_id][0].payload[0], + 1, //num_sdus + &rrc_sdu_length, // + &lcid, // sdu_lcid + 255, // no drx + 0, // no timing advance + RA_template[i].cont_res_id, // contention res id + msg4_padding, // no padding + msg4_post_padding); + + memcpy((void*)&eNB_mac_inst[module_idP].DLSCH_pdu[(unsigned char)UE_id][0].payload[0][(unsigned char)offset], + &eNB_mac_inst[module_idP].CCCH_pdu.payload[0], + rrc_sdu_length); #if defined(USER_MODE) && defined(OAI_EMU) - if (oai_emulation.info.opt_enabled){ - trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)UE_id][0].payload[0], - rrc_sdu_length, UE_id, 3, find_UE_RNTI(Mod_id, UE_id), - eNB_mac_inst[Mod_id].subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", - Mod_id, frame, find_UE_RNTI(Mod_id,UE_id), rrc_sdu_length); - } + if (oai_emulation.info.opt_enabled){ + trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].DLSCH_pdu[(unsigned char)UE_id][0].payload[0], + rrc_sdu_length, UE_id, 3, find_UE_RNTI(module_idP, UE_id), + eNB_mac_inst[module_idP].subframe,0,0); + LOG_D(OPT,"[eNB %d][DLSCH] Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, find_UE_RNTI(module_idP,UE_id), rrc_sdu_length); + } #endif - *nprb= (*nprb) + 3; - *nCCE = (*nCCE) + 4; - } - //try here - } - /* - else if (eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4==1) { + *nprb= (*nprb) + 3; + *nCCE = (*nCCE) + 4; + } + //try here + } + /* + else if (eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4==1) { // check HARQ status and retransmit if necessary - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: Checking if Msg4 was acknowledged :\n",Mod_id,frame,subframe); + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: Checking if Msg4 was acknowledged :\n",module_idP,frameP,subframeP); // Get candidate harq_pid from PHY - mac_xface->get_ue_active_harq_pid(Mod_id,eNB_mac_inst[Mod_id].RA_template[i].rnti,subframe,&harq_pid,&round,0); + mac_xface->get_ue_active_harq_pid(module_idP,eNB_mac_inst[module_idP].RA_template[i].rnti,subframeP,&harq_pid,&round,0); if (round>0) { - *nprb= (*nprb) + 3; - *nCCE = (*nCCE) + 4; + *nprb= (*nprb) + 3; + *nCCE = (*nCCE) + 4; } } - */ - } + */ + } } } // This has to be updated to include BSR information -u8 UE_is_to_be_scheduled(u8 Mod_id,u8 UE_id) { +u8 UE_is_to_be_scheduled(module_id_t module_idP,u8 UE_id) { - // LOG_D(MAC,"[eNB %d][PUSCH] Frame %d subframe %d Scheduling UE %d\n",Mod_id,rnti,frame,subframe, + // LOG_D(MAC,"[eNB %d][PUSCH] Frame %d subframeP %d Scheduling UE %d\n",module_idP,rnti,frameP,subframeP, // UE_id); - if ((eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0]>0) || - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1]>0) || - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2]>0) || - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]>0) || - (eNB_mac_inst[Mod_id].UE_template[UE_id].ul_SR>0)) // uplink scheduling request + if ((eNB_mac_inst[module_idP].UE_template[UE_id].bsr_info[LCGID0]>0) || + (eNB_mac_inst[module_idP].UE_template[UE_id].bsr_info[LCGID1]>0) || + (eNB_mac_inst[module_idP].UE_template[UE_id].bsr_info[LCGID2]>0) || + (eNB_mac_inst[module_idP].UE_template[UE_id].bsr_info[LCGID3]>0) || + (eNB_mac_inst[module_idP].UE_template[UE_id].ul_SR>0)) // uplink scheduling request return(1); - else + else return(0); } @@ -1957,8 +1968,8 @@ u32 bytes_to_bsr_index(s32 nbytes) { return(0); while ((i<BSR_TABLE_SIZE)&& - (BSR_TABLE[i]<=nbytes)){ - i++; + (BSR_TABLE[i]<=nbytes)){ + i++; } return(i-1); } @@ -1966,54 +1977,54 @@ u32 bytes_to_bsr_index(s32 nbytes) { // This table holds the allowable PRB sizes for ULSCH transmissions u8 rb_table[33] = {1,2,3,4,5,6,8,9,10,12,15,16,18,20,24,25,27,30,32,36,40,45,48,50,54,60,72,75,80,81,90,96,100}; -void schedule_ulsch(unsigned char Mod_id,u32 frame,unsigned char cooperation_flag,unsigned char subframe,unsigned char sched_subframe,unsigned int *nCCE) {//,int calibration_flag) { +void schedule_ulsch(module_id_t module_idP, frame_t frameP,unsigned char cooperation_flag,sub_frame_t subframeP, unsigned char sched_subframe,unsigned int *nCCE) {//,int calibration_flag) { - unsigned char granted_UEs; + u8 granted_UEs; unsigned int nCCE_available; u16 first_rb=1,i; - granted_UEs = find_ulgranted_UEs(Mod_id); - nCCE_available = mac_xface->get_nCCE_max(Mod_id) - *nCCE; - + granted_UEs = find_ulgranted_UEs(module_idP); + nCCE_available = mac_xface->get_nCCE_max(module_idP) - *nCCE; + // UE data info; // check which UE has data to transmit // function to decide the scheduling // e.g. scheduling_rslt = Greedy(granted_UEs, nb_RB) // default function for default scheduling - // + // // output of scheduling, the UE numbers in RBs, where it is in the code??? - // check if RA (Msg3) is active in this subframe, if so skip the PRBs used for Msg3 + // check if RA (Msg3) is active in this subframeP, if so skip the PRBs used for Msg3 // Msg3 is using 1 PRB so we need to increase first_rb accordingly // not sure about the break (can there be more than 1 active RA procedure?) for (i=0;i<NB_RA_PROC_MAX;i++) { - if ((eNB_mac_inst[Mod_id].RA_template[i].RA_active == 1) && - (eNB_mac_inst[Mod_id].RA_template[i].generate_rar == 0) && - (eNB_mac_inst[Mod_id].RA_template[i].Msg3_subframe == sched_subframe)) { - first_rb++; - break; - } + if ((eNB_mac_inst[module_idP].RA_template[i].RA_active == 1) && + (eNB_mac_inst[module_idP].RA_template[i].generate_rar == 0) && + (eNB_mac_inst[module_idP].RA_template[i].Msg3_subframe == sched_subframe)) { + first_rb++; + break; + } } - - schedule_ulsch_rnti(Mod_id, cooperation_flag, frame, subframe, sched_subframe, granted_UEs, nCCE, &nCCE_available, &first_rb); + + schedule_ulsch_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, granted_UEs, nCCE, &nCCE_available, &first_rb); #ifdef CBA - if ((eNB_mac_inst[Mod_id].num_active_cba_groups > 0) && (*nCCE == 0)) - schedule_ulsch_cba_rnti(Mod_id, cooperation_flag, frame, subframe, sched_subframe, granted_UEs, nCCE, &nCCE_available, &first_rb); + if ((eNB_mac_inst[module_idP].num_active_cba_groups > 0) && (*nCCE == 0)) + schedule_ulsch_cba_rnti(module_idP, cooperation_flag, frameP, subframeP, sched_subframe, granted_UEs, nCCE, &nCCE_available, &first_rb); #endif - + } #ifdef CBA -void schedule_ulsch_cba_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 frame, unsigned char subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb){ +void schedule_ulsch_cba_rnti(module_id_t module_idP, unsigned char cooperation_flag, frame_t frameP, unsigned char subframeP, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb){ DCI0_5MHz_TDD_1_6_t *ULSCH_dci_tdd16; DCI0_5MHz_FDD_t *ULSCH_dci_fdd; - DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu; - + DCI_PDU *DCI_pdu= &eNB_mac_inst[module_idP].DCI_pdu; + u8 rb_table_index=0, aggregation=2; u32 rballoc; u8 cba_group, cba_resources; @@ -2022,572 +2033,583 @@ void schedule_ulsch_cba_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 fram u8 remaining_rbs= available_rbs; u8 allocated_rbs; // We compute the weight of each group and initialize some variables - for (cba_group=0;cba_group<eNB_mac_inst[Mod_id].num_active_cba_groups;cba_group++) { - // UEs in PUSCH with traffic - weight[cba_group] = find_num_active_UEs_in_cbagroup(Mod_id, cba_group); - required_rbs[cba_group] = 0; - num_cba_resources[cba_group]=0; + for (cba_group=0;cba_group<eNB_mac_inst[module_idP].num_active_cba_groups;cba_group++) { + // UEs in PUSCH with traffic + weight[cba_group] = find_num_active_UEs_in_cbagroup(module_idP, cba_group); + required_rbs[cba_group] = 0; + num_cba_resources[cba_group]=0; } //LOG_D(MAC, "[eNB ] CBA granted ues are %d\n",granted_UEs ); - for (cba_group=0;cba_group<eNB_mac_inst[Mod_id].num_active_cba_groups && (*nCCE_available > (1<<aggregation));cba_group++) { - if (remaining_rbs <= 0 ) - break; - // If the group needs some resource - if ((weight[cba_group] > 0) && eNB_mac_inst[Mod_id].cba_rnti[cba_group] != 0){ - // to be refined in case of : granted_UEs >> weight[cba_group]*available_rbs - required_rbs[cba_group] = (u8)ceil((weight[cba_group]*available_rbs)/granted_UEs); - - while (remaining_rbs < required_rbs[cba_group] ) - required_rbs[cba_group]--; - - /* + for (cba_group=0;cba_group<eNB_mac_inst[module_idP].num_active_cba_groups && (*nCCE_available > (1<<aggregation));cba_group++) { + if (remaining_rbs <= 0 ) + break; + // If the group needs some resource + if ((weight[cba_group] > 0) && eNB_mac_inst[module_idP].cba_rnti[cba_group] != 0){ + // to be refined in case of : granted_UEs >> weight[cba_group]*available_rbs + required_rbs[cba_group] = (u8)ceil((weight[cba_group]*available_rbs)/granted_UEs); + + while (remaining_rbs < required_rbs[cba_group] ) + required_rbs[cba_group]--; + + /* while (rb_table[rb_table_index] < required_rbs[cba_group]) rb_table_index++; - + while (rb_table[rb_table_index] > remaining_rbs ) rb_table_index--; - + remaining_rbs-=rb_table[rb_table_index]; required_rbs[cba_group]=rb_table[rb_table_index]; - */ - // to be refined - if (weight[cba_group] < required_rbs[cba_group]) - num_cba_resources[cba_group]=(u8)ceil(weight[cba_group]/2.0); - else - num_cba_resources[cba_group]=(u8)ceil(required_rbs[cba_group]/2.0); - - while ((*nCCE) + (1<<aggregation) * num_cba_resources[cba_group] > *nCCE_available) - num_cba_resources[cba_group]--; - - LOG_N(MAC,"[eNB %d] Frame %d, subframe %d: cba group %d weight/granted_ues %d/%d available/required rb (%d/%d), num resources %d->1 (*scaled down*) \n", - Mod_id, frame, subframe, cba_group, - weight[cba_group], granted_UEs, available_rbs,required_rbs[cba_group], - num_cba_resources[cba_group]); - - num_cba_resources[cba_group]=1; - - } - } - // phase 2 - for (cba_group=0;cba_group<eNB_mac_inst[Mod_id].num_active_cba_groups;cba_group++) { - for (cba_resources=0; cba_resources < num_cba_resources[cba_group]; cba_resources++){ - rb_table_index =0; - // check if there was an allocation for this group in the 1st phase - if (required_rbs[cba_group] == 0 ) - continue; - - while (rb_table[rb_table_index] < (u8) ceil(required_rbs[cba_group] / num_cba_resources[cba_group]) ) - rb_table_index++; + */ + // to be refined + if (weight[cba_group] < required_rbs[cba_group]) + num_cba_resources[cba_group]=(u8)ceil(weight[cba_group]/2.0); + else + num_cba_resources[cba_group]=(u8)ceil(required_rbs[cba_group]/2.0); + + while ((*nCCE) + (1<<aggregation) * num_cba_resources[cba_group] > *nCCE_available) + num_cba_resources[cba_group]--; + + LOG_N(MAC,"[eNB %d] Frame %d, subframeP %d: cba group %d weight/granted_ues %d/%d available/required rb (%d/%d), num resources %d->1 (*scaled down*) \n", + module_idP, frameP, subframeP, cba_group, + weight[cba_group], granted_UEs, available_rbs,required_rbs[cba_group], + num_cba_resources[cba_group]); + + num_cba_resources[cba_group]=1; - while (rb_table[rb_table_index] > remaining_rbs ) - rb_table_index--; - - remaining_rbs-=rb_table[rb_table_index]; - allocated_rbs=rb_table[rb_table_index]; - - rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, - *first_rb, - rb_table[rb_table_index]); - - *first_rb+=rb_table[rb_table_index]; - LOG_D(MAC,"[eNB %d] Frame %d, subframe %d: CBA %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), rballoc %d, nCCE (%d/%d)\n", - Mod_id, frame, subframe, cba_group,eNB_mac_inst[Mod_id].cba_rnti[cba_group], - available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs,rballoc, - *nCCE_available,*nCCE); - - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - ULSCH_dci_tdd16 = (DCI0_5MHz_TDD_1_6_t *)eNB_mac_inst[Mod_id].UE_template[cba_group].ULSCH_DCI[0]; - - ULSCH_dci_tdd16->type = 0; - ULSCH_dci_tdd16->hopping = 0; - ULSCH_dci_tdd16->rballoc = rballoc; - ULSCH_dci_tdd16->mcs = 2; - ULSCH_dci_tdd16->ndi = 1; - ULSCH_dci_tdd16->TPC = 1; - ULSCH_dci_tdd16->cshift = cba_group; - ULSCH_dci_tdd16->dai = eNB_mac_inst[Mod_id].UE_template[cba_group].DAI_ul[sched_subframe]; - ULSCH_dci_tdd16->cqi_req = 1; - - //add_ue_spec_dci - add_common_dci(DCI_pdu, - ULSCH_dci_tdd16, - eNB_mac_inst[Mod_id].cba_rnti[cba_group], - sizeof(DCI0_5MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_5MHz_TDD_1_6_t, - format0, - 0); } - else { - ULSCH_dci_fdd = (DCI0_5MHz_FDD_t *)eNB_mac_inst[Mod_id].UE_template[cba_group].ULSCH_DCI[0]; - - ULSCH_dci_fdd->type = 0; - ULSCH_dci_fdd->hopping = 0; - ULSCH_dci_fdd->rballoc = rballoc; - ULSCH_dci_fdd->mcs = 2; - ULSCH_dci_fdd->ndi = 1; - ULSCH_dci_fdd->TPC = 1; - ULSCH_dci_fdd->cshift = 0; - ULSCH_dci_fdd->cqi_req = 1; - - //add_ue_spec_dci - add_common_dci(DCI_pdu, - ULSCH_dci_fdd, - eNB_mac_inst[Mod_id].cba_rnti[cba_group], - sizeof(DCI0_5MHz_FDD_t), - aggregation, - sizeof_DCI0_5MHz_FDD_t, - format0, - 0); + } + // phase 2 + for (cba_group=0;cba_group<eNB_mac_inst[module_idP].num_active_cba_groups;cba_group++) { + for (cba_resources=0; cba_resources < num_cba_resources[cba_group]; cba_resources++){ + rb_table_index =0; + // check if there was an allocation for this group in the 1st phase + if (required_rbs[cba_group] == 0 ) + continue; + + while (rb_table[rb_table_index] < (u8) ceil(required_rbs[cba_group] / num_cba_resources[cba_group]) ) + rb_table_index++; + + while (rb_table[rb_table_index] > remaining_rbs ) + rb_table_index--; + + remaining_rbs-=rb_table[rb_table_index]; + allocated_rbs=rb_table[rb_table_index]; + + rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, + *first_rb, + rb_table[rb_table_index]); + + *first_rb+=rb_table[rb_table_index]; + LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d: CBA %d rnti %x, total/required/allocated/remaining rbs (%d/%d/%d/%d), rballoc %d, nCCE (%d/%d)\n", + module_idP, frameP, subframeP, cba_group,eNB_mac_inst[module_idP].cba_rnti[cba_group], + available_rbs, required_rbs[cba_group], allocated_rbs, remaining_rbs,rballoc, + *nCCE_available,*nCCE); + + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + ULSCH_dci_tdd16 = (DCI0_5MHz_TDD_1_6_t *)eNB_mac_inst[module_idP].UE_template[cba_group].ULSCH_DCI[0]; + + ULSCH_dci_tdd16->type = 0; + ULSCH_dci_tdd16->hopping = 0; + ULSCH_dci_tdd16->rballoc = rballoc; + ULSCH_dci_tdd16->mcs = 2; + ULSCH_dci_tdd16->ndi = 1; + ULSCH_dci_tdd16->TPC = 1; + ULSCH_dci_tdd16->cshift = cba_group; + ULSCH_dci_tdd16->dai = eNB_mac_inst[module_idP].UE_template[cba_group].DAI_ul[sched_subframe]; + ULSCH_dci_tdd16->cqi_req = 1; + + //add_ue_spec_dci + add_common_dci(DCI_pdu, + ULSCH_dci_tdd16, + eNB_mac_inst[module_idP].cba_rnti[cba_group], + sizeof(DCI0_5MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_5MHz_TDD_1_6_t, + format0, + 0); + } + else { + ULSCH_dci_fdd = (DCI0_5MHz_FDD_t *)eNB_mac_inst[module_idP].UE_template[cba_group].ULSCH_DCI[0]; + + ULSCH_dci_fdd->type = 0; + ULSCH_dci_fdd->hopping = 0; + ULSCH_dci_fdd->rballoc = rballoc; + ULSCH_dci_fdd->mcs = 2; + ULSCH_dci_fdd->ndi = 1; + ULSCH_dci_fdd->TPC = 1; + ULSCH_dci_fdd->cshift = 0; + ULSCH_dci_fdd->cqi_req = 1; + + //add_ue_spec_dci + add_common_dci(DCI_pdu, + ULSCH_dci_fdd, + eNB_mac_inst[module_idP].cba_rnti[cba_group], + sizeof(DCI0_5MHz_FDD_t), + aggregation, + sizeof_DCI0_5MHz_FDD_t, + format0, + 0); + } + *nCCE = (*nCCE) + (1<<aggregation) * num_cba_resources[cba_group]; + *nCCE_available = mac_xface->get_nCCE_max(module_idP) - *nCCE; + // break;// for the moment only schedule one } - *nCCE = (*nCCE) + (1<<aggregation) * num_cba_resources[cba_group]; - *nCCE_available = mac_xface->get_nCCE_max(Mod_id) - *nCCE; - // break;// for the moment only schedule one - } - } + } } -#endif -void schedule_ulsch_rnti(u8 Mod_id, unsigned char cooperation_flag, u32 frame, unsigned char subframe, unsigned char sched_subframe, u8 granted_UEs, unsigned int *nCCE, unsigned int *nCCE_available, u16 *first_rb){ - unsigned char UE_id; - unsigned char next_ue; - unsigned char aggregation=2; - u16 rnti; - u8 round = 0; - u8 harq_pid = 0; - void *ULSCH_dci; - - LTE_eNB_UE_stats* eNB_UE_stats; - DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu; - u8 status=0;//,status0 = 0,status1 = 0; - // u8 k=0; - u8 rb_table_index; - u16 TBS,i; - u32 buffer_occupancy; - u32 tmp_bsr; - u32 cqi_req,cshift,ndi,mcs,rballoc; - - for (UE_id=0;UE_id<granted_UEs && (*nCCE_available > (1<<aggregation));UE_id++) { - - // msg("[MAC][eNB] subframe %d: checking UE_id %d\n",subframe,UE_id); - next_ue = UE_id; // find next ue to schedule - // msg("[MAC][eNB] subframe %d: next ue %d\n",subframe,next_ue); - rnti = find_UE_RNTI(Mod_id,next_ue); // radio network temp id is obtained - // msg("[MAC][eNB] subframe %d: rnti %x\n",subframe,rnti); - - if (rnti==0) // if so, go to next UE - continue; - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,rnti); - if (eNB_UE_stats==NULL) - mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - - LOG_I(MAC,"[eNB %d] Scheduler Frame %d, subframe %d, nCCE %d: Checking ULSCH next UE_id %d mode id %d (rnti %x,mode %s), format 0\n",Mod_id,frame,subframe,*nCCE,next_ue,Mod_id, rnti,mode_string[eNB_UE_stats->mode]); - - if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel - s8 ret; - // Get candidate harq_pid from PHY - ret = mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,1); - LOG_I(MAC,"Got harq_pid %d, round %d, next_ue %d\n",harq_pid,round,next_ue); - - /* [SR] 01/07/13: Don't schedule UE if we cannot get harq pid */ +#endif +void schedule_ulsch_rnti(module_id_t module_idP, + unsigned char cooperation_flag, + frame_t frameP, + sub_frame_t subframeP, + unsigned char sched_subframe, + u8 granted_UEs, + unsigned int *nCCE, + unsigned int *nCCE_available, + u16 *first_rb){ + module_id_t ue_mod_id = -1; + module_id_t next_ue = -1; + unsigned char aggregation = 2; + rnti_t rnti = -1; + u8 round = 0; + u8 harq_pid = 0; + void *ULSCH_dci = NULL; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].DCI_pdu; + u8 status = 0; + u8 rb_table_index = -1; + u16 TBS,i; + u32 buffer_occupancy; + u32 tmp_bsr; + u32 cqi_req,cshift,ndi,mcs,rballoc; + + for (ue_mod_id=0;ue_mod_id<granted_UEs && (*nCCE_available > (1<<aggregation));ue_mod_id++) { + + // msg("[MAC][eNB] subframeP %d: checking UE_id %d\n",subframeP,UE_id); + next_ue = ue_mod_id; // find next ue to schedule + // msg("[MAC][eNB] subframeP %d: next ue %d\n",subframeP,next_ue); + rnti = find_UE_RNTI(module_idP,next_ue); // radio network temp id is obtained + // msg("[MAC][eNB] subframeP %d: rnti %x\n",subframeP,rnti); + + if (rnti==0) // if so, go to next UE + continue; + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,rnti); + if (eNB_UE_stats==NULL) + mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + + LOG_I(MAC,"[eNB %d] Scheduler Frame %d, subframeP %d, nCCE %d: Checking ULSCH next UE_id %d mode id %d (rnti %x,mode %s), format 0\n", + module_idP,frameP,subframeP,*nCCE,next_ue,module_idP, rnti,mode_string[eNB_UE_stats->mode]); + + if (eNB_UE_stats->mode == PUSCH) { // ue has a ulsch channel + s8 ret; + // Get candidate harq_pid from PHY + ret = mac_xface->get_ue_active_harq_pid(module_idP,rnti,subframeP,&harq_pid,&round,1); + LOG_I(MAC,"Got harq_pid %d, round %d, next_ue %d\n",harq_pid,round,next_ue); + + /* [SR] 01/07/13: Don't schedule UE if we cannot get harq pid */ #ifndef EXMIMO_IOT - if ((((UE_is_to_be_scheduled(Mod_id,UE_id)>0)) || (round>0) || ((frame%10)==0)) && (ret == 0)) - // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames + if ((((UE_is_to_be_scheduled(module_idP,ue_mod_id)>0)) || (round>0) || ((frameP%10)==0)) && (ret == 0)) + // if there is information on bsr of DCCH, DTCH or if there is UL_SR, or if there is a packet to retransmit, or we want to schedule a periodic feedback every 10 frames #else - if (round==0) + if (round==0) #endif - { - LOG_D(MAC,"[eNB %d][PUSCH %x] Frame %d subframe %d Scheduling UE %d (SR %d)\n", - Mod_id,rnti,frame,subframe,UE_id, - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_SR); - - // reset the scheduling request - eNB_mac_inst[Mod_id].UE_template[UE_id].ul_SR = 0; + { + LOG_D(MAC,"[eNB %d][PUSCH %x] Frame %d subframeP %d Scheduling UE %d (SR %d)\n", + module_idP,rnti,frameP,subframeP,ue_mod_id, + eNB_mac_inst[module_idP].UE_template[ue_mod_id].ul_SR); - aggregation = process_ue_cqi(Mod_id,next_ue); // =2 by default!! - // msg("[MAC][eNB] subframe %d: aggregation %d\n",subframe,aggregation); + // reset the scheduling request + eNB_mac_inst[module_idP].UE_template[ue_mod_id].ul_SR = 0; - status = mac_get_rrc_status(Mod_id,1,next_ue); + aggregation = process_ue_cqi(module_idP,next_ue); // =2 by default!! + // msg("[MAC][eNB] subframeP %d: aggregation %d\n",subframeP,aggregation); + + status = mac_get_rrc_status(module_idP,1,next_ue); #ifndef EXMIMO_IOT - if (status < RRC_CONNECTED) - cqi_req = 0; - else - cqi_req = 1; + if (status < RRC_CONNECTED) + cqi_req = 0; + else + cqi_req = 1; #else - cqi_req = 0; + cqi_req = 0; #endif - - if (round > 0) { - ndi = eNB_mac_inst[Mod_id].UE_template[UE_id].oldNDI_UL[harq_pid]; - mcs = (round&3) + 28; //not correct for round==4! - } - else { - ndi = 1-eNB_mac_inst[Mod_id].UE_template[UE_id].oldNDI_UL[harq_pid]; - eNB_mac_inst[Mod_id].UE_template[UE_id].oldNDI_UL[harq_pid]=ndi; - mcs = openair_daq_vars.target_ue_ul_mcs; - } - - LOG_D(MAC,"[eNB %d] ULSCH scheduler: Ndi %d, mcs %d\n",Mod_id,ndi,mcs); - if((cooperation_flag > 0) && (next_ue == 1)) { // Allocation on same set of RBs - // RIV:resource indication value // function in openair1/PHY/LTE_TRANSPORT/dci_tools.c - rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, - ((next_ue-1)*4),//openair_daq_vars.ue_ul_nb_rb), - 4);//openair_daq_vars.ue_ul_nb_rb); - } - else if ((round==0) && (mcs < 29)) { - rb_table_index = 1; - TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - buffer_occupancy = ((eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] == 0) && - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] == 0) && - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] == 0) && - (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] == 0))? - BSR_TABLE[10] : // This is when we've received SR and buffers are fully served - BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0]]+ - BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1]]+ - BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2]]+ - BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]]; // This is when remaining data in UE buffers (even if SR is triggered) - - LOG_D(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframe %d Scheduled UE, BSR for LCGID0 %d, LCGID1 %d, LCGID2 %d LCGID3 %d, BO %d\n", - Mod_id,UE_id,rnti,frame,subframe, - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2], - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3], - buffer_occupancy); - - while ((TBS < buffer_occupancy) && - rb_table[rb_table_index]<(mac_xface->lte_frame_parms->N_RB_UL-1-*first_rb)){ - // continue until we've exhauster the UEs request or the total number of available PRBs - /* LOG_I(MAC,"[eNB %d][PUSCH %x] Frame %d subframe %d Scheduled UE (rb_table_index %d => TBS %d)\n", - Mod_id,rnti,frame,subframe, + if (round > 0) { + ndi = eNB_mac_inst[module_idP].UE_template[ue_mod_id].oldNDI_UL[harq_pid]; + mcs = (round&3) + 28; //not correct for round==4! + } + else { + ndi = 1-eNB_mac_inst[module_idP].UE_template[ue_mod_id].oldNDI_UL[harq_pid]; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].oldNDI_UL[harq_pid]=ndi; + mcs = openair_daq_vars.target_ue_ul_mcs; + } + + LOG_D(MAC,"[eNB %d] ULSCH scheduler: Ndi %d, mcs %d\n",module_idP,ndi,mcs); + + if((cooperation_flag > 0) && (next_ue == 1)) { // Allocation on same set of RBs + // RIV:resource indication value // function in openair1/PHY/LTE_TRANSPORT/dci_tools.c + rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, + ((next_ue-1)*4),//openair_daq_vars.ue_ul_nb_rb), + 4);//openair_daq_vars.ue_ul_nb_rb); + } + else if ((round==0) && (mcs < 29)) { + rb_table_index = 1; + TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + buffer_occupancy = ((eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0] == 0) && + (eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1] == 0) && + (eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2] == 0) && + (eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3] == 0))? + BSR_TABLE[10] : // This is when we've received SR and buffers are fully served + BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0]]+ + BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1]]+ + BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2]]+ + BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3]]; // This is when remaining data in UE buffers (even if SR is triggered) + + LOG_D(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE, BSR for LCGID0 %d, LCGID1 %d, LCGID2 %d LCGID3 %d, BO %d\n", + module_idP, + ue_mod_id, + rnti, + frameP, + subframeP, + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0], + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1], + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2], + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3], + buffer_occupancy); + + while ((TBS < buffer_occupancy) && + rb_table[rb_table_index]<(mac_xface->lte_frame_parms->N_RB_UL-1-*first_rb)){ + // continue until we've exhauster the UEs request or the total number of available PRBs + /* LOG_I(MAC,"[eNB %d][PUSCH %x] Frame %d subframeP %d Scheduled UE (rb_table_index %d => TBS %d)\n", + module_idP,rnti,frameP,subframeP, rb_table_index,TBS); - */ - rb_table_index++; - TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - } - - if (rb_table[rb_table_index]>(mac_xface->lte_frame_parms->N_RB_UL-1-*first_rb)) { - rb_table_index--; - TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - } - //rb_table_index = 8; - - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframe %d Scheduled UE (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", - Mod_id,UE_id,rnti,frame,subframe,mcs, - *first_rb,rb_table[rb_table_index], - rb_table_index,mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]), - harq_pid); - - rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, - *first_rb, - rb_table[rb_table_index]);//openair_daq_vars.ue_ul_nb_rb); - - *first_rb+=rb_table[rb_table_index]; // increment for next UE allocation - eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb_ul[harq_pid] = rb_table[rb_table_index]; //store for possible retransmission - - buffer_occupancy -= mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); - i = bytes_to_bsr_index((s32)buffer_occupancy); - - // Adjust BSR entries for LCGIDs - if (i>0) { - if (eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] <= i) { - tmp_bsr = BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0]]; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] = 0; - if (BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1]] <= (buffer_occupancy-tmp_bsr)) { - tmp_bsr += BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1]]; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] = 0; - if (BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2]] <= (buffer_occupancy-tmp_bsr)) { - tmp_bsr += BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2]]; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] = 0; - if (BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]] <= (buffer_occupancy-tmp_bsr)) { - tmp_bsr += BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]]; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] = 0; - } else { - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3]] - ((s32)buffer_occupancy - (s32)tmp_bsr)); - } - } - else { - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2]] - ((s32)buffer_occupancy -(s32)tmp_bsr)); - } - } - else { - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1]] - (s32)buffer_occupancy); - } - } - else { - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0]] - (s32)buffer_occupancy); - } - } - else { // we have flushed all buffers so clear bsr - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID0] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID1] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID2] = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].bsr_info[LCGID3] = 0; - } - - - } // ndi==1 - else { //we schedule a retransmission - LOG_I(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframe %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, TBS %d, harq_pid %d)\n", - Mod_id,UE_id,rnti,frame,subframe,mcs, - *first_rb,eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb_ul[harq_pid], - mac_xface->get_TBS_UL(mcs,eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb_ul[harq_pid]), - harq_pid); - - rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, - *first_rb, - eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb_ul[harq_pid]); - - *first_rb+=eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb_ul[harq_pid]; // increment for next UE allocation - } - - // Cyclic shift for DM RS - if(cooperation_flag == 2) { - if(next_ue == 1)// For Distriibuted Alamouti, cyclic shift applied to 2nd UE - cshift = 1; - else - cshift = 0; - } - else - cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_UL) { - case 6: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[sched_subframe]; - ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_1_5MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_1_5MHz_TDD_1_6_t, - format0, - 0); - break; - default: - case 25: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[sched_subframe]; - ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_5MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_5MHz_TDD_1_6_t, - format0, - 0); - break; - case 50: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[sched_subframe]; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_10MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_10MHz_TDD_1_6_t, - format0, - 0); - break; - case 100: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[sched_subframe]; - ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_20MHz_TDD_1_6_t), - aggregation, - sizeof_DCI0_20MHz_TDD_1_6_t, - format0, - 0); - break; - } - } - else { //FDD - switch (mac_xface->lte_frame_parms->N_RB_UL) { - case 25: - default: - - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = 1; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_5MHz_FDD_t), - aggregation, - sizeof_DCI0_5MHz_FDD_t, - format0, - 0); - break; - case 6: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->TPC = 1; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_1_5MHz_FDD_t), - aggregation, - sizeof_DCI0_1_5MHz_FDD_t, - format0, - 0); - break; - case 50: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = 1; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_10MHz_FDD_t), - aggregation, - sizeof_DCI0_10MHz_FDD_t, - format0, - 0); - break; - case 100: - ULSCH_dci = eNB_mac_inst[Mod_id].UE_template[next_ue].ULSCH_DCI[harq_pid]; - - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->type = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->hopping = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->mcs = mcs; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->ndi = ndi; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->TPC = 1; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->padding = 0; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cshift = cshift; - ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; - - add_ue_spec_dci(DCI_pdu, - ULSCH_dci, - rnti, - sizeof(DCI0_20MHz_FDD_t), - aggregation, - sizeof_DCI0_20MHz_FDD_t, - format0, - 0); - break; - - } - } - //#ifdef DEBUG_eNB_SCHEDULER - // dump_dci(mac_xface->lte_frame_parms, - // &DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci-1]); - //#endif - add_ue_ulsch_info(Mod_id, - next_ue, - subframe, - S_UL_SCHEDULED); - - *nCCE = (*nCCE) + (1<<aggregation); - *nCCE_available = mac_xface->get_nCCE_max(Mod_id) - *nCCE; - //msg("[MAC][eNB %d][ULSCH Scheduler] Frame %d, subframe %d: Generated ULSCH DCI for next UE_id %d, format 0\n", Mod_id,frame,subframe,next_ue); - - //break; // leave loop after first UE is schedule (avoids m - } // UE_is_to_be_scheduled - } // UE is in PUSCH + */ + rb_table_index++; + TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + } + + if (rb_table[rb_table_index]>(mac_xface->lte_frame_parms->N_RB_UL-1-*first_rb)) { + rb_table_index--; + TBS = mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + } + //rb_table_index = 8; + + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE (mcs %d, first rb %d, nb_rb %d, rb_table_index %d, TBS %d, harq_pid %d)\n", + module_idP,ue_mod_id,rnti,frameP,subframeP,mcs, + *first_rb,rb_table[rb_table_index], + rb_table_index,mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]), + harq_pid); + + rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, + *first_rb, + rb_table[rb_table_index]);//openair_daq_vars.ue_ul_nb_rb); + + *first_rb+=rb_table[rb_table_index]; // increment for next UE allocation + eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb_ul[harq_pid] = rb_table[rb_table_index]; //store for possible retransmission + + buffer_occupancy -= mac_xface->get_TBS_UL(mcs,rb_table[rb_table_index]); + i = bytes_to_bsr_index((s32)buffer_occupancy); + + // Adjust BSR entries for LCGIDs + if (i>0) { + if (eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0] <= i) { + tmp_bsr = BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0]]; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0] = 0; + if (BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1]] <= (buffer_occupancy-tmp_bsr)) { + tmp_bsr += BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1]]; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1] = 0; + if (BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2]] <= (buffer_occupancy-tmp_bsr)) { + tmp_bsr += BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2]]; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2] = 0; + if (BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3]] <= (buffer_occupancy-tmp_bsr)) { + tmp_bsr += BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3]]; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3] = 0; + } else { + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3]] - ((s32)buffer_occupancy - (s32)tmp_bsr)); + } + } + else { + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2]] - ((s32)buffer_occupancy -(s32)tmp_bsr)); + } + } + else { + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1]] - (s32)buffer_occupancy); + } + } + else { + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0] = bytes_to_bsr_index((s32)BSR_TABLE[eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0]] - (s32)buffer_occupancy); + } + } + else { // we have flushed all buffers so clear bsr + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID0] = 0; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID1] = 0; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID2] = 0; + eNB_mac_inst[module_idP].UE_template[ue_mod_id].bsr_info[LCGID3] = 0; + } + + + } // ndi==1 + else { //we schedule a retransmission + LOG_I(MAC,"[eNB %d][PUSCH %d/%x] Frame %d subframeP %d Scheduled UE retransmission (mcs %d, first rb %d, nb_rb %d, TBS %d, harq_pid %d)\n", + module_idP,ue_mod_id,rnti,frameP,subframeP,mcs, + *first_rb,eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb_ul[harq_pid], + mac_xface->get_TBS_UL(mcs,eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb_ul[harq_pid]), + harq_pid); + + rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL, + *first_rb, + eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb_ul[harq_pid]); + + *first_rb+=eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb_ul[harq_pid]; // increment for next UE allocation + } + + // Cyclic shift for DM RS + if(cooperation_flag == 2) { + if(next_ue == 1)// For Distriibuted Alamouti, cyclic shift applied to 2nd UE + cshift = 1; + else + cshift = 0; + } + else + cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_UL) { + case 6: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[sched_subframe]; + ((DCI0_1_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_1_5MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_1_5MHz_TDD_1_6_t, + format0, + 0); + break; + default: + case 25: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[sched_subframe]; + ((DCI0_5MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_5MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_5MHz_TDD_1_6_t, + format0, + 0); + break; + case 50: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[sched_subframe]; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_10MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_10MHz_TDD_1_6_t, + format0, + 0); + break; + case 100: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->type = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->hopping = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->TPC = 1; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_10MHz_TDD_1_6_t *)ULSCH_dci)->padding = 0; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->dai = eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[sched_subframe]; + ((DCI0_20MHz_TDD_1_6_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_20MHz_TDD_1_6_t), + aggregation, + sizeof_DCI0_20MHz_TDD_1_6_t, + format0, + 0); + break; + } + } + else { //FDD + switch (mac_xface->lte_frame_parms->N_RB_UL) { + case 25: + default: + + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->TPC = 1; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_5MHz_FDD_t), + aggregation, + sizeof_DCI0_5MHz_FDD_t, + format0, + 0); + break; + case 6: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->TPC = 1; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_1_5MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_1_5MHz_FDD_t), + aggregation, + sizeof_DCI0_1_5MHz_FDD_t, + format0, + 0); + break; + case 50: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->TPC = 1; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_10MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_10MHz_FDD_t), + aggregation, + sizeof_DCI0_10MHz_FDD_t, + format0, + 0); + break; + case 100: + ULSCH_dci = eNB_mac_inst[module_idP].UE_template[next_ue].ULSCH_DCI[harq_pid]; + + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->type = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->hopping = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->rballoc = rballoc; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->mcs = mcs; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->ndi = ndi; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->TPC = 1; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->padding = 0; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cshift = cshift; + ((DCI0_20MHz_FDD_t *)ULSCH_dci)->cqi_req = cqi_req; + + add_ue_spec_dci(DCI_pdu, + ULSCH_dci, + rnti, + sizeof(DCI0_20MHz_FDD_t), + aggregation, + sizeof_DCI0_20MHz_FDD_t, + format0, + 0); + break; + + } + } + //#ifdef DEBUG_eNB_SCHEDULER + // dump_dci(mac_xface->lte_frame_parms, + // &DCI_pdu->dci_alloc[DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci-1]); + //#endif + add_ue_ulsch_info(module_idP, + next_ue, + subframeP, + S_UL_SCHEDULED); + + *nCCE = (*nCCE) + (1<<aggregation); + *nCCE_available = mac_xface->get_nCCE_max(module_idP) - *nCCE; + //msg("[MAC][eNB %d][ULSCH Scheduler] Frame %d, subframeP %d: Generated ULSCH DCI for next UE_id %d, format 0\n", module_idP,frameP,subframeP,next_ue); + + //break; // leave loop after first UE is schedule (avoids m + } // UE_is_to_be_scheduled + } // UE is in PUSCH } // loop over UE_id } -u32 allocate_prbs(unsigned char UE_id,unsigned char nb_rb, u32 *rballoc) { +u32 allocate_prbs(module_id_t ue_mod_idP,unsigned char nb_rb, u32 *rballoc) { int i; u32 rballoc_dci=0; unsigned char nb_rb_alloc=0; for (i=0;i<(mac_xface->lte_frame_parms->N_RB_DL-2);i+=2) { - if (((*rballoc>>i)&3)==0) { - *rballoc |= (3<<i); - rballoc_dci |= (1<<((12-i)>>1)); - nb_rb_alloc+=2; - } - if (nb_rb_alloc==nb_rb) - return(rballoc_dci); + if (((*rballoc>>i)&3)==0) { + *rballoc |= (3<<i); + rballoc_dci |= (1<<((12-i)>>1)); + nb_rb_alloc+=2; + } + if (nb_rb_alloc==nb_rb) + return(rballoc_dci); } if ((mac_xface->lte_frame_parms->N_RB_DL&1)==1) { - if ((*rballoc>>(mac_xface->lte_frame_parms->N_RB_DL-1)&1)==0) { - *rballoc |= (1<<(mac_xface->lte_frame_parms->N_RB_DL-1)); - rballoc_dci |= 1;//(1<<(mac_xface->lte_frame_parms->N_RB_DL>>1)); - } + if ((*rballoc>>(mac_xface->lte_frame_parms->N_RB_DL-1)&1)==0) { + *rballoc |= (1<<(mac_xface->lte_frame_parms->N_RB_DL-1)); + rballoc_dci |= 1;//(1<<(mac_xface->lte_frame_parms->N_RB_DL>>1)); + } } return(rballoc_dci); } @@ -2600,34 +2622,34 @@ u32 allocate_prbs_sub(int nb_rb, u8 *rballoc) { //u8 number_of_subbands=13; LOG_D(MAC,"*****Check1RBALLOC****: %d%d%d%d (nb_rb %d,N_RBGS %d)\n", - rballoc[3],rballoc[2],rballoc[1],rballoc[0],nb_rb,mac_xface->lte_frame_parms->N_RBGS); + rballoc[3],rballoc[2],rballoc[1],rballoc[0],nb_rb,mac_xface->lte_frame_parms->N_RBGS); while((nb_rb >0) && (check < mac_xface->lte_frame_parms->N_RBGS)){ - //printf("rballoc[%d] %d\n",check,rballoc[check]); - if(rballoc[check] == 1){ - rballoc_dci |= (1<<((mac_xface->lte_frame_parms->N_RBGS-1)-check)); - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - nb_rb--; - case 25: - if ((check == mac_xface->lte_frame_parms->N_RBGS-1)) - nb_rb--; - else - nb_rb-=2; - break; - case 50: - if ((check == mac_xface->lte_frame_parms->N_RBGS-1)) - nb_rb-=2; - else - nb_rb-=3; - break; - case 100: - nb_rb-=4; - break; + //printf("rballoc[%d] %d\n",check,rballoc[check]); + if(rballoc[check] == 1){ + rballoc_dci |= (1<<((mac_xface->lte_frame_parms->N_RBGS-1)-check)); + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + nb_rb--; + case 25: + if ((check == mac_xface->lte_frame_parms->N_RBGS-1)) + nb_rb--; + else + nb_rb-=2; + break; + case 50: + if ((check == mac_xface->lte_frame_parms->N_RBGS-1)) + nb_rb-=2; + else + nb_rb-=3; + break; + case 100: + nb_rb-=4; + break; + } } - } - //printf("rb_alloc %x\n",rballoc_dci); - check = check+1; - // check1 = check1+2; + //printf("rb_alloc %x\n",rballoc_dci); + check = check+1; + // check1 = check1+2; } // rballoc_dci = (rballoc_dci)&(0x1fff); LOG_D(MAC,"*********RBALLOC : %x\n",rballoc_dci); @@ -2636,26 +2658,24 @@ u32 allocate_prbs_sub(int nb_rb, u8 *rballoc) { } -void fill_DLSCH_dci(unsigned char Mod_id,u32 frame, unsigned char subframe,u32 RBalloc,u8 RA_scheduled,int mbsfn_flag) { +void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP,u32 RBalloc,u8 RA_scheduled,int mbsfn_flag) { // loop over all allocated UEs and compute frequency allocations for PDSCH - unsigned char UE_id,first_rb,nb_rb=3; - u16 rnti; + module_id_t ue_mod_id = -1; + u8 first_rb,nb_rb=3; + rnti_t rnti; unsigned char vrb_map[100]; - u8 rballoc_sub[mac_xface->lte_frame_parms->N_RBGS]; + u8 rballoc_sub[mac_xface->lte_frame_parms->N_RBGS]; //u8 number_of_subbands=13; - u32 rballoc=RBalloc; + u32 rballoc = RBalloc; - // u32 test=0; unsigned char round; unsigned char harq_pid; - void *DLSCH_dci=NULL; - DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu; - int i; - // u8 status=0; - - void *BCCH_alloc_pdu=(void*)&eNB_mac_inst[Mod_id].BCCH_alloc_pdu; - int size_bits,size_bytes; + void *DLSCH_dci=NULL; + DCI_PDU *DCI_pdu= &eNB_mac_inst[module_idP].DCI_pdu; + int i; + void *BCCH_alloc_pdu=(void*)&eNB_mac_inst[module_idP].BCCH_alloc_pdu; + int size_bits,size_bytes; if (mbsfn_flag>0) return; @@ -2665,668 +2685,668 @@ void fill_DLSCH_dci(unsigned char Mod_id,u32 frame, unsigned char subframe,u32 R // SI DLSCH // printf("BCCH check\n"); - if (eNB_mac_inst[Mod_id].bcch_active == 1) { - eNB_mac_inst[Mod_id].bcch_active = 0; - LOG_D(MAC,"[eNB %d] Frame %d subframe %d: BCCH active\n", Mod_id, frame, subframe); - // randomize frequency allocation for SI - first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); - if (mac_xface->lte_frame_parms->frame_type == TDD) { + if (eNB_mac_inst[module_idP].bcch_active == 1) { + eNB_mac_inst[module_idP].bcch_active = 0; + LOG_D(MAC,"[eNB %d] Frame %d subframeP %d: BCCH active\n", module_idP, frameP, subframeP); + // randomize frequency allocation for SI + first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); + if (mac_xface->lte_frame_parms->frame_type == TDD) { - } - else { - BCCH_alloc_pdu_fdd.rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(BCCH_alloc_pdu_fdd.vrb_type,BCCH_alloc_pdu_fdd.rballoc); - } - - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; + } + else { + BCCH_alloc_pdu_fdd.rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(BCCH_alloc_pdu_fdd.vrb_type,BCCH_alloc_pdu_fdd.rballoc); + } - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; - rballoc |= mac_xface->get_rballoc(0,((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_1_5MHz_TDD_1_6_t), - 2, - sizeof_DCI1A_1_5MHz_TDD_1_6_t, - format1A,0); - break; - case 25: - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; - rballoc |= mac_xface->get_rballoc(0,((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_5MHz_TDD_1_6_t), - 2, - sizeof_DCI1A_5MHz_TDD_1_6_t, - format1A,0); - break; - case 50: - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; - rballoc |= mac_xface->get_rballoc(0,((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_10MHz_TDD_1_6_t), - 2, - sizeof_DCI1A_10MHz_TDD_1_6_t, - format1A,0); - break; - case 100: - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; - rballoc |= mac_xface->get_rballoc(0,((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_20MHz_TDD_1_6_t), - 2, - sizeof_DCI1A_20MHz_TDD_1_6_t, - format1A,0); - break; + vrb_map[first_rb] = 1; + vrb_map[first_rb+1] = 1; + vrb_map[first_rb+2] = 1; + vrb_map[first_rb+3] = 1; + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; + rballoc |= mac_xface->get_rballoc(0,((DCI1A_1_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_1_5MHz_TDD_1_6_t), + 2, + sizeof_DCI1A_1_5MHz_TDD_1_6_t, + format1A,0); + break; + case 25: + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; + rballoc |= mac_xface->get_rballoc(0,((DCI1A_5MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_5MHz_TDD_1_6_t), + 2, + sizeof_DCI1A_5MHz_TDD_1_6_t, + format1A,0); + break; + case 50: + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; + rballoc |= mac_xface->get_rballoc(0,((DCI1A_10MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_10MHz_TDD_1_6_t), + 2, + sizeof_DCI1A_10MHz_TDD_1_6_t, + format1A,0); + break; + case 100: + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->padding = 0; + rballoc |= mac_xface->get_rballoc(0,((DCI1A_20MHz_TDD_1_6_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_20MHz_TDD_1_6_t), + 2, + sizeof_DCI1A_20MHz_TDD_1_6_t, + format1A,0); + break; + } } - } - else { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; - - rballoc |= mac_xface->get_rballoc(0,((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_1_5MHz_FDD_t), - 2, - sizeof_DCI1A_1_5MHz_FDD_t, - format1A,0); - break; - case 25: - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; - - rballoc |= mac_xface->get_rballoc(0,((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_5MHz_FDD_t), - 2, - sizeof_DCI1A_5MHz_FDD_t, - format1A,0); - break; - case 50: - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; - - rballoc |= mac_xface->get_rballoc(0,((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_10MHz_FDD_t), - 2, - sizeof_DCI1A_10MHz_FDD_t, - format1A,0); - break; - case 100: - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; - ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; - - rballoc |= mac_xface->get_rballoc(0,((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); - add_common_dci(DCI_pdu, - BCCH_alloc_pdu, - SI_RNTI, - sizeof(DCI1A_20MHz_FDD_t), - 2, - sizeof_DCI1A_20MHz_FDD_t, - format1A,0); - break; + else { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; + + rballoc |= mac_xface->get_rballoc(0,((DCI1A_1_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_1_5MHz_FDD_t), + 2, + sizeof_DCI1A_1_5MHz_FDD_t, + format1A,0); + break; + case 25: + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; + + rballoc |= mac_xface->get_rballoc(0,((DCI1A_5MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_5MHz_FDD_t), + 2, + sizeof_DCI1A_5MHz_FDD_t, + format1A,0); + break; + case 50: + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; + + rballoc |= mac_xface->get_rballoc(0,((DCI1A_10MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_10MHz_FDD_t), + 2, + sizeof_DCI1A_10MHz_FDD_t, + format1A,0); + break; + case 100: + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->type = 1; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->vrb_type = 0; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->ndi = 1; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rv = 1; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->harq_pid = 0; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->TPC = 1; + ((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->padding = 0; + + rballoc |= mac_xface->get_rballoc(0,((DCI1A_20MHz_FDD_t*)BCCH_alloc_pdu)->rballoc); + add_common_dci(DCI_pdu, + BCCH_alloc_pdu, + SI_RNTI, + sizeof(DCI1A_20MHz_FDD_t), + 2, + sizeof_DCI1A_20MHz_FDD_t, + format1A,0); + break; + } } - } } if (RA_scheduled == 1) { - for (i=0;i<NB_RA_PROC_MAX;i++) { - - if (eNB_mac_inst[Mod_id].RA_template[i].generate_rar == 1) { - - //FK: postponed to fill_rar - //eNB_mac_inst[Mod_id].RA_template[i].generate_rar = 0; - - LOG_D(MAC,"[eNB %d] Frame %d, subframe %d: Generating RAR DCI (proc %d), RA_active %d format 1A (%d,%d))\n", - Mod_id,frame, subframe,i, - eNB_mac_inst[Mod_id].RA_template[i].RA_active, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_fmt1, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bits1); - // randomize frequency allocation for RA - while (1) { - first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); - if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) - break; - } - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch(mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 25: - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 50: - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 100: - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - default: - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - } - } - else { - switch(mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 25: - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 50: - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - case 100: - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->type=1; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->ndi=1; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rv=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->mcs=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->TPC=1; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->padding=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->vrb_type, - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0])->rballoc); - break; - default: - break; - } - } - add_common_dci(DCI_pdu, - (void*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu1[0], - eNB_mac_inst[Mod_id].RA_template[i].RA_rnti, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bytes1, - 2, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bits1, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_fmt1, - 1); - - - - LOG_D(MAC,"[eNB %d] Frame %d: Adding common dci for RA%d (RAR) RA_active %d\n",Mod_id,frame,i, - eNB_mac_inst[Mod_id].RA_template[i].RA_active); - } - if (eNB_mac_inst[Mod_id].RA_template[i].generate_Msg4_dci == 1) { - - // randomize frequency allocation for RA - while (1) { - first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); - if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) - break; - } - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 25: - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 50: - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 100: - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - default: - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - } - } - else { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - - case 6: - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 25: - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 50: - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - case 100: - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->padding=0; - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - default: - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->type=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rv=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->TPC=1; - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - break; - } - } - - add_ue_spec_dci(DCI_pdu, - (void*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0], - eNB_mac_inst[Mod_id].RA_template[i].rnti, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bytes2, - 1, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bits2, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_fmt2, - 0); - LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: Adding ue specific dci (rnti %x) for Msg4\n", - Mod_id,frame,subframe,eNB_mac_inst[Mod_id].RA_template[i].rnti); - eNB_mac_inst[Mod_id].RA_template[i].generate_Msg4_dci=0; - - } - else if (eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4==1) { - // check HARQ status and retransmit if necessary - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: Checking if Msg4 was acknowledged: \n", - Mod_id,frame,subframe); - // Get candidate harq_pid from PHY - mac_xface->get_ue_active_harq_pid(Mod_id,eNB_mac_inst[Mod_id].RA_template[i].rnti,subframe,&harq_pid,&round,0); - if (round>0) { - // we have to schedule a retransmission - if (mac_xface->lte_frame_parms->frame_type == TDD) - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->ndi=1; - else - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->ndi=1; - // randomize frequency allocation for RA - while (1) { - first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); - if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) - break; - } - vrb_map[first_rb] = 1; - vrb_map[first_rb+1] = 1; - vrb_map[first_rb+2] = 1; - vrb_map[first_rb+3] = 1; - if (mac_xface->lte_frame_parms->frame_type == TDD) { - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - } - else { - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); - rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->vrb_type, - ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0])->rballoc); - } - - add_ue_spec_dci(DCI_pdu, - (void*)&eNB_mac_inst[Mod_id].RA_template[i].RA_alloc_pdu2[0], - eNB_mac_inst[Mod_id].RA_template[i].rnti, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bytes2, - 2, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_size_bits2, - eNB_mac_inst[Mod_id].RA_template[i].RA_dci_fmt2, - 0); - LOG_W(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission)\n", - Mod_id,frame,subframe,eNB_mac_inst[Mod_id].RA_template[i].rnti); - } - else { - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframe %d : Msg4 acknowledged\n",Mod_id,frame,subframe); - eNB_mac_inst[Mod_id].RA_template[i].wait_ack_Msg4=0; - eNB_mac_inst[Mod_id].RA_template[i].RA_active=0; - } + for (i=0;i<NB_RA_PROC_MAX;i++) { + + if (eNB_mac_inst[module_idP].RA_template[i].generate_rar == 1) { + + //FK: postponed to fill_rar + //eNB_mac_inst[module_idP].RA_template[i].generate_rar = 0; + + LOG_D(MAC,"[eNB %d] Frame %d, subframeP %d: Generating RAR DCI (proc %d), RA_active %d format 1A (%d,%d))\n", + module_idP,frameP, subframeP,i, + eNB_mac_inst[module_idP].RA_template[i].RA_active, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_fmt1, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bits1); + // randomize frequency allocation for RA + while (1) { + first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); + if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) + break; + } + vrb_map[first_rb] = 1; + vrb_map[first_rb+1] = 1; + vrb_map[first_rb+2] = 1; + vrb_map[first_rb+3] = 1; + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch(mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 25: + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 50: + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 100: + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + default: + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + } + } + else { + switch(mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 25: + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 50: + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + case 100: + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->type=1; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->ndi=1; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rv=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->mcs=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->harq_pid=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->TPC=1; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->padding=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->vrb_type, + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0])->rballoc); + break; + default: + break; + } + } + add_common_dci(DCI_pdu, + (void*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu1[0], + eNB_mac_inst[module_idP].RA_template[i].RA_rnti, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bytes1, + 2, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bits1, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_fmt1, + 1); + + + + LOG_D(MAC,"[eNB %d] Frame %d: Adding common dci for RA%d (RAR) RA_active %d\n",module_idP,frameP,i, + eNB_mac_inst[module_idP].RA_template[i].RA_active); + } + if (eNB_mac_inst[module_idP].RA_template[i].generate_Msg4_dci == 1) { + + // randomize frequency allocation for RA + while (1) { + first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); + if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) + break; + } + vrb_map[first_rb] = 1; + vrb_map[first_rb+1] = 1; + vrb_map[first_rb+2] = 1; + vrb_map[first_rb+3] = 1; + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_1_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 25: + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 50: + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_10MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 100: + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_20MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + default: + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + } + } + else { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + + case 6: + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_1_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 25: + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 50: + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_10MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + case 100: + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->padding=0; + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_20MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + default: + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->type=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rv=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->harq_pid=0; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->TPC=1; + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc= mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_DL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + break; + } + } + + add_ue_spec_dci(DCI_pdu, + (void*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0], + eNB_mac_inst[module_idP].RA_template[i].rnti, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bytes2, + 1, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bits2, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_fmt2, + 0); + LOG_D(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: Adding ue specific dci (rnti %x) for Msg4\n", + module_idP,frameP,subframeP,eNB_mac_inst[module_idP].RA_template[i].rnti); + eNB_mac_inst[module_idP].RA_template[i].generate_Msg4_dci=0; + + } + else if (eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4==1) { + // check HARQ status and retransmit if necessary + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: Checking if Msg4 was acknowledged: \n", + module_idP,frameP,subframeP); + // Get candidate harq_pid from PHY + mac_xface->get_ue_active_harq_pid(module_idP,eNB_mac_inst[module_idP].RA_template[i].rnti,subframeP,&harq_pid,&round,0); + if (round>0) { + // we have to schedule a retransmission + if (mac_xface->lte_frame_parms->frame_type == TDD) + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->ndi=1; + else + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->ndi=1; + // randomize frequency allocation for RA + while (1) { + first_rb = (unsigned char)(taus()%(mac_xface->lte_frame_parms->N_RB_DL-4)); + if ((vrb_map[first_rb] != 1) && (vrb_map[first_rb+3] != 1)) + break; + } + vrb_map[first_rb] = 1; + vrb_map[first_rb+1] = 1; + vrb_map[first_rb+2] = 1; + vrb_map[first_rb+3] = 1; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_TDD_1_6_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + } + else { + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc = mac_xface->computeRIV(mac_xface->lte_frame_parms->N_RB_UL,first_rb,4); + rballoc |= mac_xface->get_rballoc(((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->vrb_type, + ((DCI1A_5MHz_FDD_t*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0])->rballoc); + } + + add_ue_spec_dci(DCI_pdu, + (void*)&eNB_mac_inst[module_idP].RA_template[i].RA_alloc_pdu2[0], + eNB_mac_inst[module_idP].RA_template[i].rnti, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bytes2, + 2, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_size_bits2, + eNB_mac_inst[module_idP].RA_template[i].RA_dci_fmt2, + 0); + LOG_W(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission)\n", + module_idP,frameP,subframeP,eNB_mac_inst[module_idP].RA_template[i].rnti); + } + else { + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d, subframeP %d : Msg4 acknowledged\n",module_idP,frameP,subframeP); + eNB_mac_inst[module_idP].RA_template[i].wait_ack_Msg4=0; + eNB_mac_inst[module_idP].RA_template[i].RA_active=0; + } + } } - } - } // RA is scheduled in this subframe + } // RA is scheduled in this subframeP // UE specific DCIs - for (UE_id=0;UE_id<NUMBER_OF_UE_MAX;UE_id++) { - //printf("UE_id: %d => status %d\n",UE_id,eNB_dlsch_info[Mod_id][UE_id].status); - if (eNB_dlsch_info[Mod_id][UE_id].status == S_DL_SCHEDULED) { - - // clear scheduling flag - eNB_dlsch_info[Mod_id][UE_id].status = S_DL_WAITING; - rnti = find_UE_RNTI(Mod_id,UE_id); - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - nb_rb = eNB_mac_inst[Mod_id].UE_template[UE_id].nb_rb[harq_pid]; - - DLSCH_dci = (void *)eNB_mac_inst[Mod_id].UE_template[UE_id].DLSCH_DCI[harq_pid]; - - - /// Synchronizing rballoc with rballoc_sub - for(i=0;i<mac_xface->lte_frame_parms->N_RBGS;i++){ - rballoc_sub[i] = eNB_mac_inst[Mod_id].UE_template[UE_id].rballoc_subband[harq_pid][i]; - if(rballoc_sub[i] == 1) - rballoc |= (0x0001<<i); // TO be FIXED!!!!!! - } - - - switch(mac_xface->get_transmission_mode(Mod_id,rnti)) { - default: - - case 1: - - case 2: - LOG_D(MAC,"[USER-PLANE DEFAULT DRB] Adding UE spec DCI for %d PRBS (%x) => ",nb_rb,rballoc); - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; - size_bytes = sizeof(DCI1_1_5MHz_TDD_t); - size_bits = sizeof_DCI1_1_5MHz_TDD_t; - break; - case 25: - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; - size_bytes = sizeof(DCI1_5MHz_TDD_t); - size_bits = sizeof_DCI1_5MHz_TDD_t; - break; - case 50: - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rah = 0; - size_bytes = sizeof(DCI1_10MHz_TDD_t); - size_bits = sizeof_DCI1_10MHz_TDD_t; - break; - case 100: - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rah = 0; - size_bytes = sizeof(DCI1_20MHz_TDD_t); - size_bits = sizeof_DCI1_20MHz_TDD_t; - break; - default: - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; - size_bytes = sizeof(DCI1_5MHz_TDD_t); - size_bits = sizeof_DCI1_5MHz_TDD_t; - break; - } - - - } - else { - switch(mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; - size_bytes=sizeof(DCI1_1_5MHz_FDD_t); - size_bits=sizeof_DCI1_1_5MHz_FDD_t; - break; - case 25: - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; - size_bytes=sizeof(DCI1_5MHz_FDD_t); - size_bits=sizeof_DCI1_5MHz_FDD_t; - break; - case 50: - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rah = 0; - size_bytes=sizeof(DCI1_10MHz_FDD_t); - size_bits=sizeof_DCI1_10MHz_FDD_t; - break; - case 100: - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rah = 0; - size_bytes=sizeof(DCI1_20MHz_FDD_t); - size_bits=sizeof_DCI1_20MHz_FDD_t; - break; - default: - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; - size_bytes=sizeof(DCI1_5MHz_FDD_t); - size_bits=sizeof_DCI1_5MHz_FDD_t; - break; - } - } - - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - size_bytes, - process_ue_cqi (Mod_id,UE_id),//aggregation, - size_bits, - format1, - 0); - - break; - case 4: - - //if (nb_rb>10) { - // DCI format 2_2A_M10PRB can also be used for less than 10 PRB (it refers to the system bandwidth) - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - sizeof(DCI2_5MHz_2A_M10PRB_TDD_t), - process_ue_cqi (Mod_id,UE_id),//aggregation, - sizeof_DCI2_5MHz_2A_M10PRB_TDD_t, - format2_2A_M10PRB, - 0); - /*} + for (ue_mod_id=0;ue_mod_id<NUMBER_OF_UE_MAX;ue_mod_id++) { + //printf("UE_id: %d => status %d\n",UE_id,eNB_dlsch_info[module_idP][UE_id].status); + if (eNB_dlsch_info[module_idP][ue_mod_id].status == S_DL_SCHEDULED) { + + // clear scheduling flag + eNB_dlsch_info[module_idP][ue_mod_id].status = S_DL_WAITING; + rnti = find_UE_RNTI(module_idP,ue_mod_id); + mac_xface->get_ue_active_harq_pid(module_idP,rnti,subframeP,&harq_pid,&round,0); + nb_rb = eNB_mac_inst[module_idP].UE_template[ue_mod_id].nb_rb[harq_pid]; + + DLSCH_dci = (void *)eNB_mac_inst[module_idP].UE_template[ue_mod_id].DLSCH_DCI[harq_pid]; + + + /// Synchronizing rballoc with rballoc_sub + for(i=0;i<mac_xface->lte_frame_parms->N_RBGS;i++){ + rballoc_sub[i] = eNB_mac_inst[module_idP].UE_template[ue_mod_id].rballoc_subband[harq_pid][i]; + if(rballoc_sub[i] == 1) + rballoc |= (0x0001<<i); // TO be FIXED!!!!!! + } + + + switch(mac_xface->get_transmission_mode(module_idP,rnti)) { + default: + + case 1: + + case 2: + LOG_D(MAC,"[USER-PLANE DEFAULT DRB] Adding UE spec DCI for %d PRBS (%x) => ",nb_rb,rballoc); + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; + size_bytes = sizeof(DCI1_1_5MHz_TDD_t); + size_bits = sizeof_DCI1_1_5MHz_TDD_t; + break; + case 25: + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; + size_bytes = sizeof(DCI1_5MHz_TDD_t); + size_bits = sizeof_DCI1_5MHz_TDD_t; + break; + case 50: + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rah = 0; + size_bytes = sizeof(DCI1_10MHz_TDD_t); + size_bits = sizeof_DCI1_10MHz_TDD_t; + break; + case 100: + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rah = 0; + size_bytes = sizeof(DCI1_20MHz_TDD_t); + size_bits = sizeof_DCI1_20MHz_TDD_t; + break; + default: + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rah = 0; + size_bytes = sizeof(DCI1_5MHz_TDD_t); + size_bits = sizeof_DCI1_5MHz_TDD_t; + break; + } + + + } + else { + switch(mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; + size_bytes=sizeof(DCI1_1_5MHz_FDD_t); + size_bits=sizeof_DCI1_1_5MHz_FDD_t; + break; + case 25: + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; + size_bytes=sizeof(DCI1_5MHz_FDD_t); + size_bits=sizeof_DCI1_5MHz_FDD_t; + break; + case 50: + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rah = 0; + size_bytes=sizeof(DCI1_10MHz_FDD_t); + size_bits=sizeof_DCI1_10MHz_FDD_t; + break; + case 100: + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rah = 0; + size_bytes=sizeof(DCI1_20MHz_FDD_t); + size_bits=sizeof_DCI1_20MHz_FDD_t; + break; + default: + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rah = 0; + size_bytes=sizeof(DCI1_5MHz_FDD_t); + size_bits=sizeof_DCI1_5MHz_FDD_t; + break; + } + } + + add_ue_spec_dci(DCI_pdu, + DLSCH_dci, + rnti, + size_bytes, + process_ue_cqi (module_idP,ue_mod_id),//aggregation, + size_bits, + format1, + 0); + + break; + case 4: + + //if (nb_rb>10) { + // DCI format 2_2A_M10PRB can also be used for less than 10 PRB (it refers to the system bandwidth) + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; + add_ue_spec_dci(DCI_pdu, + DLSCH_dci, + rnti, + sizeof(DCI2_5MHz_2A_M10PRB_TDD_t), + process_ue_cqi (module_idP,ue_mod_id),//aggregation, + sizeof_DCI2_5MHz_2A_M10PRB_TDD_t, + format2_2A_M10PRB, + 0); + /*} else { ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); add_ue_spec_dci(DCI_pdu, @@ -3337,37 +3357,37 @@ void fill_DLSCH_dci(unsigned char Mod_id,u32 frame, unsigned char subframe,u32 R sizeof_DCI2_5MHz_2A_L10PRB_TDD_t, format2_2A_L10PRB); }*/ - break; - case 5: - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; - - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - process_ue_cqi (Mod_id,UE_id),//aggregation, - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - format1E_2A_M10PRB, - 0); - break; - - case 6: - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; - - add_ue_spec_dci(DCI_pdu, - DLSCH_dci, - rnti, - sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), - process_ue_cqi (Mod_id,UE_id),//aggregation - sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, - format1E_2A_M10PRB, - 0); - break; - + break; + case 5: + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; + + add_ue_spec_dci(DCI_pdu, + DLSCH_dci, + rnti, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + process_ue_cqi (module_idP,ue_mod_id),//aggregation, + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + format1E_2A_M10PRB, + 0); + break; + + case 6: + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rballoc = allocate_prbs_sub(nb_rb,rballoc_sub); + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rah = 0; + + add_ue_spec_dci(DCI_pdu, + DLSCH_dci, + rnti, + sizeof(DCI1E_5MHz_2A_M10PRB_TDD_t), + process_ue_cqi (module_idP,ue_mod_id),//aggregation + sizeof_DCI1E_5MHz_2A_M10PRB_TDD_t, + format1E_2A_M10PRB, + 0); + break; + + } } - } } @@ -3375,55 +3395,52 @@ void fill_DLSCH_dci(unsigned char Mod_id,u32 frame, unsigned char subframe,u32 R -void update_ul_dci(u8 Mod_id,u16 rnti,u8 dai) { +void update_ul_dci(module_id_t module_idP,rnti_t rnti,u8 dai) { - DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu; - int i; - DCI0_5MHz_TDD_1_6_t *ULSCH_dci; + DCI_PDU *DCI_pdu = &eNB_mac_inst[module_idP].DCI_pdu; + int i; + DCI0_5MHz_TDD_1_6_t *ULSCH_dci = NULL;; if (mac_xface->lte_frame_parms->frame_type == TDD) { - for (i=0;i<DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci;i++) { - ULSCH_dci = (DCI0_5MHz_TDD_1_6_t *)DCI_pdu->dci_alloc[i].dci_pdu; - if ((DCI_pdu->dci_alloc[i].format == format0) && (DCI_pdu->dci_alloc[i].rnti == rnti)) - ULSCH_dci->dai = (dai-1)&3; - } + for (i=0;i<DCI_pdu->Num_common_dci+DCI_pdu->Num_ue_spec_dci;i++) { + ULSCH_dci = (DCI0_5MHz_TDD_1_6_t *)DCI_pdu->dci_alloc[i].dci_pdu; + if ((DCI_pdu->dci_alloc[i].format == format0) && (DCI_pdu->dci_alloc[i].rnti == rnti)) + ULSCH_dci->dai = (dai-1)&3; + } } // printf("Update UL DCI: DAI %d\n",dai); } -void schedule_ue_spec(unsigned char Mod_id, - u32 frame, - unsigned char subframe, - u16 nb_rb_used0, - unsigned int *nCCE_used, - int mbsfn_flag) { - - unsigned char UE_id; - unsigned char next_ue; - unsigned char granted_UEs; - u16 nCCE; - unsigned char aggregation; +void schedule_ue_spec(module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + u16 nb_rb_used0, + unsigned int *nCCE_used, + int mbsfn_flag) { + + module_id_t ue_mod_id = -1; + module_id_t next_ue = -1; + unsigned char granted_UEs = 0; + u16 nCCE; + unsigned char aggregation; mac_rlc_status_resp_t rlc_status; - unsigned char header_len_dcch=0, header_len_dcch_tmp=0,header_len_dtch=0,header_len_dtch_tmp=0, ta_len=0; - unsigned char sdu_lcids[11],offset,num_sdus=0; - u16 nb_rb,nb_rb_temp,nb_available_rb,TBS,j,sdu_lengths[11],rnti,padding=0,post_padding=0; - unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; - unsigned char round=0; - unsigned char harq_pid=0; - void *DLSCH_dci; - LTE_eNB_UE_stats* eNB_UE_stats; - u16 sdu_length_total=0; - // unsigned char loop_count; - unsigned char DAI; - u16 i=0; - u8 dl_pow_off[NUMBER_OF_UE_MAX]; - unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX]; -// unsigned char rballoc_sub[N_RBGS_MAX]; - u16 pre_nb_available_rbs[NUMBER_OF_UE_MAX]; - int mcs; - //u8 number_of_subbands=13; - u16 min_rb_unit; - short ta_update=0; + unsigned char header_len_dcch=0, header_len_dcch_tmp=0,header_len_dtch=0,header_len_dtch_tmp=0, ta_len=0; + unsigned char sdu_lcids[11],offset,num_sdus=0; + u16 nb_rb,nb_rb_temp,nb_available_rb,TBS,j,sdu_lengths[11],rnti,padding=0,post_padding=0; + unsigned char dlsch_buffer[MAX_DLSCH_PAYLOAD_BYTES]; + unsigned char round = 0; + unsigned char harq_pid = 0; + void *DLSCH_dci = NULL; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + u16 sdu_length_total = 0; + unsigned char DAI; + u16 i = 0; + u8 dl_pow_off[NUMBER_OF_UE_MAX]; + unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX]; + u16 pre_nb_available_rbs[NUMBER_OF_UE_MAX]; + int mcs; + u16 min_rb_unit; + short ta_update = 0; switch (mac_xface->lte_frame_parms->N_RB_DL) { case 6: @@ -3447,794 +3464,829 @@ void schedule_ue_spec(unsigned char Mod_id, return; //int **rballoc_sub = (int **)malloc(1792*sizeof(int *)); - granted_UEs = find_dlgranted_UEs(Mod_id); + granted_UEs = find_dlgranted_UEs(module_idP); - //weight = get_ue_weight(Mod_id,UE_id); + //weight = get_ue_weight(module_idP,UE_id); aggregation = 1; // set to the maximum aggregation level /// Initialization for pre-processor for(i=0;i<NUMBER_OF_UE_MAX;i++){ - pre_nb_available_rbs[i] = 0; - dl_pow_off[i] = 2; - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++){ -// rballoc_sub[j] = 0; - rballoc_sub_UE[i][j] = 0; - } + pre_nb_available_rbs[i] = 0; + dl_pow_off[i] = 2; + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++){ + // rballoc_sub[j] = 0; + rballoc_sub_UE[i][j] = 0; + } } for (i = 0; i < NUMBER_OF_UE_MAX; i++) { - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[i].pre_nb_available_rbs = 0; - for (j = 0; j < mac_xface->lte_frame_parms->N_RBGS; j++) { - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[i].rballoc_sub[j] = 0; - } + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[i].pre_nb_available_rbs = 0; + for (j = 0; j < mac_xface->lte_frame_parms->N_RBGS; j++) { + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[i].rballoc_sub[j] = 0; + } } // set current available nb_rb and nCCE to maximum nb_available_rb = mac_xface->lte_frame_parms->N_RB_DL - nb_rb_used0; - nCCE = mac_xface->get_nCCE_max(Mod_id) - *nCCE_used; + nCCE = mac_xface->get_nCCE_max(module_idP) - *nCCE_used; // store the goloabl enb stats - eNB_mac_inst[Mod_id].eNB_stats.num_dlactive_UEs = granted_UEs; - eNB_mac_inst[Mod_id].eNB_stats.available_prbs = nb_available_rb; - eNB_mac_inst[Mod_id].eNB_stats.total_available_prbs += nb_available_rb; - eNB_mac_inst[Mod_id].eNB_stats.available_ncces = nCCE; - eNB_mac_inst[Mod_id].eNB_stats.dlsch_bytes_tx=0; - eNB_mac_inst[Mod_id].eNB_stats.dlsch_pdus_tx=0; + eNB_mac_inst[module_idP].eNB_stats.num_dlactive_UEs = granted_UEs; + eNB_mac_inst[module_idP].eNB_stats.available_prbs = nb_available_rb; + eNB_mac_inst[module_idP].eNB_stats.total_available_prbs += nb_available_rb; + eNB_mac_inst[module_idP].eNB_stats.available_ncces = nCCE; + eNB_mac_inst[module_idP].eNB_stats.dlsch_bytes_tx=0; + eNB_mac_inst[module_idP].eNB_stats.dlsch_pdus_tx=0; /// CALLING Pre_Processor for downlink scheduling (Returns estimation of RBs required by each UE and the allocation on sub-band) - dlsch_scheduler_pre_processor(Mod_id, - frame, - subframe, - dl_pow_off, - pre_nb_available_rbs, - mac_xface->lte_frame_parms->N_RBGS, - rballoc_sub_UE); - - - for (UE_id=0;UE_id<granted_UEs;UE_id++) { - - rnti = find_UE_RNTI(Mod_id,UE_id); - - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].crnti= rnti; - eNB_mac_inst[Mod_id].eNB_UE_stats[UE_id].rrc_status=mac_get_rrc_status(Mod_id,1,UE_id); - if (rnti==0) { - LOG_E(MAC,"Cannot find rnti for UE_id %d (granted UEs %d)\n",UE_id,granted_UEs); - mac_xface->macphy_exit("");//continue; - } + dlsch_scheduler_pre_processor(module_idP, + frameP, + subframeP, + dl_pow_off, + pre_nb_available_rbs, + mac_xface->lte_frame_parms->N_RBGS, + rballoc_sub_UE); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,rnti); - if (eNB_UE_stats==NULL) - mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - // Get candidate harq_pid from PHY - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - // printf("Got harq_pid %d, round %d\n",harq_pid,round); + for (ue_mod_id=0;ue_mod_id<granted_UEs;ue_mod_id++) { + rnti = find_UE_RNTI(module_idP,ue_mod_id); - nb_available_rb = pre_nb_available_rbs[UE_id]; + eNB_mac_inst[module_idP].eNB_UE_stats[ue_mod_id].crnti= rnti; + eNB_mac_inst[module_idP].eNB_UE_stats[ue_mod_id].rrc_status=mac_get_rrc_status(module_idP,1,ue_mod_id); + if (rnti==0) { + LOG_E(MAC,"Cannot find rnti for UE_id %d (granted UEs %d)\n",ue_mod_id,granted_UEs); + mac_xface->macphy_exit("");//continue; + } - if ((nb_available_rb == 0) || (nCCE < (1<<aggregation))) { - LOG_D(MAC,"UE %d: nb_availiable_rb exhausted (nb_rb_used %d, nb_available_rb %d, nCCE %d, aggregation %d)\n", - UE_id, nb_rb_used0, nb_available_rb, nCCE, aggregation); - //if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) - continue; //to next user (there might be rbs availiable for other UEs in TM5 - // else - // break; - } - sdu_length_total=0; - num_sdus=0; + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,rnti); + if (eNB_UE_stats==NULL) + mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - // get Round-Robin allocation - next_ue = UE_id;//schedule_next_dlue(Mod_id,subframe); // next scheduled user - // If nobody is left, exit while loop and go to next step - if (next_ue == 255) - break; + // Get candidate harq_pid from PHY + mac_xface->get_ue_active_harq_pid(module_idP,rnti,subframeP,&harq_pid,&round,0); + // printf("Got harq_pid %d, round %d\n",harq_pid,round); - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->tdd_config) { - case 0: - if ((subframe==0)||(subframe==1)||(subframe==3)||(subframe==5)||(subframe==6)||(subframe==8)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - case 1: - if ((subframe==0)||(subframe==4)||(subframe==5)||(subframe==9)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - break; - case 2: - if ((subframe==4)||(subframe==5)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - break; - case 3: - if ((subframe==5)||(subframe==7)||(subframe==9)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - break; - case 4: - if ((subframe==0)||(subframe==6)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - break; - case 5: - if (subframe==9) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - break; - case 6: - if ((subframe==0)||(subframe==1)||(subframe==5)||(subframe==6)||(subframe==9)) - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI = 0; - default: - break; + + nb_available_rb = pre_nb_available_rbs[ue_mod_id]; + + if ((nb_available_rb == 0) || (nCCE < (1<<aggregation))) { + LOG_D(MAC,"UE %d: nb_availiable_rb exhausted (nb_rb_used %d, nb_available_rb %d, nCCE %d, aggregation %d)\n", + ue_mod_id, nb_rb_used0, nb_available_rb, nCCE, aggregation); + //if(mac_xface->get_transmission_mode(module_idP,rnti)==5) + continue; //to next user (there might be rbs availiable for other UEs in TM5 + // else + // break; } - } + sdu_length_total=0; + num_sdus=0; + + // get Round-Robin allocation + next_ue = ue_mod_id;//schedule_next_dlue(module_idP,subframeP); // next scheduled user + // If nobody is left, exit while loop and go to next step + if (next_ue == 255) + break; - // This is an allocated UE_id - rnti = find_UE_RNTI(Mod_id,next_ue); - if (rnti==0) - continue; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->tdd_config) { + case 0: + if ((subframeP==0)||(subframeP==1)||(subframeP==3)||(subframeP==5)||(subframeP==6)||(subframeP==8)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + case 1: + if ((subframeP==0)||(subframeP==4)||(subframeP==5)||(subframeP==9)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + break; + case 2: + if ((subframeP==4)||(subframeP==5)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + break; + case 3: + if ((subframeP==5)||(subframeP==7)||(subframeP==9)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + break; + case 4: + if ((subframeP==0)||(subframeP==6)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + break; + case 5: + if (subframeP==9) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + break; + case 6: + if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)||(subframeP==9)) + eNB_mac_inst[module_idP].UE_template[next_ue].DAI = 0; + default: + break; + } + } + + // This is an allocated UE_id + rnti = find_UE_RNTI(module_idP,next_ue); + if (rnti==0) + continue; + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(module_idP,rnti); - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,rnti); + if (eNB_UE_stats==NULL) + mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); - if (eNB_UE_stats==NULL) - mac_xface->macphy_exit("[MAC][eNB] Cannot find eNB_UE_stats\n"); + //eNB_UE_stats->dlsch_mcs1 = openair_daq_vars.target_ue_dl_mcs; + // int flag_LA=0; + //printf("CQI %d\n",eNB_UE_stats->DL_cqi[0]); + + eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; - //eNB_UE_stats->dlsch_mcs1 = openair_daq_vars.target_ue_dl_mcs; - // int flag_LA=0; - //printf("CQI %d\n",eNB_UE_stats->DL_cqi[0]); - - eNB_UE_stats->dlsch_mcs1 = cqi_to_mcs[eNB_UE_stats->DL_cqi[0]]; - if(eNB_UE_stats->dlsch_mcs1>22) - eNB_UE_stats->dlsch_mcs1=22; - - - // for TM5, limit the MCS to 16QAM + eNB_UE_stats->dlsch_mcs1=22; - // for EXMIMO, limit the MCS to 16QAM as well -#ifdef EXMIMO - eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,16); -#endif + // for TM5, limit the MCS to 16QAM - // Get candidate harq_pid from PHY - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].harq_pid = harq_pid; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].harq_round = round; - // Note this code is for a specific DCI format - DLSCH_dci = (void *)eNB_mac_inst[Mod_id].UE_template[next_ue].DLSCH_DCI[harq_pid]; + // for EXMIMO, limit the MCS to 16QAM as well +#ifdef EXMIMO + eNB_UE_stats->dlsch_mcs1 = cmin(eNB_UE_stats->dlsch_mcs1,16); +#endif - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++){ // initializing the rb allocation indicator for each UE - eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j] = 0; - } - // store stats - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].dl_cqi= eNB_UE_stats->DL_cqi[0]; - - if (round > 0) { - if (mac_xface->lte_frame_parms->frame_type == TDD) { - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI++; - LOG_D(MAC,"DAI update: subframe %d: UE %d, DAI %d\n",subframe,next_ue,eNB_mac_inst[Mod_id].UE_template[next_ue].DAI); - - update_ul_dci(Mod_id,rnti,eNB_mac_inst[Mod_id].UE_template[next_ue].DAI); - } + // Get candidate harq_pid from PHY + mac_xface->get_ue_active_harq_pid(module_idP,rnti,subframeP,&harq_pid,&round,0); - // get freq_allocation - nb_rb = eNB_mac_inst[Mod_id].UE_template[next_ue].nb_rb[harq_pid]; - if (nb_rb <= nb_available_rb) { - - if(nb_rb == pre_nb_available_rbs[next_ue]){ - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) // for indicating the rballoc for each sub-band - eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j];} - else - { - nb_rb_temp = nb_rb; - j = 0; - while((nb_rb_temp > 0) && (j<mac_xface->lte_frame_parms->N_RBGS)){ - if(rballoc_sub_UE[next_ue][j] == 1){ - eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; - if((j == mac_xface->lte_frame_parms->N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))) - nb_rb_temp = nb_rb_temp - min_rb_unit+1; - else - nb_rb_temp = nb_rb_temp - min_rb_unit; - } - j = j+1; - } - } - - nb_available_rb -= nb_rb; - aggregation = process_ue_cqi(Mod_id,next_ue); - nCCE-=(1<<aggregation); // adjust the remaining nCCE - *nCCE_used += (1<<aggregation); - - - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].dl_pow_off = dl_pow_off[next_ue]; - - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].rballoc_sub[j] = eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j]; - - switch (mac_xface->get_transmission_mode(Mod_id,rnti)) { - case 1: - case 2: - default: - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - if (mac_xface->lte_frame_parms->frame_type == TDD) { - // ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",Mod_id,harq_pid,round,(eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1),((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs); - } - else { - // ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rv = round&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",Mod_id,harq_pid,round,((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->mcs); - - } - break; - case 25: - if (mac_xface->lte_frame_parms->frame_type == TDD) { - // ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",Mod_id,harq_pid,round,(eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1),((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs); - } - else { - // ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = round&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",Mod_id,harq_pid,round,((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs); - - } - break; - case 50: - if (mac_xface->lte_frame_parms->frame_type == TDD) { - // ((DCI1_10MHz_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",Mod_id,harq_pid,round,(eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1),((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs); - } - else { - // ((DCI1_10MHz_FDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rv = round&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",Mod_id,harq_pid,round,((DCI1_10MHz_FDD_t*)DLSCH_dci)->mcs); - - } - break; - case 100: - if (mac_xface->lte_frame_parms->frame_type == TDD) { - // ((DCI1_20MHz_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",Mod_id,harq_pid,round,(eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1),((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs); - } - else { - // ((DCI1_20MHz_FDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rv = round&3; - LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",Mod_id,harq_pid,round,((DCI1_20MHz_FDD_t*)DLSCH_dci)->mcs); - - } - break; - } - break; - case 4: - // if (nb_rb>10) { - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi1 = 0; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - // } - //else { - // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->ndi1 = 0; - // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->rv1 = round&3; - // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - // } - break; - case 5: - // if(nb_rb>10){ - //((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = eNB_UE_stats->DL_cqi[0]<<1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - if(dl_pow_off[next_ue] == 2) - dl_pow_off[next_ue] = 1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[next_ue]; - // } - break; - case 6: - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 0; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = 1;//dl_pow_off[next_ue]; - break; - } + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].harq_pid = harq_pid; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].harq_round = round; + // Note this code is for a specific DCI format + DLSCH_dci = (void *)eNB_mac_inst[module_idP].UE_template[next_ue].DLSCH_DCI[harq_pid]; - add_ue_dlsch_info(Mod_id, - next_ue, - subframe, - S_DL_SCHEDULED); - - //eNB_UE_stats->dlsch_trials[round]++; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_retransmission+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].rbs_used_retx=nb_rb; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].total_rbs_used_retx+=nb_rb; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].ncce_used_retx=nCCE; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].dlsch_mcs2=eNB_UE_stats->dlsch_mcs1; + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++){ // initializing the rb allocation indicator for each UE + eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j] = 0; } - else { // don't schedule this UE, its retransmission takes more resources than we have - + // store stats + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].dl_cqi= eNB_UE_stats->DL_cqi[0]; + + if (round > 0) { + if (mac_xface->lte_frame_parms->frame_type == TDD) { + eNB_mac_inst[module_idP].UE_template[next_ue].DAI++; + LOG_D(MAC,"DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,next_ue,eNB_mac_inst[module_idP].UE_template[next_ue].DAI); + + update_ul_dci(module_idP,rnti,eNB_mac_inst[module_idP].UE_template[next_ue].DAI); + } + + // get freq_allocation + nb_rb = eNB_mac_inst[module_idP].UE_template[next_ue].nb_rb[harq_pid]; + if (nb_rb <= nb_available_rb) { + + if(nb_rb == pre_nb_available_rbs[next_ue]){ + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) // for indicating the rballoc for each sub-band + eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j];} + else + { + nb_rb_temp = nb_rb; + j = 0; + while((nb_rb_temp > 0) && (j<mac_xface->lte_frame_parms->N_RBGS)){ + if(rballoc_sub_UE[next_ue][j] == 1){ + eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; + if((j == mac_xface->lte_frame_parms->N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))) + nb_rb_temp = nb_rb_temp - min_rb_unit+1; + else + nb_rb_temp = nb_rb_temp - min_rb_unit; + } + j = j+1; + } + } + + nb_available_rb -= nb_rb; + aggregation = process_ue_cqi(module_idP,next_ue); + nCCE-=(1<<aggregation); // adjust the remaining nCCE + *nCCE_used += (1<<aggregation); + + + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].dl_pow_off = dl_pow_off[next_ue]; + + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].rballoc_sub[j] = eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j]; + + switch (mac_xface->get_transmission_mode(module_idP,rnti)) { + case 1: + case 2: + default: + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + if (mac_xface->lte_frame_parms->frame_type == TDD) { + // ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1),((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs); + } + else { + // ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rv = round&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",module_idP,harq_pid,round,((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->mcs); + + } + break; + case 25: + if (mac_xface->lte_frame_parms->frame_type == TDD) { + // ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1),((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs); + } + else { + // ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = round&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",module_idP,harq_pid,round,((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs); + + } + break; + case 50: + if (mac_xface->lte_frame_parms->frame_type == TDD) { + // ((DCI1_10MHz_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1),((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs); + } + else { + // ((DCI1_10MHz_FDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rv = round&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",module_idP,harq_pid,round,((DCI1_10MHz_FDD_t*)DLSCH_dci)->mcs); + + } + break; + case 100: + if (mac_xface->lte_frame_parms->frame_type == TDD) { + // ((DCI1_20MHz_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, dai %d, mcs %d\n",module_idP,harq_pid,round,(eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1),((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs); + } + else { + // ((DCI1_20MHz_FDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rv = round&3; + LOG_D(MAC,"[eNB %d] Retransmission : harq_pid %d, round %d, mcs %d\n",module_idP,harq_pid,round,((DCI1_20MHz_FDD_t*)DLSCH_dci)->mcs); + + } + break; + } + break; + case 4: + // if (nb_rb>10) { + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi1 = 0; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + // } + //else { + // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->ndi1 = 0; + // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->rv1 = round&3; + // ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + // } + break; + case 5: + // if(nb_rb>10){ + //((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = eNB_UE_stats->DL_cqi[0]<<1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + if(dl_pow_off[next_ue] == 2) + dl_pow_off[next_ue] = 1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[next_ue]; + // } + break; + case 6: + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 0; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = 1;//dl_pow_off[next_ue]; + break; + } + + add_ue_dlsch_info(module_idP, + next_ue, + subframeP, + S_DL_SCHEDULED); + + //eNB_UE_stats->dlsch_trials[round]++; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_retransmission+=1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].rbs_used_retx=nb_rb; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].total_rbs_used_retx+=nb_rb; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].ncce_used_retx=nCCE; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].dlsch_mcs2=eNB_UE_stats->dlsch_mcs1; + } + else { // don't schedule this UE, its retransmission takes more resources than we have + + } } - } - else { // This is a potentially new SDU opportunity + else { // This is a potentially new SDU opportunity - // calculate mcs + // calculate mcs - rlc_status.bytes_in_buffer = 0; - // Now check RLC information to compute number of required RBs - // get maximum TBS size for RLC request - //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); - // check first for RLC data on DCCH - // add the length for all the control elements (timing adv, drx, etc) : header + payload + rlc_status.bytes_in_buffer = 0; + // Now check RLC information to compute number of required RBs + // get maximum TBS size for RLC request + //TBS = mac_xface->get_TBS(eNB_UE_stats->DL_cqi[0]<<1,nb_available_rb); + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); + // check first for RLC data on DCCH + // add the length for all the control elements (timing adv, drx, etc) : header + payload #ifndef EXMIMO_IOT - ta_len = ((eNB_UE_stats->timing_advance_update/4)!=0) ? 2 : 0; -#else - ta_len = 0; + ta_len = ((eNB_UE_stats->timing_advance_update/4)!=0) ? 2 : 0; +#else + ta_len = 0; #endif - - header_len_dcch = 2; // 2 bytes DCCH SDU subheader - - - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_NO, DCCH+(NB_RB_MAX*next_ue), - (TBS-ta_len-header_len_dcch)); // transport block set size - - sdu_lengths[0]=0; - if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit - LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH, Requesting %d bytes from RLC (RRC message)\n",Mod_id,frame,TBS-header_len_dcch); - sdu_lengths[0] += mac_rlc_data_req(Mod_id,frame,RLC_MBMS_NO, - DCCH+(NB_RB_MAX*next_ue), - (char *)&dlsch_buffer[sdu_lengths[0]]); - - LOG_D(MAC,"[eNB %d][DCCH] Got %d bytes from RLC\n",Mod_id,sdu_lengths[0]); - sdu_length_total = sdu_lengths[0]; - sdu_lcids[0] = DCCH; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_pdu_tx[DCCH]+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_bytes_tx[DCCH]+=sdu_lengths[0]; - num_sdus = 1; + + header_len_dcch = 2; // 2 bytes DCCH SDU subheader + + + rlc_status = mac_rlc_status_ind( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DCCH, + (TBS-ta_len-header_len_dcch)); // transport block set size + + sdu_lengths[0]=0; + if (rlc_status.bytes_in_buffer > 0) { // There is DCCH to transmit + LOG_D(MAC,"[eNB %d] Frame %d, DL-DCCH->DLSCH, Requesting %d bytes from RLC (RRC message)\n",module_idP,frameP,TBS-header_len_dcch); + sdu_lengths[0] += mac_rlc_data_req( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DCCH, + (char *)&dlsch_buffer[sdu_lengths[0]]); + + LOG_D(MAC,"[eNB %d][DCCH] Got %d bytes from RLC\n",module_idP,sdu_lengths[0]); + sdu_length_total = sdu_lengths[0]; + sdu_lcids[0] = DCCH; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_pdu_tx[DCCH]+=1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_bytes_tx[DCCH]+=sdu_lengths[0]; + num_sdus = 1; #ifdef DEBUG_eNB_SCHEDULER - LOG_T(MAC,"[eNB %d][DCCH] Got %d bytes :",Mod_id,sdu_lengths[0]); - for (j=0;j<sdu_lengths[0];j++) - LOG_T(MAC,"%x ",dlsch_buffer[j]); - LOG_T(MAC,"\n"); + LOG_T(MAC,"[eNB %d][DCCH] Got %d bytes :",module_idP,sdu_lengths[0]); + for (j=0;j<sdu_lengths[0];j++) + LOG_T(MAC,"%x ",dlsch_buffer[j]); + LOG_T(MAC,"\n"); #endif - } - else { - header_len_dcch = 0; - sdu_length_total = 0; - } - - // check for DCCH1 and update header information (assume 2 byte sub-header) - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_NO, DCCH+1+(NB_RB_MAX*next_ue), - (TBS-ta_len-header_len_dcch-sdu_length_total)); // transport block set size less allocations for timing advance and - // DCCH SDU - - if (rlc_status.bytes_in_buffer > 0) { - LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, Requesting %d bytes from RLC (RRC message)\n", - Mod_id,frame,TBS-header_len_dcch-sdu_length_total); - sdu_lengths[num_sdus] += mac_rlc_data_req(Mod_id,frame,RLC_MBMS_NO, - DCCH+1+(NB_RB_MAX*next_ue), - (char *)&dlsch_buffer[sdu_lengths[0]]); - sdu_lcids[num_sdus] = DCCH1; - sdu_length_total += sdu_lengths[num_sdus]; - header_len_dcch += 2; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_pdu_tx[DCCH1]+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_bytes_tx[DCCH1]+=sdu_lengths[num_sdus]; - num_sdus++; - LOG_D(MAC,"[eNB %d] Got %d bytes for DCCH from RLC\n",Mod_id,sdu_lengths[0]); - } - // check for DTCH and update header information - // here we should loop over all possible DTCH - - header_len_dtch = 3; // 3 bytes DTCH SDU subheader - - LOG_D(MAC,"[eNB %d], Frame %d, DTCH->DLSCH, Checking RLC status (rab %d, tbs %d, len %d)\n", - Mod_id,frame,DTCH+(NB_RB_MAX*next_ue),TBS, - TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch); - - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_NO, DTCH+(NB_RB_MAX*next_ue), - TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch); - - if (rlc_status.bytes_in_buffer > 0) { - - LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB], Frame %d, DTCH->DLSCH, Requesting %d bytes from RLC (hdr len dtch %d)\n", - Mod_id,frame,TBS-header_len_dcch-sdu_length_total-header_len_dtch,header_len_dtch); - sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id,frame,RLC_MBMS_NO, - DTCH+(NB_RB_MAX*next_ue), - (char*)&dlsch_buffer[sdu_length_total]); - - LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",Mod_id,sdu_lengths[num_sdus],DTCH+(NB_RB_MAX*next_ue)); - sdu_lcids[num_sdus] = DTCH; - sdu_length_total += sdu_lengths[num_sdus]; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_pdu_tx[DTCH]+=1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].num_bytes_tx[DTCH]+=sdu_lengths[num_sdus]; - if (sdu_lengths[num_sdus] < 128) - header_len_dtch=2; - num_sdus++; - } - else { - header_len_dtch = 0; - } - - // there is a payload - if (((sdu_length_total + header_len_dcch + header_len_dtch )> 0)) { - - // Now compute number of required RBs for total sdu length - // Assume RAH format 2 - // adjust header lengths - header_len_dcch_tmp = header_len_dcch; - header_len_dtch_tmp = header_len_dtch; - if (header_len_dtch==0) - header_len_dcch = (header_len_dcch >0) ? 1 : header_len_dcch; // remove length field - else - header_len_dtch = (header_len_dtch > 0) ? 1 :header_len_dtch; // remove length field for the last SDU - - - - - mcs = eNB_UE_stats->dlsch_mcs1; - if (mcs==0) nb_rb = 4; // don't let the TBS get too small - else nb_rb=min_rb_unit; - - TBS = mac_xface->get_TBS_DL(mcs,nb_rb); - - while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) { - nb_rb += min_rb_unit; // - if (nb_rb>nb_available_rb) { // if we've gone beyond the maximum number of RBs - // (can happen if N_RB_DL is odd) - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); - nb_rb = nb_available_rb; - break; - } - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rb); - } - - if(nb_rb == pre_nb_available_rbs[next_ue]) - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) // for indicating the rballoc for each sub-band - eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; - else - { - nb_rb_temp = nb_rb; - j = 0; - while((nb_rb_temp > 0) && (j<mac_xface->lte_frame_parms->N_RBGS)){ - if(rballoc_sub_UE[next_ue][j] == 1){ - eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; - if ((j == mac_xface->lte_frame_parms->N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))) - nb_rb_temp = nb_rb_temp - min_rb_unit+1; - else - nb_rb_temp = nb_rb_temp - min_rb_unit; - } - j = j+1; - } - } - - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].pre_nb_available_rbs = nb_rb; - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].dl_pow_off = dl_pow_off[next_ue]; - - for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) - PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[next_ue].rballoc_sub[j] = eNB_mac_inst[Mod_id].UE_template[next_ue].rballoc_subband[harq_pid][j]; - - - // decrease mcs until TBS falls below required length - while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) { - mcs--; - TBS = mac_xface->get_TBS_DL(mcs,nb_rb); - } - - // if we have decreased too much or we don't have enough RBs, increase MCS - while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( dl_pow_off[next_ue]>0) && (mcs<28)) || ( (dl_pow_off[next_ue]==0) && (mcs<=15)))) { - mcs++; - TBS = mac_xface->get_TBS_DL(mcs,nb_rb); - } - - LOG_D(MAC,"dlsch_mcs before and after the rate matching = (%d, %d)\n",eNB_UE_stats->dlsch_mcs1, mcs); + } + else { + header_len_dcch = 0; + sdu_length_total = 0; + } + + // check for DCCH1 and update header information (assume 2 byte sub-header) + rlc_status = mac_rlc_status_ind( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DCCH+1, + (TBS-ta_len-header_len_dcch-sdu_length_total)); // transport block set size less allocations for timing advance and + // DCCH SDU + + if (rlc_status.bytes_in_buffer > 0) { + LOG_D(MAC,"[eNB %d], Frame %d, DCCH1->DLSCH, Requesting %d bytes from RLC (RRC message)\n", + module_idP,frameP,TBS-header_len_dcch-sdu_length_total); + sdu_lengths[num_sdus] += mac_rlc_data_req( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DCCH+1, + (char *)&dlsch_buffer[sdu_lengths[0]]); + + sdu_lcids[num_sdus] = DCCH1; + sdu_length_total += sdu_lengths[num_sdus]; + header_len_dcch += 2; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_pdu_tx[DCCH1]+=1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_bytes_tx[DCCH1]+=sdu_lengths[num_sdus]; + num_sdus++; + LOG_D(MAC,"[eNB %d] Got %d bytes for DCCH from RLC\n",module_idP,sdu_lengths[0]); + } + // check for DTCH and update header information + // here we should loop over all possible DTCH + + header_len_dtch = 3; // 3 bytes DTCH SDU subheader + + LOG_D(MAC,"[eNB %d], Frame %d, DTCH->DLSCH, Checking RLC status (rab %d, tbs %d, len %d)\n", + module_idP,frameP,DTCH,TBS, + TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch); + + rlc_status = mac_rlc_status_ind( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DTCH, + TBS-ta_len-header_len_dcch-sdu_length_total-header_len_dtch); + + if (rlc_status.bytes_in_buffer > 0) { + + LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB], Frame %d, DTCH->DLSCH, Requesting %d bytes from RLC (hdr len dtch %d)\n", + module_idP,frameP,TBS-header_len_dcch-sdu_length_total-header_len_dtch,header_len_dtch); + sdu_lengths[num_sdus] = mac_rlc_data_req( + module_idP, + ue_mod_id, + frameP, + 1, + RLC_MBMS_NO, + DTCH, + (char*)&dlsch_buffer[sdu_length_total]); + + LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Got %d bytes for DTCH %d \n",module_idP,sdu_lengths[num_sdus],DTCH); + sdu_lcids[num_sdus] = DTCH; + sdu_length_total += sdu_lengths[num_sdus]; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_pdu_tx[DTCH]+=1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].num_bytes_tx[DTCH]+=sdu_lengths[num_sdus]; + if (sdu_lengths[num_sdus] < 128) { + header_len_dtch=2; + } + num_sdus++; + } + else { + header_len_dtch = 0; + } + + // there is a payload + if (((sdu_length_total + header_len_dcch + header_len_dtch )> 0)) { + + // Now compute number of required RBs for total sdu length + // Assume RAH format 2 + // adjust header lengths + header_len_dcch_tmp = header_len_dcch; + header_len_dtch_tmp = header_len_dtch; + if (header_len_dtch==0) { + header_len_dcch = (header_len_dcch >0) ? 1 : header_len_dcch; // remove length field + } else { + header_len_dtch = (header_len_dtch > 0) ? 1 :header_len_dtch; // remove length field for the last SDU + } + + + mcs = eNB_UE_stats->dlsch_mcs1; + if (mcs==0) nb_rb = 4; // don't let the TBS get too small + else nb_rb=min_rb_unit; + + TBS = mac_xface->get_TBS_DL(mcs,nb_rb); + + while (TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) { + nb_rb += min_rb_unit; // + if (nb_rb>nb_available_rb) { // if we've gone beyond the maximum number of RBs + // (can happen if N_RB_DL is odd) + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_available_rb); + nb_rb = nb_available_rb; + break; + } + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rb); + } + + if(nb_rb == pre_nb_available_rbs[next_ue]) { + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) {// for indicating the rballoc for each sub-band + eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; + } + } else + { + nb_rb_temp = nb_rb; + j = 0; + while((nb_rb_temp > 0) && (j<mac_xface->lte_frame_parms->N_RBGS)){ + if(rballoc_sub_UE[next_ue][j] == 1){ + eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j] = rballoc_sub_UE[next_ue][j]; + if ((j == mac_xface->lte_frame_parms->N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))) + nb_rb_temp = nb_rb_temp - min_rb_unit+1; + else + nb_rb_temp = nb_rb_temp - min_rb_unit; + } + j = j+1; + } + } + + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].pre_nb_available_rbs = nb_rb; + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].dl_pow_off = dl_pow_off[next_ue]; + + for(j=0;j<mac_xface->lte_frame_parms->N_RBGS;j++) + PHY_vars_eNB_g[module_idP]->mu_mimo_mode[next_ue].rballoc_sub[j] = eNB_mac_inst[module_idP].UE_template[next_ue].rballoc_subband[harq_pid][j]; + + + // decrease mcs until TBS falls below required length + while ((TBS > (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && (mcs>0)) { + mcs--; + TBS = mac_xface->get_TBS_DL(mcs,nb_rb); + } + + // if we have decreased too much or we don't have enough RBs, increase MCS + while ((TBS < (sdu_length_total + header_len_dcch + header_len_dtch + ta_len)) && ((( dl_pow_off[next_ue]>0) && (mcs<28)) || ( (dl_pow_off[next_ue]==0) && (mcs<=15)))) { + mcs++; + TBS = mac_xface->get_TBS_DL(mcs,nb_rb); + } + + LOG_D(MAC,"dlsch_mcs before and after the rate matching = (%d, %d)\n",eNB_UE_stats->dlsch_mcs1, mcs); #ifdef DEBUG_eNB_SCHEDULER - LOG_D(MAC,"[eNB %d] Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", - Mod_id,mcs,TBS,nb_rb); - // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", - // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); + LOG_D(MAC,"[eNB %d] Generated DLSCH header (mcs %d, TBS %d, nb_rb %d)\n", + module_idP,mcs,TBS,nb_rb); + // msg("[MAC][eNB ] Reminder of DLSCH with random data %d %d %d %d \n", + // TBS, sdu_length_total, offset, TBS-sdu_length_total-offset); #endif - if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) { - padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len); - post_padding = 0; - } - else { - padding = 0; - // adjust the header len - if (header_len_dtch==0) - header_len_dcch = header_len_dcch_tmp; - else //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) - header_len_dtch = header_len_dtch_tmp; - - post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len ; // 1 is for the postpadding header - } + if ((TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len) <= 2) { + padding = (TBS - header_len_dcch - header_len_dtch - sdu_length_total - ta_len); + post_padding = 0; + } + else { + padding = 0; + // adjust the header len + if (header_len_dtch==0) + header_len_dcch = header_len_dcch_tmp; + else //if (( header_len_dcch==0)&&((header_len_dtch==1)||(header_len_dtch==2))) + header_len_dtch = header_len_dtch_tmp; + + post_padding = TBS - sdu_length_total - header_len_dcch - header_len_dtch - ta_len ; // 1 is for the postpadding header + } #ifndef EXMIMO_IOT - ta_update = eNB_UE_stats->timing_advance_update/4; -#else - ta_update = 0; + ta_update = eNB_UE_stats->timing_advance_update/4; +#else + ta_update = 0; #endif - offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0], - // offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0], - num_sdus, //num_sdus - sdu_lengths, // - sdu_lcids, - 255, // no drx - ta_update, // timing advance - NULL, // contention res id - padding, - post_padding); - //#ifdef DEBUG_eNB_SCHEDULER - LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, next_ue %d,padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", - Mod_id,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset, - ta_len,next_ue,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); - //#endif - - LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); - for (i=0;i<16;i++) - LOG_T(MAC,"%x.",dlsch_buffer[i]); - LOG_T(MAC,"\n"); - - // cycle through SDUs and place in dlsch_buffer - memcpy(&eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0][offset],dlsch_buffer,sdu_length_total); - // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); - - // fill remainder of DLSCH with random data - for (j=0;j<(TBS-sdu_length_total-offset);j++) - eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); - //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); + offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[module_idP].DLSCH_pdu[(module_id_t)next_ue][0].payload[0], + // offset = generate_dlsch_header((unsigned char*)eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0], + num_sdus, //num_sdus + sdu_lengths, // + sdu_lcids, + 255, // no drx + ta_update, // timing advance + NULL, // contention res id + padding, + post_padding); + //#ifdef DEBUG_eNB_SCHEDULER + LOG_I(MAC,"[eNB %d][USER-PLANE DEFAULT DRB] Generate header : sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d,timing advance value : %d, next_ue %d,padding %d,post_padding %d,(mcs %d, TBS %d, nb_rb %d),header_dcch %d, header_dtch %d\n", + module_idP,sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],offset, + ta_len,next_ue,padding,post_padding,mcs,TBS,nb_rb,header_len_dcch,header_len_dtch); + //#endif + + LOG_T(MAC,"[eNB %d] First 16 bytes of DLSCH : \n"); + for (i=0;i<16;i++) + LOG_T(MAC,"%x.",dlsch_buffer[i]); + LOG_T(MAC,"\n"); + + // cycle through SDUs and place in dlsch_buffer + memcpy(&eNB_mac_inst[module_idP].DLSCH_pdu[(module_id_t)next_ue][0].payload[0][offset],dlsch_buffer,sdu_length_total); + // memcpy(&eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset],dcch_buffer,sdu_lengths[0]); + + // fill remainder of DLSCH with random data + for (j=0;j<(TBS-sdu_length_total-offset);j++) + eNB_mac_inst[module_idP].DLSCH_pdu[(module_id_t)next_ue][0].payload[0][offset+sdu_length_total+j] = (char)(taus()&0xff); + //eNB_mac_inst[0].DLSCH_pdu[0][0].payload[0][offset+sdu_lengths[0]+j] = (char)(taus()&0xff); #if defined(USER_MODE) && defined(OAI_EMU) - /* Tracing of PDU is done on UE side */ - if (oai_emulation.info.opt_enabled) - trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].DLSCH_pdu[(unsigned char)next_ue][0].payload[0], - TBS, Mod_id, 3, find_UE_RNTI(Mod_id,next_ue), - eNB_mac_inst[Mod_id].subframe,0,0); - LOG_D(OPT,"[eNB %d][DLSCH] Frame %d rnti %x with size %d\n", - Mod_id, frame, find_UE_RNTI(Mod_id,next_ue), TBS); + /* Tracing of PDU is done on UE side */ + if (oai_emulation.info.opt_enabled) + trace_pdu(1, (uint8_t *)eNB_mac_inst[module_idP].DLSCH_pdu[(module_id_t)next_ue][0].payload[0], + TBS, module_idP, 3, find_UE_RNTI(module_idP,next_ue), + eNB_mac_inst[module_idP].subframe,0,0); + LOG_D(OPT,"[eNB %d][DLSCH] Frame %d rnti %x with size %d\n", + module_idP, frameP, find_UE_RNTI(module_idP,next_ue), TBS); #endif - aggregation = process_ue_cqi(Mod_id,next_ue); - nCCE-=(1<<aggregation); // adjust the remaining nCCE - *nCCE_used+=(1<<aggregation); // adjust the remaining nCCE - eNB_mac_inst[Mod_id].UE_template[next_ue].nb_rb[harq_pid] = nb_rb; - - add_ue_dlsch_info(Mod_id, - next_ue, - subframe, - S_DL_SCHEDULED); - // store stats - eNB_mac_inst[Mod_id].eNB_stats.dlsch_bytes_tx+=sdu_length_total; - eNB_mac_inst[Mod_id].eNB_stats.dlsch_pdus_tx+=1; - - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].rbs_used = nb_rb; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].total_rbs_used += nb_rb; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].ncce_used = nCCE; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].dlsch_mcs2=mcs; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].TBS = TBS; - - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].overhead_bytes= TBS- sdu_length_total; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].total_sdu_bytes+= sdu_length_total; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].total_pdu_bytes+= TBS; - eNB_mac_inst[Mod_id].eNB_UE_stats[next_ue].total_num_pdus+=1; - - if (mac_xface->lte_frame_parms->frame_type == TDD) { - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI++; - // printf("DAI update: subframe %d: UE %d, DAI %d\n",subframe,next_ue,eNB_mac_inst[Mod_id].UE_template[next_ue].DAI); - - update_ul_dci(Mod_id,rnti,eNB_mac_inst[Mod_id].UE_template[next_ue].DAI); - } - - switch (mac_xface->get_transmission_mode(Mod_id,rnti)) { - case 1: - case 2: - default: - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; - ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - break; - case 25: - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"Format1 DCI: harq_pid %d, ndi %d\n",harq_pid,((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi); - break; - case 50: - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rv = 0; - ((DCI1_10MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - break; - case 100: - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rv = 0; - ((DCI1_20MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - break; - default: - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; - ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - break; - } - } - else { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; - break; - case 25: - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; - break; - case 50: - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rv = 0; - break; - case 100: - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rv = 0; - break; - default: - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; - break; - } - } - break; - case 4: - // if (nb_rb>10) { - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs1 = mcs; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi1 = 1; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv1 = round&3; - ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - - //} - /* else { + aggregation = process_ue_cqi(module_idP,next_ue); + nCCE-=(1<<aggregation); // adjust the remaining nCCE + *nCCE_used+=(1<<aggregation); // adjust the remaining nCCE + eNB_mac_inst[module_idP].UE_template[next_ue].nb_rb[harq_pid] = nb_rb; + + add_ue_dlsch_info(module_idP, + next_ue, + subframeP, + S_DL_SCHEDULED); + // store stats + eNB_mac_inst[module_idP].eNB_stats.dlsch_bytes_tx+=sdu_length_total; + eNB_mac_inst[module_idP].eNB_stats.dlsch_pdus_tx+=1; + + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].rbs_used = nb_rb; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].total_rbs_used += nb_rb; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].ncce_used = nCCE; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].dlsch_mcs1=eNB_UE_stats->dlsch_mcs1; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].dlsch_mcs2=mcs; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].TBS = TBS; + + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].overhead_bytes= TBS- sdu_length_total; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].total_sdu_bytes+= sdu_length_total; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].total_pdu_bytes+= TBS; + eNB_mac_inst[module_idP].eNB_UE_stats[next_ue].total_num_pdus+=1; + + if (mac_xface->lte_frame_parms->frame_type == TDD) { + eNB_mac_inst[module_idP].UE_template[next_ue].DAI++; + // printf("DAI update: subframeP %d: UE %d, DAI %d\n",subframeP,next_ue,eNB_mac_inst[module_idP].UE_template[next_ue].DAI); + + update_ul_dci(module_idP,rnti,eNB_mac_inst[module_idP].UE_template[next_ue].DAI); + } + + switch (mac_xface->get_transmission_mode(module_idP,rnti)) { + case 1: + case 2: + default: + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; + ((DCI1_1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + break; + case 25: + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"Format1 DCI: harq_pid %d, ndi %d\n",harq_pid,((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi); + break; + case 50: + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->rv = 0; + ((DCI1_10MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + break; + case 100: + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->rv = 0; + ((DCI1_20MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + break; + default: + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->rv = 0; + ((DCI1_5MHz_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + break; + } + } + else { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; + break; + case 25: + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; + break; + case 50: + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_10MHz_FDD_t*)DLSCH_dci)->rv = 0; + break; + case 100: + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_20MHz_FDD_t*)DLSCH_dci)->rv = 0; + break; + default: + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->ndi = 1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + ((DCI1_5MHz_FDD_t*)DLSCH_dci)->rv = 0; + break; + } + } + break; + case 4: + // if (nb_rb>10) { + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs1 = mcs; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi1 = 1; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv1 = round&3; + ((DCI2_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + + //} + /* else { ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->mcs1 = eNB_UE_stats->DL_cqi[0]; ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->ndi1 = 1; ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->rv1 = round&3; ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; - ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; + ((DCI2_5MHz_2A_L10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; }*/ - break; - case 5: - - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - if(dl_pow_off[next_ue] == 2) - dl_pow_off[next_ue] = 1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[next_ue]; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; - break; - case 6: - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = mcs; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = 1; - ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; - break; - } - // Toggle NDI for next time - LOG_D(MAC,"Frame %d, subframe %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",frame,subframe,next_ue, - eNB_mac_inst[Mod_id].UE_template[next_ue].rnti,harq_pid,eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]); - eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]=1-eNB_mac_inst[Mod_id].UE_template[next_ue].oldNDI[harq_pid]; - } - - else { // There is no data from RLC or MAC header, so don't schedule - + break; + case 5: + + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + if(dl_pow_off[next_ue] == 2) + dl_pow_off[next_ue] = 1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = dl_pow_off[next_ue]; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; + break; + case 6: + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->mcs = mcs; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->harq_pid = harq_pid; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->ndi = 1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->rv = round&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dai = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->dl_power_off = 1; + ((DCI1E_5MHz_2A_M10PRB_TDD_t*)DLSCH_dci)->tpmi = 5; + break; + } + // Toggle NDI for next time + LOG_D(MAC,"Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n",frameP,subframeP,next_ue, + eNB_mac_inst[module_idP].UE_template[next_ue].rnti,harq_pid,eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]); + eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]=1-eNB_mac_inst[module_idP].UE_template[next_ue].oldNDI[harq_pid]; + } + + else { // There is no data from RLC or MAC header, so don't schedule + + } } - } - if (mac_xface->lte_frame_parms->frame_type == TDD) { - DAI = (eNB_mac_inst[Mod_id].UE_template[next_ue].DAI-1)&3; - LOG_D(MAC,"[eNB %d] Frame %d: DAI %d for UE %d\n",Mod_id,frame,DAI,next_ue); - // Save DAI for Format 0 DCI - - switch (mac_xface->lte_frame_parms->tdd_config) { - case 0: - // if ((subframe==0)||(subframe==1)||(subframe==5)||(subframe==6)) - break; - case 1: - switch (subframe) { - case 1: - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[7] = DAI; - break; - case 4: - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[8] = DAI; - break; - case 6: - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[2] = DAI; - break; - case 9: - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[3] = DAI; - break; - } - case 2: - // if ((subframe==3)||(subframe==8)) - // eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul = DAI; - break; - case 3: - if ((subframe==6)||(subframe==8)||(subframe==0)) { - LOG_D(MAC,"schedule_ue_spec: setting UL DAI to %d for subframe %d => %d\n",DAI,subframe, ((subframe+8)%10)>>1); - eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul[((subframe+8)%10)>>1] = DAI; - } - break; - case 4: - // if ((subframe==8)||(subframe==9)) - // eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul = DAI; - break; - case 5: - // if (subframe==8) - // eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul = DAI; - break; - case 6: - // if ((subframe==1)||(subframe==4)||(subframe==6)||(subframe==9)) - // eNB_mac_inst[Mod_id].UE_template[next_ue].DAI_ul = DAI; - break; - default: - break; + if (mac_xface->lte_frame_parms->frame_type == TDD) { + DAI = (eNB_mac_inst[module_idP].UE_template[next_ue].DAI-1)&3; + LOG_D(MAC,"[eNB %d] Frame %d: DAI %d for UE %d\n",module_idP,frameP,DAI,next_ue); + // Save DAI for Format 0 DCI + + switch (mac_xface->lte_frame_parms->tdd_config) { + case 0: + // if ((subframeP==0)||(subframeP==1)||(subframeP==5)||(subframeP==6)) + break; + case 1: + switch (subframeP) { + case 1: + eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[7] = DAI; + break; + case 4: + eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[8] = DAI; + break; + case 6: + eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[2] = DAI; + break; + case 9: + eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[3] = DAI; + break; + } + case 2: + // if ((subframeP==3)||(subframeP==8)) + // eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul = DAI; + break; + case 3: + if ((subframeP==6)||(subframeP==8)||(subframeP==0)) { + LOG_D(MAC,"schedule_ue_spec: setting UL DAI to %d for subframeP %d => %d\n",DAI,subframeP, ((subframeP+8)%10)>>1); + eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul[((subframeP+8)%10)>>1] = DAI; + } + break; + case 4: + // if ((subframeP==8)||(subframeP==9)) + // eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul = DAI; + break; + case 5: + // if (subframeP==8) + // eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul = DAI; + break; + case 6: + // if ((subframeP==1)||(subframeP==4)||(subframeP==6)||(subframeP==9)) + // eNB_mac_inst[module_idP].UE_template[next_ue].DAI_ul = DAI; + break; + default: + break; + } } - } - //printf("MAC nCCE : %d\n",*nCCE_used); + //printf("MAC nCCE : %d\n",*nCCE_used); } } -void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subframe) {//, int calibration_flag) { +void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,u8 cooperation_flag, frame_t frameP, sub_frame_t subframeP) {//, int calibration_flag) { unsigned char nprb=0; unsigned int nCCE=0; @@ -4250,77 +4302,77 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf int result; #endif - DCI_PDU *DCI_pdu= &eNB_mac_inst[Mod_id].DCI_pdu; - // LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler\n",Mod_id, frame, subframe); + DCI_PDU *DCI_pdu= &eNB_mac_inst[module_idP].DCI_pdu; + // LOG_D(MAC,"[eNB %d] Frame %d, Subframe %d, entering MAC scheduler\n",module_idP, frameP, subframeP); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,1); #if defined(ENABLE_ITTI) do { - // Checks if a message has been sent to MAC sub-task - itti_poll_msg (TASK_MAC_ENB, &msg_p); + // Checks if a message has been sent to MAC sub-task + itti_poll_msg (TASK_MAC_ENB, &msg_p); - if (msg_p != NULL) { - msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); + if (msg_p != NULL) { + msg_name = ITTI_MSG_NAME (msg_p); + instance = ITTI_MSG_INSTANCE (msg_p); - switch (ITTI_MSG_ID(msg_p)) { - case MESSAGE_TEST: - LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p)); - break; + switch (ITTI_MSG_ID(msg_p)) { + case MESSAGE_TEST: + LOG_D(MAC, "Received %s\n", ITTI_MSG_NAME(msg_p)); + break; - case RRC_MAC_BCCH_DATA_REQ: - LOG_D(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n", + case RRC_MAC_BCCH_DATA_REQ: + LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, - RRC_MAC_BCCH_DATA_REQ (msg_p).frame, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index); + RRC_MAC_BCCH_DATA_REQ (msg_p).frameP, RRC_MAC_BCCH_DATA_REQ (msg_p).enb_index); - // TODO process BCCH data req. - break; + // TODO process BCCH data req. + break; - case RRC_MAC_CCCH_DATA_REQ: - LOG_D(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n", + case RRC_MAC_CCCH_DATA_REQ: + LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, - RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index); + RRC_MAC_CCCH_DATA_REQ (msg_p).frameP, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index); - // TODO process CCCH data req. - break; + // TODO process CCCH data req. + break; #ifdef Rel10 - case RRC_MAC_MCCH_DATA_REQ: - LOG_D(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d, mbsfn_sync_area %d\n", + case RRC_MAC_MCCH_DATA_REQ: + LOG_D(MAC, "Received %s from %s: instance %d, frameP %d, eNB_index %d, mbsfn_sync_area %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, - RRC_MAC_MCCH_DATA_REQ (msg_p).frame, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area); + RRC_MAC_MCCH_DATA_REQ (msg_p).frameP, RRC_MAC_MCCH_DATA_REQ (msg_p).enb_index, RRC_MAC_MCCH_DATA_REQ (msg_p).mbsfn_sync_area); - // TODO process MCCH data req. - break; + // TODO process MCCH data req. + break; #endif - default: - LOG_E(MAC, "Received unexpected message %s\n", msg_name); - break; - } + default: + LOG_E(MAC, "Received unexpected message %s\n", msg_name); + break; + } - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } } while(msg_p != NULL); #endif -// clear DCI and BCCH contents before scheduling + // clear DCI and BCCH contents before scheduling DCI_pdu->Num_common_dci = 0; DCI_pdu->Num_ue_spec_dci = 0; - eNB_mac_inst[Mod_id].bcch_active = 0; + eNB_mac_inst[module_idP].bcch_active = 0; #ifdef Rel10 - eNB_mac_inst[Mod_id].mcch_active =0; + eNB_mac_inst[module_idP].mcch_active =0; #endif - eNB_mac_inst[Mod_id].frame = frame; - eNB_mac_inst[Mod_id].subframe = subframe; + eNB_mac_inst[module_idP].frame = frameP; + eNB_mac_inst[module_idP].subframe = subframeP; - //if (subframe%5 == 0) + //if (subframeP%5 == 0) #ifdef EXMIMO - pdcp_run(frame, 1, 0, Mod_id); + pdcp_run(frameP, 1, 0, module_idP); /* ret = pthread_mutex_trylock (&pdcp_mutex); if (ret != 0) { @@ -4333,7 +4385,7 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf else { pdcp_instance_cnt++; pthread_mutex_unlock(&pdcp_mutex); - + if (pdcp_instance_cnt == 0) { if (pthread_cond_signal(&pdcp_cond) != 0) { LOG_E(PDCP,"pthread_cond_signal unsuccessfull\n"); @@ -4344,132 +4396,132 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf LOG_W(PDCP,"PDCP thread busy!!! inst_cnt=%d\n",pdcp_instance_cnt); } } - */ + */ #endif #ifdef CELLULAR - rrc_rx_tx(Mod_id, frame, 0, 0); + rrc_rx_tx(module_idP, frameP, 0, 0); #else // check HO - rrc_rx_tx(Mod_id, - frame, - 1, - Mod_id); + rrc_rx_tx(module_idP, + frameP, + 1, + module_idP); #endif #ifdef Rel10 - if (eNB_mac_inst[Mod_id].MBMS_flag >0) { + if (eNB_mac_inst[module_idP].MBMS_flag >0) { - mbsfn_status = schedule_MBMS(Mod_id,frame,subframe); + mbsfn_status = schedule_MBMS(module_idP,frameP,subframeP); } #endif - switch (subframe) { + switch (subframeP) { case 0: // FDD/TDD Schedule Downlink RA transmissions (RA response, Msg4 Contention resolution) - // Schedule ULSCH for FDD or subframe 4 (TDD config 0,3,6) + // Schedule ULSCH for FDD or subframeP 4 (TDD config 0,3,6) // Schedule Normal DLSCH - - schedule_RA(Mod_id,frame,subframe,2,&nprb,&nCCE); + + schedule_RA(module_idP,frameP,subframeP,2,&nprb,&nCCE); if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD - schedule_ulsch(Mod_id,frame,cooperation_flag,0,4,&nCCE);//,calibration_flag); + schedule_ulsch(module_idP,frameP,cooperation_flag,0,4,&nCCE);//,calibration_flag); } else if ((mac_xface->lte_frame_parms->tdd_config == TDD) || //TDD - (mac_xface->lte_frame_parms->tdd_config == 3) || - (mac_xface->lte_frame_parms->tdd_config == 6)) - //schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,4,&nCCE);//,calibration_flag); + (mac_xface->lte_frame_parms->tdd_config == 3) || + (mac_xface->lte_frame_parms->tdd_config == 6)) + //schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,&nCCE);//,calibration_flag); + - - // schedule_ue_spec(Mod_id,subframe,nprb,&nCCE,mbsfn_status); + // schedule_ue_spec(module_idP,subframeP,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,1,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); break; case 1: - // TDD, schedule UL for subframe 7 (TDD config 0,1) / subframe 8 (TDD Config 6) + // TDD, schedule UL for subframeP 7 (TDD config 0,1) / subframeP 8 (TDD Config 6) // FDD, schedule normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD - switch (mac_xface->lte_frame_parms->tdd_config) { - case 0: - case 1: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,7,&nCCE); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - case 6: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,8,&nCCE); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 0: + case 1: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,&nCCE); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + case 6: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,&nCCE); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + default: + break; + } } else { //FDD - schedule_ulsch(Mod_id,frame,cooperation_flag,1,5,&nCCE); - // schedule_ue_spec(Mod_id,subframe,nprb,&nCCE,mbsfn_status); - // fill_DLSCH_dci(Mod_id,subframe,RBalloc,0,mbsfn_status); + schedule_ulsch(module_idP,frameP,cooperation_flag,1,5,&nCCE); + // schedule_ue_spec(module_idP,subframeP,nprb,&nCCE,mbsfn_status); + // fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status); } break; case 2: - // TDD, nothing + // TDD, nothing // FDD, normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD - schedule_ulsch(Mod_id,frame,cooperation_flag,2,6,&nCCE); - // schedule_ue_spec(Mod_id,subframe,nprb,&nCCE,mbsfn_status); - // fill_DLSCH_dci(Mod_id,subframe,RBalloc,0,mbsfn_status); + schedule_ulsch(module_idP,frameP,cooperation_flag,2,6,&nCCE); + // schedule_ue_spec(module_idP,subframeP,nprb,&nCCE,mbsfn_status); + // fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status); } break; case 3: - // TDD Config 2, ULSCH for subframe 7 + // TDD Config 2, ULSCH for subframeP 7 // TDD Config 2/5 normal DLSCH // FDD, normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->tdd_config) { - case 2: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,7,&nCCE); - case 5: - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 2: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,7,&nCCE); + case 5: + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + default: + break; + } } else { //FDD - // schedule_ulsch(Mod_id,frame,cooperation_flag,3,7,&nCCE); - // schedule_ue_spec(Mod_id,subframe,0,0,mbsfn_status); - // fill_DLSCH_dci(Mod_id,subframe,RBalloc,0,mbsfn_status); + // schedule_ulsch(module_idP,frameP,cooperation_flag,3,7,&nCCE); + // schedule_ue_spec(module_idP,subframeP,0,0,mbsfn_status); + // fill_DLSCH_dci(module_idP,subframeP,RBalloc,0,mbsfn_status); } break; case 4: - // TDD Config 1, ULSCH for subframe 8 + // TDD Config 1, ULSCH for subframeP 8 // TDD Config 1/2/4/5 DLSCH // FDD UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == 1) { // TDD - switch (mac_xface->lte_frame_parms->tdd_config) { - case 1: - // schedule_RA(Mod_id,frame,subframe,&nprb,&nCCE); - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,8,&nCCE); - case 2: - case 4: - case 5: - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,1,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 1: + // schedule_RA(module_idP,frameP,subframeP,&nprb,&nCCE); + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,8,&nCCE); + case 2: + case 4: + case 5: + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); + break; + default: + break; + } } else { - if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD - schedule_RA(Mod_id, frame, subframe, 0, &nprb, &nCCE); - // schedule_ulsch(Mod_id, frame, cooperation_flag, 4, 8, &nCCE); - //schedule_ue_spec(Mod_id, frame, subframe, nprb, &nCCE, mbsfn_status); - fill_DLSCH_dci(Mod_id, frame, subframe, RBalloc, 1, mbsfn_status); + if (mac_xface->lte_frame_parms->frame_type == FDD) { //FDD + schedule_RA(module_idP, frameP, subframeP, 0, &nprb, &nCCE); + // schedule_ulsch(module_idP, frameP, cooperation_flag, 4, 8, &nCCE); + //schedule_ue_spec(module_idP, frameP, subframeP, nprb, &nCCE, mbsfn_status); + fill_DLSCH_dci(module_idP, frameP, subframeP, RBalloc, 1, mbsfn_status); - } + } } break; @@ -4478,22 +4530,22 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf // TDD Config 0,6 ULSCH for subframes 9,3 resp. // TDD normal DLSCH // FDD normal UL/DLSCH - schedule_SI(Mod_id,frame,&nprb,&nCCE); - //schedule_RA(Mod_id,frame,subframe,5,&nprb,&nCCE); + schedule_SI(module_idP,frameP,&nprb,&nCCE); + //schedule_RA(module_idP,frameP,subframeP,5,&nprb,&nCCE); if ((mac_xface->lte_frame_parms->frame_type == FDD) ) { - // schedule_RA(Mod_id,frame,subframe,1,&nprb,&nCCE); - // schedule_ulsch(Mod_id,frame,cooperation_flag,5,9,&nCCE); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + // schedule_RA(module_idP,frameP,subframeP,1,&nprb,&nCCE); + // schedule_ulsch(module_idP,frameP,cooperation_flag,5,9,&nCCE); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } else if ((mac_xface->lte_frame_parms->tdd_config == 0) || // TDD Config 0 - (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6 - //schedule_ulsch(Mod_id,cooperation_flag,subframe,&nCCE); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + (mac_xface->lte_frame_parms->tdd_config == 6)) { // TDD Config 6 + //schedule_ulsch(module_idP,cooperation_flag,subframeP,&nCCE); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } else { - //schedule_ue_spec(Mod_id,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + //schedule_ue_spec(module_idP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; @@ -4502,137 +4554,137 @@ void eNB_dlsch_ulsch_scheduler(u8 Mod_id,u8 cooperation_flag, u32 frame, u8 subf // TDD Config 3,4,5 Normal DLSCH // FDD normal ULSCH/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD - switch (mac_xface->lte_frame_parms->tdd_config) { - case 0: - break; - case 1: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,2,&nCCE); - // schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - case 6: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,3,&nCCE); - // schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - case 5: - schedule_RA(Mod_id,frame,subframe,2,&nprb,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,1,mbsfn_status); - break; - case 3: - case 4: - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 0: + break; + case 1: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,&nCCE); + // schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + case 6: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,&nCCE); + // schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + case 5: + schedule_RA(module_idP,frameP,subframeP,2,&nprb,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); + break; + case 3: + case 4: + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + + default: + break; + } } else { //FDD - // schedule_ulsch(Mod_id,frame,cooperation_flag,6,0,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + // schedule_ulsch(module_idP,frameP,cooperation_flag,6,0,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; - + case 7: // TDD Config 3,4,5 Normal DLSCH // FDD Normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD - switch (mac_xface->lte_frame_parms->tdd_config) { - case 3: - case 4: - // schedule_RA(Mod_id,frame,subframe,3,&nprb,&nCCE); // 3 = Msg3 subframe, not - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); //1,mbsfn_status); - break; - case 5: - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 3: + case 4: + // schedule_RA(module_idP,frameP,subframeP,3,&nprb,&nCCE); // 3 = Msg3 subframeP, not + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); //1,mbsfn_status); + break; + case 5: + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + default: + break; + } } else { //FDD - // schedule_ulsch(Mod_id,frame,cooperation_flag,7,1,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,nprb,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + // schedule_ulsch(module_idP,frameP,cooperation_flag,7,1,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,nprb,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 8: - // TDD Config 2,3,4,5 ULSCH for subframe 2 + // TDD Config 2,3,4,5 ULSCH for subframeP 2 // // FDD Normal UL/DLSCH if (mac_xface->lte_frame_parms->frame_type == TDD) { // TDD - switch (mac_xface->lte_frame_parms->tdd_config) { - case 2: - case 3: - case 4: - case 5: - - // schedule_RA(Mod_id,subframe,&nprb,&nCCE); - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,2,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 2: + case 3: + case 4: + case 5: + + // schedule_RA(module_idP,subframeP,&nprb,&nCCE); + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,2,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + default: + break; + } } else { //FDD - // schedule_ulsch(Mod_id,frame,cooperation_flag,8,2,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + // schedule_ulsch(module_idP,frameP,cooperation_flag,8,2,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; case 9: // TDD Config 1,3,4,6 ULSCH for subframes 3,3,3,4 if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->tdd_config) { - case 1: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,3,&nCCE); - schedule_RA(Mod_id,frame,subframe,7,&nprb,&nCCE); // 7 = Msg3 subframe, not - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,1,mbsfn_status); - break; - case 3: - case 4: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,3,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - case 6: - schedule_ulsch(Mod_id,frame,cooperation_flag,subframe,4,&nCCE); - //schedule_RA(Mod_id,frame,subframe,&nprb,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - case 2: - case 5: - //schedule_RA(Mod_id,frame,subframe,&nprb,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); - break; - default: - break; - } + switch (mac_xface->lte_frame_parms->tdd_config) { + case 1: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,&nCCE); + schedule_RA(module_idP,frameP,subframeP,7,&nprb,&nCCE); // 7 = Msg3 subframeP, not + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,1,mbsfn_status); + break; + case 3: + case 4: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,3,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + case 6: + schedule_ulsch(module_idP,frameP,cooperation_flag,subframeP,4,&nCCE); + //schedule_RA(module_idP,frameP,subframeP,&nprb,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + case 2: + case 5: + //schedule_RA(module_idP,frameP,subframeP,&nprb,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); + break; + default: + break; + } } else { //FDD - // schedule_ulsch(Mod_id,frame,cooperation_flag,9,3,&nCCE); - schedule_ue_spec(Mod_id,frame,subframe,0,&nCCE,mbsfn_status); - fill_DLSCH_dci(Mod_id,frame,subframe,RBalloc,0,mbsfn_status); + // schedule_ulsch(module_idP,frameP,cooperation_flag,9,3,&nCCE); + schedule_ue_spec(module_idP,frameP,subframeP,0,&nCCE,mbsfn_status); + fill_DLSCH_dci(module_idP,frameP,subframeP,RBalloc,0,mbsfn_status); } break; - + } DCI_pdu->nCCE = nCCE; - LOG_D(MAC,"frame %d, subframe %d nCCE %d\n",frame,subframe,nCCE); + LOG_D(MAC,"frameP %d, subframeP %d nCCE %d\n",frameP,subframeP,nCCE); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER,0); } diff --git a/openair2/LAYER2/MAC/l1_helpers.c b/openair2/LAYER2/MAC/l1_helpers.c index e98403fa36782acd004fcce7b1ac29fc3e4cab6d..21efccfe214e3af36f7621bcdeaa85badf7ce3b3 100644 --- a/openair2/LAYER2/MAC/l1_helpers.c +++ b/openair2/LAYER2/MAC/l1_helpers.c @@ -39,23 +39,23 @@ #include "extern.h" #include "UTIL/LOG/log.h" -s8 get_Po_NOMINAL_PUSCH(u8 Mod_id) { +s8 get_Po_NOMINAL_PUSCH(module_id_t module_idP) { RACH_ConfigCommon_t *rach_ConfigCommon = NULL; - if (UE_mac_inst[Mod_id].radioResourceConfigCommon) - rach_ConfigCommon = &UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon; + if (UE_mac_inst[module_idP].radioResourceConfigCommon) + rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; else { - LOG_E(MAC,"[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",Mod_id); + LOG_E(MAC,"[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",module_idP); mac_xface->macphy_exit(""); } return(-120 + (rach_ConfigCommon->powerRampingParameters.preambleInitialReceivedTargetPower<<1) + - get_DELTA_PREAMBLE(Mod_id)); + get_DELTA_PREAMBLE(module_idP)); } -s8 get_deltaP_rampup(u8 Mod_id) { +s8 get_deltaP_rampup(module_id_t module_idP) { - LOG_D(MAC,"[PUSCH]%d dB\n",UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER<<1); - return((s8)(UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER<<1)); + LOG_D(MAC,"[PUSCH]%d dB\n",UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER<<1); + return((s8)(UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER<<1)); } diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c index 1fc5d38a5afe1d63a83a7c0ffd68531bce0f8395..e3ada9a31960ca436c7a43d43cefe54a431d711e 100644 --- a/openair2/LAYER2/MAC/main.c +++ b/openair2/LAYER2/MAC/main.c @@ -25,16 +25,16 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file main.c -* \brief top init of Layer 2 -* \author Raymond Knopp and Navid Nikaein -* \date 2011 -* \version 0.5 -* \email: navid.nikaein@eurecom.fr -* @ingroup _mac + * \brief top init of Layer 2 + * \author Raymond Knopp and Navid Nikaein + * \date 2011 + * \version 0.5 + * \email: navid.nikaein@eurecom.fr + * @ingroup _mac -*/ + */ #ifdef USER_MODE #include "LAYER2/register.h" @@ -74,98 +74,94 @@ /***********************************************************************/ -void dl_phy_sync_success(unsigned char Mod_id, - u32 frame, - unsigned char eNB_index, - u8 first_sync){ //init as MR -/***********************************************************************/ - LOG_D(MAC,"[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", Mod_id, frame, eNB_index); +void dl_phy_sync_success(module_id_t module_idP, + frame_t frameP, + unsigned char eNB_index, + u8 first_sync){ //init as MR + /***********************************************************************/ + LOG_D(MAC,"[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", module_idP, frameP, eNB_index); if (first_sync==1) { - layer2_init_UE(Mod_id); - openair_rrc_ue_init(Mod_id,eNB_index); + layer2_init_UE(module_idP); + openair_rrc_ue_init(module_idP,eNB_index); } else { - mac_in_sync_ind(Mod_id,frame,eNB_index); + mac_in_sync_ind(module_idP,frameP,eNB_index); } - + } /***********************************************************************/ -void mrbch_phy_sync_failure(u8 Mod_id, u32 frame, u8 free_eNB_index){//init as CH +void mrbch_phy_sync_failure(module_id_t module_idP, frame_t frameP, u8 free_eNB_index){//init as CH /***********************************************************************/ - LOG_I(MAC,"[eNB %d] Frame %d: PHY Sync failure \n",Mod_id,frame); - layer2_init_eNB(Mod_id, free_eNB_index); - openair_rrc_eNB_init(Mod_id); - - - - + LOG_I(MAC,"[eNB %d] Frame %d: PHY Sync failure \n",module_idP,frameP); + layer2_init_eNB(module_idP, free_eNB_index); + openair_rrc_eNB_init(module_idP); } -char layer2_init_eNB(unsigned char Mod_id, unsigned char eNB_index){ +char layer2_init_eNB(module_id_t module_idP, unsigned char eNB_index){ return 0; } /***********************************************************************/ -char layer2_init_UE(unsigned char Mod_id){ - +char layer2_init_UE(module_id_t module_idP){ + return 0; } /***********************************************************************/ -void mac_UE_out_of_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index){ -/***********************************************************************/ +void mac_UE_out_of_sync_ind(module_id_t module_idP, frame_t frameP, u16 eNB_index){ + /***********************************************************************/ -// Mac_rlc_xface->mac_out_of_sync_ind(Mod_id, frame, eNB_index); + // Mac_rlc_xface->mac_out_of_sync_ind(Mod_id, frameP, eNB_index); } /***********************************************************************/ int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active){ -/***********************************************************************/ - unsigned char Mod_id,i,j; + /***********************************************************************/ + module_id_t Mod_id,i,j; RA_TEMPLATE *RA_template; UE_TEMPLATE *UE_template; int size_bytes1,size_bytes2,size_bits1,size_bits2; LOG_I(MAC,"[MAIN] Init function start:Nb_UE_INST=%d\n",NB_UE_INST); if (NB_UE_INST>0) { - UE_mac_inst = (UE_MAC_INST*)malloc16(NB_UE_INST*sizeof(UE_MAC_INST)); - if (UE_mac_inst == NULL) { - LOG_C(MAC,"[MAIN] Can't ALLOCATE %d Bytes for %d UE_MAC_INST with size %d \n",NB_UE_INST*sizeof(UE_MAC_INST),NB_UE_INST,sizeof(UE_MAC_INST)); - 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)); - for(i=0;i<NB_UE_INST; i++) - ue_init_mac(i); - + UE_mac_inst = (UE_MAC_INST*)malloc16(NB_UE_INST*sizeof(UE_MAC_INST)); + if (UE_mac_inst == NULL) { + LOG_C(MAC,"[MAIN] Can't ALLOCATE %d Bytes for %d UE_MAC_INST with size %d \n",NB_UE_INST*sizeof(UE_MAC_INST),NB_UE_INST,sizeof(UE_MAC_INST)); + 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)); + for(i=0;i<NB_UE_INST; i++) + ue_init_mac(i); + } else UE_mac_inst = NULL; - + LOG_I(MAC,"[MAIN] Init function start:Nb_eNB_INST=%d\n",NB_eNB_INST); if (NB_eNB_INST>0) { - eNB_mac_inst = (eNB_MAC_INST*)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST)); - if (eNB_mac_inst == NULL){ - LOG_D(MAC,"[MAIN] can't ALLOCATE %d Bytes for %d eNB_MAC_INST with size %d \n",NB_eNB_INST*sizeof(eNB_MAC_INST),NB_eNB_INST,sizeof(eNB_MAC_INST)); - mac_xface->macphy_exit("[MAC][MAIN] not enough memory for eNB \n"); - } - LOG_D(MAC,"[MAIN] ALLOCATE %d Bytes for %d eNB_MAC_INST @ %p\n",NB_eNB_INST*sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst); - bzero(eNB_mac_inst,NB_eNB_INST*sizeof(eNB_MAC_INST)); + eNB_mac_inst = (eNB_MAC_INST*)malloc16(NB_eNB_INST*sizeof(eNB_MAC_INST)); + if (eNB_mac_inst == NULL){ + LOG_D(MAC,"[MAIN] can't ALLOCATE %d Bytes for %d eNB_MAC_INST with size %d \n",NB_eNB_INST*sizeof(eNB_MAC_INST),NB_eNB_INST,sizeof(eNB_MAC_INST)); + mac_xface->macphy_exit("[MAC][MAIN] not enough memory for eNB \n"); + } + LOG_D(MAC,"[MAIN] ALLOCATE %d Bytes for %d eNB_MAC_INST @ %p\n",NB_eNB_INST*sizeof(eNB_MAC_INST),NB_eNB_INST,eNB_mac_inst); + bzero(eNB_mac_inst,NB_eNB_INST*sizeof(eNB_MAC_INST)); } else eNB_mac_inst = NULL; - + for(Mod_id=0;Mod_id<NB_eNB_INST;Mod_id++){ #ifdef PHY_EMUL - Mac_rlc_xface->Is_cluster_head[Mod_id]=2;//0: MR, 1: CH, 2: not CH neither MR + Mac_rlc_xface->Is_cluster_head[Mod_id]=2;//0: MR, 1: CH, 2: not CH neither MR #endif - /*#ifdef Rel10 + /*#ifdef Rel10 int n; for (n=0;n<4096;n++) eNB_mac_inst[Mod_id].MCH_pdu.payload[n] = taus(); @@ -176,18 +172,18 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active){ if (Is_rrc_registered == 1){ - LOG_I(MAC,"[MAIN] calling RRC\n"); + 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,HO_active); + openair_rrc_top_init(eMBMS_active, cba_group_active,HO_active); #endif } - else { + else { LOG_I(MAC,"[MAIN] Running without an RRC\n"); - } + } #ifndef USER_MODE #ifndef PHY_EMUL LOG_I(MAC,"[MAIN] add openair2 proc\n"); -//// add_openair2_stats(); + //// add_openair2_stats(); #endif #endif @@ -196,102 +192,102 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active){ // Set up DCIs for TDD 5MHz Config 1..6 for (i=0;i<NB_eNB_INST;i++) { - LOG_D(MAC,"[MAIN][eNB %d] initializing RA_template\n",i); - LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", i); - - RA_template = (RA_TEMPLATE *)&eNB_mac_inst[i].RA_template[0]; - for (j=0;j<NB_RA_PROC_MAX;j++) { - if (mac_xface->lte_frame_parms->frame_type == TDD) { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - break; - case 25: - size_bytes1 = sizeof(DCI1A_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_5MHz_TDD_1_6_t; - break; - case 50: - size_bytes1 = sizeof(DCI1A_10MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_10MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_10MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_10MHz_TDD_1_6_t; - break; - case 100: - size_bytes1 = sizeof(DCI1A_20MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_20MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_20MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_20MHz_TDD_1_6_t; - break; - default: - size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); - size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; - break; - } - + LOG_D(MAC,"[MAIN][eNB %d] initializing RA_template\n",i); + LOG_D(MAC, "[MSC_NEW][FRAME 00000][MAC_eNB][MOD %02d][]\n", i); + + RA_template = (RA_TEMPLATE *)&eNB_mac_inst[i].RA_template[0]; + for (j=0;j<NB_RA_PROC_MAX;j++) { + if (mac_xface->lte_frame_parms->frame_type == TDD) { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + break; + case 25: + size_bytes1 = sizeof(DCI1A_5MHz_TDD_1_6_t); + size_bytes2 = sizeof(DCI1A_5MHz_TDD_1_6_t); + size_bits1 = sizeof_DCI1A_5MHz_TDD_1_6_t; + size_bits2 = sizeof_DCI1A_5MHz_TDD_1_6_t; + break; + case 50: + size_bytes1 = sizeof(DCI1A_10MHz_TDD_1_6_t); + size_bytes2 = sizeof(DCI1A_10MHz_TDD_1_6_t); + size_bits1 = sizeof_DCI1A_10MHz_TDD_1_6_t; + size_bits2 = sizeof_DCI1A_10MHz_TDD_1_6_t; + break; + case 100: + size_bytes1 = sizeof(DCI1A_20MHz_TDD_1_6_t); + size_bytes2 = sizeof(DCI1A_20MHz_TDD_1_6_t); + size_bits1 = sizeof_DCI1A_20MHz_TDD_1_6_t; + size_bits2 = sizeof_DCI1A_20MHz_TDD_1_6_t; + break; + default: + size_bytes1 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + size_bytes2 = sizeof(DCI1A_1_5MHz_TDD_1_6_t); + size_bits1 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + size_bits2 = sizeof_DCI1A_1_5MHz_TDD_1_6_t; + break; + } + + } + else { + switch (mac_xface->lte_frame_parms->N_RB_DL) { + case 6: + size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); + size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); + size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; + size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; + break; + case 25: + size_bytes1 = sizeof(DCI1A_5MHz_FDD_t); + size_bytes2 = sizeof(DCI1A_5MHz_FDD_t); + size_bits1 = sizeof_DCI1A_5MHz_FDD_t; + size_bits2 = sizeof_DCI1A_5MHz_FDD_t; + break; + case 50: + size_bytes1 = sizeof(DCI1A_10MHz_FDD_t); + size_bytes2 = sizeof(DCI1A_10MHz_FDD_t); + size_bits1 = sizeof_DCI1A_10MHz_FDD_t; + size_bits2 = sizeof_DCI1A_10MHz_FDD_t; + break; + case 100: + size_bytes1 = sizeof(DCI1A_20MHz_FDD_t); + size_bytes2 = sizeof(DCI1A_20MHz_FDD_t); + size_bits1 = sizeof_DCI1A_20MHz_FDD_t; + size_bits2 = sizeof_DCI1A_20MHz_FDD_t; + break; + default: + size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); + size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); + size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; + size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; + break; + } + } + memcpy((void *)&RA_template[j].RA_alloc_pdu1[0],(void *)&RA_alloc_pdu,size_bytes1); + memcpy((void *)&RA_template[j].RA_alloc_pdu2[0],(void *)&DLSCH_alloc_pdu1A,size_bytes2); + RA_template[j].RA_dci_size_bytes1 = size_bytes1; + RA_template[j].RA_dci_size_bytes2 = size_bytes2; + RA_template[j].RA_dci_size_bits1 = size_bits1; + RA_template[j].RA_dci_size_bits2 = size_bits2; + + RA_template[j].RA_dci_fmt1 = format1A; + RA_template[j].RA_dci_fmt2 = format1A; } - else { - switch (mac_xface->lte_frame_parms->N_RB_DL) { - case 6: - size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; - break; - case 25: - size_bytes1 = sizeof(DCI1A_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_5MHz_FDD_t; - break; - case 50: - size_bytes1 = sizeof(DCI1A_10MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_10MHz_FDD_t); - size_bits1 = sizeof_DCI1A_10MHz_FDD_t; - size_bits2 = sizeof_DCI1A_10MHz_FDD_t; - break; - case 100: - size_bytes1 = sizeof(DCI1A_20MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_20MHz_FDD_t); - size_bits1 = sizeof_DCI1A_20MHz_FDD_t; - size_bits2 = sizeof_DCI1A_20MHz_FDD_t; - break; - default: - size_bytes1 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bytes2 = sizeof(DCI1A_1_5MHz_FDD_t); - size_bits1 = sizeof_DCI1A_1_5MHz_FDD_t; - size_bits2 = sizeof_DCI1A_1_5MHz_FDD_t; - break; - } + + memset (&eNB_mac_inst[i].eNB_stats,0,sizeof(eNB_STATS)); + UE_template = (UE_TEMPLATE *)&eNB_mac_inst[i].UE_template[0]; + for (j=0;j<NUMBER_OF_UE_MAX;j++) { + UE_template[j].rnti=0; + // initiallize the eNB to UE statistics + memset (&eNB_mac_inst[i].eNB_UE_stats[j],0,sizeof(eNB_UE_STATS)); } - memcpy((void *)&RA_template[j].RA_alloc_pdu1[0],(void *)&RA_alloc_pdu,size_bytes1); - memcpy((void *)&RA_template[j].RA_alloc_pdu2[0],(void *)&DLSCH_alloc_pdu1A,size_bytes2); - RA_template[j].RA_dci_size_bytes1 = size_bytes1; - RA_template[j].RA_dci_size_bytes2 = size_bytes2; - RA_template[j].RA_dci_size_bits1 = size_bits1; - RA_template[j].RA_dci_size_bits2 = size_bits2; - - RA_template[j].RA_dci_fmt1 = format1A; - RA_template[j].RA_dci_fmt2 = format1A; - } - - memset (&eNB_mac_inst[i].eNB_stats,0,sizeof(eNB_STATS)); - UE_template = (UE_TEMPLATE *)&eNB_mac_inst[i].UE_template[0]; - for (j=0;j<NUMBER_OF_UE_MAX;j++) { - UE_template[j].rnti=0; - // initiallize the eNB to UE statistics - memset (&eNB_mac_inst[i].eNB_UE_stats[j],0,sizeof(eNB_UE_STATS)); - } } - //ICIC init param + //ICIC init param #ifdef ICIC u8 SB_size; SB_size=mac_xface->get_SB_size(mac_xface->lte_frame_parms->N_RB_DL); @@ -299,20 +295,20 @@ int mac_top_init(int eMBMS_active, u8 cba_group_active, u8 HO_active){ srand (time(NULL)); for(j=0;j<NB_eNB_INST;j++){ - eNB_mac_inst[j].sbmap_conf.first_subframe=0; - eNB_mac_inst[j].sbmap_conf.periodicity=10; - eNB_mac_inst[j].sbmap_conf.sb_size=SB_size; - eNB_mac_inst[j].sbmap_conf.nb_active_sb=1; - for(i=0;i<NUMBER_OF_SUBBANDS;i++) - eNB_mac_inst[j].sbmap_conf.sbmap[i]=1; + eNB_mac_inst[j].sbmap_conf.first_subframe=0; + eNB_mac_inst[j].sbmap_conf.periodicity=10; + eNB_mac_inst[j].sbmap_conf.sb_size=SB_size; + eNB_mac_inst[j].sbmap_conf.nb_active_sb=1; + for(i=0;i<NUMBER_OF_SUBBANDS;i++) + eNB_mac_inst[j].sbmap_conf.sbmap[i]=1; - eNB_mac_inst[j].sbmap_conf.sbmap[rand()%NUMBER_OF_SUBBANDS]=0; + eNB_mac_inst[j].sbmap_conf.sbmap[rand()%NUMBER_OF_SUBBANDS]=0; } #endif -//end ALU's algo + //end ALU's algo - LOG_I(MAC,"[MAIN][INIT] Init function finished\n"); + LOG_I(MAC,"[MAIN][INIT] Init function finished\n"); return(0); @@ -336,8 +332,8 @@ int mac_init_global_param(void){ bzero(Mac_rlc_xface,sizeof(MAC_RLC_XFACE)); if(Mac_rlc_xface == NULL){ - LOG_E(MAC,"[MAIN] FATAL EROOR: Could not allocate memory for Mac_rlc_xface !!!\n"); - return (-1); + LOG_E(MAC,"[MAIN] FATAL EROOR: Could not allocate memory for Mac_rlc_xface !!!\n"); + return (-1); } @@ -384,7 +380,7 @@ int mac_init_global_param(void){ /***********************************************************************/ void mac_top_cleanup(void){ -/***********************************************************************/ + /***********************************************************************/ #ifndef USER_MODE pdcp_module_cleanup (); #endif @@ -499,7 +495,7 @@ int l2_init(LTE_DL_FRAME_PARMS *frame_parms,int eMBMS_active, u8 cba_group_activ //Mac_rlc_xface->Is_cluster_head[0] = 1; //Mac_rlc_xface->Is_cluster_head[1] = 0; - + return(1); } diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index f44513973af7bfdb820369ff8752148a86caf834..3d80ce64185ae369d0f9fb4296699247109eba8e 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -1,4 +1,4 @@ - + /******************************************************************************* Eurecom OpenAirInterface @@ -26,7 +26,7 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file pre_processor.c * \brief procedures related to UE * \author Ankit Bhamri @@ -56,7 +56,7 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" - + #define DEBUG_eNB_SCHEDULER 1 #define DEBUG_HEADER_PARSING 1 //#define DEBUG_PACKET_TRACE 1 @@ -67,286 +67,300 @@ #ifndef USER_MODE #define msg debug_msg #endif -*/ + */ extern inline unsigned int taus(void); // This function stores the downlink buffer for all the logical channels -void store_dlsch_buffer (unsigned char Mod_id, - u32 frame, - unsigned char subframe){ +void store_dlsch_buffer (module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframeP){ - unsigned char next_ue; - u16 rnti,i=0; + module_id_t next_ue; + rnti_t rnti; + u16 i=0; mac_rlc_status_resp_t rlc_status; - unsigned char UE_id,granted_UEs; + unsigned char UE_id,granted_UEs; granted_UEs = find_dlgranted_UEs(Mod_id); for (UE_id=0;UE_id<granted_UEs;UE_id++){ - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_total = 0; - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_pdus_total = 0; - for(i=0;i< MAX_NUM_LCID; i++) { - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_info[i]=0; - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_pdus_in_buffer[i]=0; - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_head_sdu_creation_time[i]=0; - eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_head_sdu_remaining_size_to_send[i]=0; - } + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_total = 0; + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_pdus_total = 0; + for(i=0;i< MAX_NUM_LCID; i++) { + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_info[i]=0; + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_pdus_in_buffer[i]=0; + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_head_sdu_creation_time[i]=0; + eNB_mac_inst[Mod_id].UE_template[UE_id].dl_buffer_head_sdu_remaining_size_to_send[i]=0; + } } for (UE_id=0;UE_id<granted_UEs;UE_id++) { - - next_ue = UE_id; - rnti = find_UE_RNTI(Mod_id,next_ue); - if (rnti == 0) - continue; - - for(i=0;i< MAX_NUM_LCID; i++){ // loop over all the logical channels - - rlc_status = mac_rlc_status_ind(Mod_id,frame,1,RLC_MBMS_NO,i+(NB_RB_MAX*next_ue),0 ); - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_remaining_size_to_send[i] = rlc_status.head_sdu_remaining_size_to_send; - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_is_segmented[i] = rlc_status.head_sdu_is_segmented; - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total = eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i];//storing the total dlsch buffer - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_total += eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i]; + + next_ue = UE_id; + rnti = find_UE_RNTI(Mod_id,next_ue); + if (rnti == 0) + continue; + + for(i=0;i< MAX_NUM_LCID; i++){ // loop over all the logical channels + + rlc_status = mac_rlc_status_ind(Mod_id,next_ue, frameP,1,RLC_MBMS_NO,i,0 ); + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i] = rlc_status.bytes_in_buffer; //storing the dlsch buffer for each logical channel + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i] = rlc_status.pdus_in_buffer; + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_creation_time[i] = rlc_status.head_sdu_creation_time ; + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_remaining_size_to_send[i] = rlc_status.head_sdu_remaining_size_to_send; + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_is_segmented[i] = rlc_status.head_sdu_is_segmented; + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total = eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i];//storing the total dlsch buffer + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_total += eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i]; #ifdef DEBUG_eNB_SCHEDULER - /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : - * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent - */ - if (eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i]>0) - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and %d size, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", - Mod_id, frame, subframe, next_ue, - i, eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i],eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i], - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_creation_time[i], - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_remaining_size_to_send[i], - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_is_segmented[i] - ); + /* note for dl_buffer_head_sdu_remaining_size_to_send[i] : + * 0 if head SDU has not been segmented (yet), else remaining size not already segmented and sent + */ + if (eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i]>0) + LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d in LCID%d: total of %d pdus and %d size, head sdu queuing time %d, remaining size %d, is segmeneted %d \n", + Mod_id, frameP, subframeP, next_ue, + i, eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_in_buffer[i],eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_info[i], + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_creation_time[i], + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_remaining_size_to_send[i], + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_head_sdu_is_segmented[i] + ); #endif - } + } #ifdef DEBUG_eNB_SCHEDULER - if ( eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total>0) - LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", - Mod_id, frame, subframe, next_ue, - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total, - eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_total - ); + if ( eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total>0) + LOG_D(MAC,"[eNB %d] Frame %d Subframe %d : RLC status for UE %d : total DL buffer size %d and total number of pdu %d \n", + Mod_id, frameP, subframeP, next_ue, + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total, + eNB_mac_inst[Mod_id].UE_template[next_ue].dl_pdus_total + ); #endif } } // This function returns the estimated number of RBs required by each UE for downlink scheduling -void assign_rbs_required (unsigned char Mod_id, - u32 frame, - unsigned char subframe, - u16 *nb_rbs_required){ +void assign_rbs_required (module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframe, + u16 *nb_rbs_required){ - - unsigned char next_ue; - u16 rnti,TBS = 0; - LTE_eNB_UE_stats* eNB_UE_stats; - unsigned char UE_id, granted_UEs; + + module_id_t next_ue; + rnti_t rnti; + u16 TBS = 0; + LTE_eNB_UE_stats *eNB_UE_stats = NULL; + module_id_t ue_inst; + unsigned char granted_UEs; granted_UEs = find_dlgranted_UEs(Mod_id); - for (UE_id=0;UE_id<granted_UEs;UE_id++){ - nb_rbs_required[UE_id] = 0; //initialization + for (ue_inst=0;ue_inst<granted_UEs;ue_inst++){ + nb_rbs_required[ue_inst] = 0; //initialization } - for (UE_id=0;UE_id<granted_UEs;UE_id++) { - - next_ue = UE_id; - rnti = find_UE_RNTI(Mod_id,next_ue); - if (rnti == 0) - continue; - - eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,rnti); - //if(eNB_UE_stats == NULL) - //continue; - - - switch(eNB_UE_stats->DL_cqi[0]) + for (ue_inst=0;ue_inst<granted_UEs;ue_inst++) { + + next_ue = ue_inst; + rnti = find_UE_RNTI(Mod_id,next_ue); + if (rnti == 0) + continue; + + eNB_UE_stats = mac_xface->get_eNB_UE_stats(Mod_id,rnti); + //if(eNB_UE_stats == NULL) + //continue; + + + switch(eNB_UE_stats->DL_cqi[0]) { case 0: - eNB_UE_stats->dlsch_mcs1 = 0; - break; + eNB_UE_stats->dlsch_mcs1 = 0; + break; case 1: - eNB_UE_stats->dlsch_mcs1 = 0; - break; + eNB_UE_stats->dlsch_mcs1 = 0; + break; case 2: - eNB_UE_stats->dlsch_mcs1 = 0; - break; + eNB_UE_stats->dlsch_mcs1 = 0; + break; case 3: - eNB_UE_stats->dlsch_mcs1 = 2; - break; + eNB_UE_stats->dlsch_mcs1 = 2; + break; case 4: - eNB_UE_stats->dlsch_mcs1 = 4; - break; + eNB_UE_stats->dlsch_mcs1 = 4; + break; case 5: - eNB_UE_stats->dlsch_mcs1 = 6; - break; + eNB_UE_stats->dlsch_mcs1 = 6; + break; case 6: - eNB_UE_stats->dlsch_mcs1 = 8; - break; + eNB_UE_stats->dlsch_mcs1 = 8; + break; case 7: - eNB_UE_stats->dlsch_mcs1 = 11; - break; + eNB_UE_stats->dlsch_mcs1 = 11; + break; case 8: - eNB_UE_stats->dlsch_mcs1 = 13; - break; + eNB_UE_stats->dlsch_mcs1 = 13; + break; case 9: - eNB_UE_stats->dlsch_mcs1 = 16; - break; + eNB_UE_stats->dlsch_mcs1 = 16; + break; case 10: - eNB_UE_stats->dlsch_mcs1 = 18; - break; + eNB_UE_stats->dlsch_mcs1 = 18; + break; case 11: - eNB_UE_stats->dlsch_mcs1 = 20; - break; + eNB_UE_stats->dlsch_mcs1 = 20; + break; case 12: - eNB_UE_stats->dlsch_mcs1 = 22; - break; + eNB_UE_stats->dlsch_mcs1 = 22; + break; case 13: - eNB_UE_stats->dlsch_mcs1 = 22;//25 - break; + eNB_UE_stats->dlsch_mcs1 = 22;//25 + break; case 14: - eNB_UE_stats->dlsch_mcs1 = 22;//27 - break; + eNB_UE_stats->dlsch_mcs1 = 22;//27 + break; case 15: - eNB_UE_stats->dlsch_mcs1 = 22;//28 - break; + eNB_UE_stats->dlsch_mcs1 = 22;//28 + break; default: - printf("Invalid CQI"); - exit(-1); + printf("Invalid CQI"); + exit(-1); } - - - - if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED)){ - nb_rbs_required[next_ue] = mac_xface->lte_frame_parms->N_RB_DL; - continue; - } - - - if (eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total> 0) { - - if (eNB_UE_stats->dlsch_mcs1==0) nb_rbs_required[next_ue] = 4; // don't let the TBS get too small - else nb_rbs_required[next_ue] = 2; - - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[next_ue]); - - while (TBS < eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total) { - nb_rbs_required[next_ue] += 2; - if (nb_rbs_required[next_ue]>mac_xface->lte_frame_parms->N_RB_DL) { - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,mac_xface->lte_frame_parms->N_RB_DL); - nb_rbs_required[next_ue] = mac_xface->lte_frame_parms->N_RB_DL;// calculating required number of RBs for each UE - break; - } - TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[next_ue]); + + + + if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED)){ + nb_rbs_required[next_ue] = mac_xface->lte_frame_parms->N_RB_DL; + continue; + } + + + if (eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total> 0) { + + if (eNB_UE_stats->dlsch_mcs1==0) nb_rbs_required[next_ue] = 4; // don't let the TBS get too small + else nb_rbs_required[next_ue] = 2; + + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[next_ue]); + + while (TBS < eNB_mac_inst[Mod_id].UE_template[next_ue].dl_buffer_total) { + nb_rbs_required[next_ue] += 2; + if (nb_rbs_required[next_ue]>mac_xface->lte_frame_parms->N_RB_DL) { + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,mac_xface->lte_frame_parms->N_RB_DL); + nb_rbs_required[next_ue] = mac_xface->lte_frame_parms->N_RB_DL;// calculating required number of RBs for each UE + break; + } + TBS = mac_xface->get_TBS_DL(eNB_UE_stats->dlsch_mcs1,nb_rbs_required[next_ue]); + } + } - - } - + } } // This fuction sorts the UE in order their dlsch buffer and CQI -void sort_UEs (unsigned char Mod_id, - unsigned char subframe, - u16 *UE_id_sorted){ - - unsigned char next_ue1,next_ue2,round1=0,round2=0,harq_pid1=0,harq_pid2=0; - u16 UE_id,granted_UEs,i=0,ii=0,j=0,rnti1,rnti2; - LTE_eNB_UE_stats* eNB_UE_stats1; - LTE_eNB_UE_stats* eNB_UE_stats2; - - +void sort_UEs (module_id_t Mod_id, + sub_frame_t subframe, + module_id_t *UE_id_sorted){ + + module_id_t next_ue1,next_ue2; + unsigned char round1=0,round2=0,harq_pid1=0,harq_pid2=0; + module_id_t ue_inst; + u16 granted_UEs,i=0,ii=0,j=0; + rnti_t rnti1,rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + + granted_UEs = find_dlgranted_UEs(Mod_id); - - - for (UE_id=0;UE_id<granted_UEs;UE_id++) { - UE_id_sorted[i] = UE_id; - i++; + + + for (ue_inst=0;ue_inst<granted_UEs;ue_inst++) { + UE_id_sorted[i] = ue_inst; + i++; } - + for(i=0; i < granted_UEs;i++){ - - next_ue1 = UE_id_sorted[i]; - - rnti1 = find_UE_RNTI(Mod_id,next_ue1); - if(rnti1 == 0) - continue; - - - eNB_UE_stats1 = mac_xface->get_eNB_UE_stats(Mod_id,rnti1); - - mac_xface->get_ue_active_harq_pid(Mod_id,rnti1,subframe,&harq_pid1,&round1,0); - - - for(ii=i+1;ii<granted_UEs;ii++){ - - next_ue2 = UE_id_sorted[ii]; - - rnti2 = find_UE_RNTI(Mod_id,next_ue2); - if(rnti2 == 0) - continue; - - eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,rnti2); - - mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); - - if(round2 > round1){ - UE_id_sorted[i] = next_ue2; - UE_id_sorted[ii] = next_ue1; - } - else if (round2 == round1){ - for(j=0;j<MAX_NUM_LCID;j++){ - - if(eNB_mac_inst[Mod_id].UE_template[next_ue1].dl_buffer_info[j] < eNB_mac_inst[Mod_id].UE_template[next_ue2].dl_buffer_info[j]){ - UE_id_sorted[i] = next_ue2; - UE_id_sorted[ii] = next_ue1; - break; - } - else if((j == MAX_NUM_LCID-1)) - { - if(eNB_UE_stats1->DL_cqi[0] < eNB_UE_stats2->DL_cqi[0]){ - UE_id_sorted[i] = next_ue2; - UE_id_sorted[ii] = next_ue1; - } - } - } + + next_ue1 = UE_id_sorted[i]; + + rnti1 = find_UE_RNTI(Mod_id,next_ue1); + if(rnti1 == 0) + continue; + + + eNB_UE_stats1 = mac_xface->get_eNB_UE_stats(Mod_id,rnti1); + + mac_xface->get_ue_active_harq_pid(Mod_id,rnti1,subframe,&harq_pid1,&round1,0); + + + for(ii=i+1;ii<granted_UEs;ii++){ + + next_ue2 = UE_id_sorted[ii]; + + rnti2 = find_UE_RNTI(Mod_id,next_ue2); + if(rnti2 == 0) + continue; + + eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,rnti2); + + mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); + + if(round2 > round1){ + UE_id_sorted[i] = next_ue2; + UE_id_sorted[ii] = next_ue1; + } + else if (round2 == round1){ + for(j=0;j<MAX_NUM_LCID;j++){ + + if(eNB_mac_inst[Mod_id].UE_template[next_ue1].dl_buffer_info[j] < eNB_mac_inst[Mod_id].UE_template[next_ue2].dl_buffer_info[j]){ + UE_id_sorted[i] = next_ue2; + UE_id_sorted[ii] = next_ue1; + break; + } + else if((j == MAX_NUM_LCID-1)) + { + if(eNB_UE_stats1->DL_cqi[0] < eNB_UE_stats2->DL_cqi[0]){ + UE_id_sorted[i] = next_ue2; + UE_id_sorted[ii] = next_ue1; + } + } + } + } } - } } } - + // This function assigns pre-available RBS to each UE in specified sub-bands before scheduling is done -void dlsch_scheduler_pre_processor (unsigned char Mod_id, - u32 frame, - unsigned char subframe, - u8 *dl_pow_off, - u16 *pre_nb_available_rbs, - int N_RBGS, - unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX]){ +void dlsch_scheduler_pre_processor (module_id_t Mod_id, + frame_t frameP, + sub_frame_t subframeP, + u8 *dl_pow_off, + u16 *pre_nb_available_rbs, + int N_RBGS, + unsigned char rballoc_sub_UE[NUMBER_OF_UE_MAX][N_RBGS_MAX]){ unsigned char next_ue,next_ue1,next_ue2,rballoc_sub[mac_xface->lte_frame_parms->N_RBGS],harq_pid=0,harq_pid1=0,harq_pid2=0,round=0,round1=0,round2=0,total_ue_count=0; unsigned char MIMO_mode_indicator[mac_xface->lte_frame_parms->N_RBGS]; - u16 UE_id,UE_id_sorted[NUMBER_OF_UE_MAX],granted_UEs,i,ii,j,nb_rbs_required[NUMBER_OF_UE_MAX],nb_rbs_required_remaining[NUMBER_OF_UE_MAX],nb_rbs_required_remaining_1[NUMBER_OF_UE_MAX],i1,i2,i3,r1=0,average_rbs_per_user=0; - u16 rnti,rnti1,rnti2; - LTE_eNB_UE_stats* eNB_UE_stats1; - LTE_eNB_UE_stats* eNB_UE_stats2; - u16 min_rb_unit; + module_id_t UE_id, i; + module_id_t UE_id_sorted[NUMBER_OF_UE_MAX]; + module_id_t granted_UEs; + u16 ii,j; + u16 nb_rbs_required[NUMBER_OF_UE_MAX]; + u16 nb_rbs_required_remaining[NUMBER_OF_UE_MAX]; + u16 nb_rbs_required_remaining_1[NUMBER_OF_UE_MAX]; + u16 i1,i2,i3,r1=0; + u16 average_rbs_per_user=0; + rnti_t rnti,rnti1,rnti2; + LTE_eNB_UE_stats *eNB_UE_stats1 = NULL; + LTE_eNB_UE_stats *eNB_UE_stats2 = NULL; + u16 min_rb_unit; switch (mac_xface->lte_frame_parms->N_RB_DL) { @@ -371,42 +385,42 @@ void dlsch_scheduler_pre_processor (unsigned char Mod_id, for(i=0;i<NUMBER_OF_UE_MAX;i++){ - nb_rbs_required[i] = 0; - UE_id_sorted[i] = i; - dl_pow_off[i] =2; - pre_nb_available_rbs[i] = 0; - nb_rbs_required_remaining[i] = 0; - for(j=0;j<N_RBGS;j++) - { - MIMO_mode_indicator[j] = 2; - rballoc_sub[j] = 0; - rballoc_sub_UE[i][j] = 0; - } + nb_rbs_required[i] = 0; + UE_id_sorted[i] = i; + dl_pow_off[i] =2; + pre_nb_available_rbs[i] = 0; + nb_rbs_required_remaining[i] = 0; + for(j=0;j<N_RBGS;j++) + { + MIMO_mode_indicator[j] = 2; + rballoc_sub[j] = 0; + rballoc_sub_UE[i][j] = 0; + } } - + //printf("SUCCESS %d",mac_xface->lte_frame_parms->N_RBGS); //exit(-1); // Store the DLSCH buffer for each logical channel - store_dlsch_buffer (Mod_id,frame,subframe); + store_dlsch_buffer (Mod_id,frameP,subframeP); // Calculate the number of RBs required by each UE on the basis of logical channel's buffer - assign_rbs_required (Mod_id,frame,subframe,nb_rbs_required); + assign_rbs_required (Mod_id,frameP,subframeP,nb_rbs_required); // Sorts the user on the basis of dlsch logical channel buffer and CQI - sort_UEs (Mod_id,subframe,UE_id_sorted); - //printf ("Frame:%d,SUCCESS %d[%d] %d[%d]\n",frame,UE_id_sorted[0],nb_rbs_required[UE_id_sorted[0]],UE_id_sorted[1],nb_rbs_required[UE_id_sorted[1]]); - + sort_UEs (Mod_id,subframeP,UE_id_sorted); + //printf ("Frame:%d,SUCCESS %d[%d] %d[%d]\n",frameP,UE_id_sorted[0],nb_rbs_required[UE_id_sorted[0]],UE_id_sorted[1],nb_rbs_required[UE_id_sorted[1]]); + for (i=0;i<granted_UEs;i++){ - rnti = find_UE_RNTI(Mod_id,i); - if(rnti == 0) - continue; - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - if(round>0) - nb_rbs_required[i] = eNB_mac_inst[Mod_id].UE_template[i].nb_rb[harq_pid]; - //nb_rbs_required_remaining[i] = nb_rbs_required[i]; - if(nb_rbs_required[i] > 0) - total_ue_count = total_ue_count + 1; + rnti = find_UE_RNTI(Mod_id,i); + if(rnti == 0) + continue; + mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframeP,&harq_pid,&round,0); + if(round>0) + nb_rbs_required[i] = eNB_mac_inst[Mod_id].UE_template[i].nb_rb[harq_pid]; + //nb_rbs_required_remaining[i] = nb_rbs_required[i]; + if(nb_rbs_required[i] > 0) + total_ue_count = total_ue_count + 1; } // hypotetical assignement if((total_ue_count > 0) && ( min_rb_unit * total_ue_count <= mac_xface->lte_frame_parms->N_RB_DL ) ) @@ -415,316 +429,316 @@ void dlsch_scheduler_pre_processor (unsigned char Mod_id, average_rbs_per_user = min_rb_unit; for(i=0;i<granted_UEs;i++){ - // control channel - if (mac_get_rrc_status(Mod_id,1,i) < RRC_RECONFIGURED) - nb_rbs_required_remaining_1[i] = nb_rbs_required[i]; - else - nb_rbs_required_remaining_1[i] = cmin(average_rbs_per_user,nb_rbs_required[i]); + // control channel + if (mac_get_rrc_status(Mod_id,1,i) < RRC_RECONFIGURED) + nb_rbs_required_remaining_1[i] = nb_rbs_required[i]; + else + nb_rbs_required_remaining_1[i] = cmin(average_rbs_per_user,nb_rbs_required[i]); } - - + + //Allocation to UEs is done in 2 rounds, // 1st round: average number of RBs allocated to each UE // 2nd round: remaining RBs are allocated to high priority UEs for(r1=0;r1<2;r1++){ - for(i=0; i<granted_UEs;i++) - { - if(r1 == 0) - nb_rbs_required_remaining[i] = nb_rbs_required_remaining_1[i]; - else // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round - nb_rbs_required_remaining[i] = nb_rbs_required[i]-nb_rbs_required_remaining_1[i]+nb_rbs_required_remaining[i]; + for(i=0; i<granted_UEs;i++) + { + if(r1 == 0) + nb_rbs_required_remaining[i] = nb_rbs_required_remaining_1[i]; + else // rb required based only on the buffer - rb allloctaed in the 1st round + extra reaming rb form the 1st round + nb_rbs_required_remaining[i] = nb_rbs_required[i]-nb_rbs_required_remaining_1[i]+nb_rbs_required_remaining[i]; + } + // retransmission in control channels + for (i = 0 ;i<granted_UEs; i++){ + + next_ue = UE_id_sorted[i]; + rnti = find_UE_RNTI(Mod_id,next_ue); + if(rnti == 0) + continue; + mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframeP,&harq_pid,&round,0); + + if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED) && (round >0)) { + + + + for(j=0;j<N_RBGS;j++){ + + if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ + + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue][j] = 1; + + MIMO_mode_indicator[j] = 1; + + if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) + dl_pow_off[next_ue] = 1; + // if the total rb is odd + if ((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))) { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; + } + else { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; + } + } + } + } } - // retransmission in control channels - for (i = 0 ;i<granted_UEs; i++){ - - next_ue = UE_id_sorted[i]; - rnti = find_UE_RNTI(Mod_id,next_ue); - if(rnti == 0) - continue; - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED) && (round >0)) { + // retransmission in data channels + for (i = 0 ;i<granted_UEs; i++){ + + next_ue = UE_id_sorted[i]; + rnti = find_UE_RNTI(Mod_id,next_ue); + if(rnti == 0) + continue; + mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframeP,&harq_pid,&round,0); + + if ((mac_get_rrc_status(Mod_id,1,next_ue) >= RRC_RECONFIGURED) && (round > 0)) { - for(j=0;j<N_RBGS;j++){ - if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue][j] = 1; + for(j=0;j<N_RBGS;j++){ - MIMO_mode_indicator[j] = 1; + if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ - if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) - dl_pow_off[next_ue] = 1; - // if the total rb is odd - if ((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))) { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; - } - else { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; - } - } - } + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue][j] = 1; + + MIMO_mode_indicator[j] = 1; + + if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) + dl_pow_off[next_ue] = 1; + + if((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))){ + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit + 1; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; + } + else { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; + } + } + } + } } - } + // control channel in the 1st transmission + for (i = 0 ;i<granted_UEs; i++){ - // retransmission in data channels - for (i = 0 ;i<granted_UEs; i++){ - - next_ue = UE_id_sorted[i]; - rnti = find_UE_RNTI(Mod_id,next_ue); - if(rnti == 0) - continue; - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); + next_ue = UE_id_sorted[i]; + rnti = find_UE_RNTI(Mod_id,next_ue); + if(rnti == 0) + continue; + mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframeP,&harq_pid,&round,0); + + if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED) && (round == 0)) { - if ((mac_get_rrc_status(Mod_id,1,next_ue) >= RRC_RECONFIGURED) && (round > 0)) { - for(j=0;j<N_RBGS;j++){ + for(j=0;j<N_RBGS;j++){ - if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ + if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue][j] = 1; + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue][j] = 1; - MIMO_mode_indicator[j] = 1; + MIMO_mode_indicator[j] = 1; - if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) - dl_pow_off[next_ue] = 1; + if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) + dl_pow_off[next_ue] = 1; - if((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))){ - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit + 1; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; - } - else { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; - } - } - } + if((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))){ + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit + 1; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; + } + else { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; + } + } + } + } } - } - // control channel in the 1st transmission - for (i = 0 ;i<granted_UEs; i++){ - - next_ue = UE_id_sorted[i]; - rnti = find_UE_RNTI(Mod_id,next_ue); - if(rnti == 0) - continue; - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - if ((mac_get_rrc_status(Mod_id,1,next_ue) < RRC_RECONFIGURED) && (round == 0)) { + // data chanel TM5 + for (i = 0 ;i<granted_UEs; i++){ - + next_ue1 = UE_id_sorted[i]; + rnti1 = find_UE_RNTI(Mod_id,next_ue1); + if(rnti1 == 0) + continue; - for(j=0;j<N_RBGS;j++){ + eNB_UE_stats1 = mac_xface->get_eNB_UE_stats(Mod_id,rnti1); - if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ + mac_xface->get_ue_active_harq_pid(Mod_id,rnti1,subframeP,&harq_pid1,&round1,0); - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue][j] = 1; + if ((mac_get_rrc_status(Mod_id,1,next_ue1) >= RRC_RECONFIGURED) && (round1==0) && (mac_xface->get_transmission_mode(Mod_id,rnti1)==5) && (dl_pow_off[next_ue1] != 1)) { - MIMO_mode_indicator[j] = 1; - if(mac_xface->get_transmission_mode(Mod_id,rnti)==5) - dl_pow_off[next_ue] = 1; + for(j=0;j<N_RBGS;j+=2){ - if((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))){ - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit + 1; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit - 1; - } - else { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; - } - } - } - } - } + if((((j == (N_RBGS-1))&& (rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue1][j] == 0)) || ((j < (N_RBGS-1)) && (rballoc_sub[j+1] == 0) && (rballoc_sub_UE[next_ue1][j+1] == 0))) && (nb_rbs_required_remaining[next_ue1]>0)){ - + for (ii = i+1;ii < granted_UEs;ii++) { - // data chanel TM5 - for (i = 0 ;i<granted_UEs; i++){ - - - next_ue1 = UE_id_sorted[i]; - rnti1 = find_UE_RNTI(Mod_id,next_ue1); - if(rnti1 == 0) - continue; + next_ue2 = UE_id_sorted[ii]; + rnti2 = find_UE_RNTI(Mod_id,next_ue2); + if(rnti2 == 0) + continue; - eNB_UE_stats1 = mac_xface->get_eNB_UE_stats(Mod_id,rnti1); + eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,rnti2); + mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframeP,&harq_pid2,&round2,0); - mac_xface->get_ue_active_harq_pid(Mod_id,rnti1,subframe,&harq_pid1,&round1,0); + if ((mac_get_rrc_status(Mod_id,1,next_ue2) >= RRC_RECONFIGURED) && (round2==0) && (mac_xface->get_transmission_mode(Mod_id,rnti2)==5) && (dl_pow_off[next_ue2] != 1)) { + + if((((j == (N_RBGS-1)) && (rballoc_sub_UE[next_ue2][j] == 0)) || ((j < (N_RBGS-1)) && (rballoc_sub_UE[next_ue2][j+1] == 0))) && (nb_rbs_required_remaining[next_ue2]>0)){ + + if((((eNB_UE_stats2->DL_pmi_single^eNB_UE_stats1->DL_pmi_single)<<(14-j))&0xc000)== 0x4000){ //MU-MIMO only for 25 RBs configuration + + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue1][j] = 1; + rballoc_sub_UE[next_ue2][j] = 1; + MIMO_mode_indicator[j] = 0; + + if (j< N_RBGS-1) { + rballoc_sub[j+1] = 1; + rballoc_sub_UE[next_ue1][j+1] = 1; + rballoc_sub_UE[next_ue2][j+1] = 1; + MIMO_mode_indicator[j+1] = 0; + } + + dl_pow_off[next_ue1] = 0; + dl_pow_off[next_ue2] = 0; - if ((mac_get_rrc_status(Mod_id,1,next_ue1) >= RRC_RECONFIGURED) && (round1==0) && (mac_xface->get_transmission_mode(Mod_id,rnti1)==5) && (dl_pow_off[next_ue1] != 1)) { - - - for(j=0;j<N_RBGS;j+=2){ - - if((((j == (N_RBGS-1))&& (rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue1][j] == 0)) || ((j < (N_RBGS-1)) && (rballoc_sub[j+1] == 0) && (rballoc_sub_UE[next_ue1][j+1] == 0))) && (nb_rbs_required_remaining[next_ue1]>0)){ - - for (ii = i+1;ii < granted_UEs;ii++) { - - next_ue2 = UE_id_sorted[ii]; - rnti2 = find_UE_RNTI(Mod_id,next_ue2); - if(rnti2 == 0) - continue; - - eNB_UE_stats2 = mac_xface->get_eNB_UE_stats(Mod_id,rnti2); - mac_xface->get_ue_active_harq_pid(Mod_id,rnti2,subframe,&harq_pid2,&round2,0); - - if ((mac_get_rrc_status(Mod_id,1,next_ue2) >= RRC_RECONFIGURED) && (round2==0) && (mac_xface->get_transmission_mode(Mod_id,rnti2)==5) && (dl_pow_off[next_ue2] != 1)) { - - if((((j == (N_RBGS-1)) && (rballoc_sub_UE[next_ue2][j] == 0)) || ((j < (N_RBGS-1)) && (rballoc_sub_UE[next_ue2][j+1] == 0))) && (nb_rbs_required_remaining[next_ue2]>0)){ - - if((((eNB_UE_stats2->DL_pmi_single^eNB_UE_stats1->DL_pmi_single)<<(14-j))&0xc000)== 0x4000){ //MU-MIMO only for 25 RBs configuration - - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue1][j] = 1; - rballoc_sub_UE[next_ue2][j] = 1; - MIMO_mode_indicator[j] = 0; - - if (j< N_RBGS-1) { - rballoc_sub[j+1] = 1; - rballoc_sub_UE[next_ue1][j+1] = 1; - rballoc_sub_UE[next_ue2][j+1] = 1; - MIMO_mode_indicator[j+1] = 0; - } - - dl_pow_off[next_ue1] = 0; - dl_pow_off[next_ue2] = 0; - - - - - if ((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25) || - (mac_xface->lte_frame_parms->N_RB_DL == 50))){ - nb_rbs_required_remaining[next_ue1] = nb_rbs_required_remaining[next_ue1] - min_rb_unit+1; - pre_nb_available_rbs[next_ue1] = pre_nb_available_rbs[next_ue1] + min_rb_unit-1; - nb_rbs_required_remaining[next_ue2] = nb_rbs_required_remaining[next_ue2] - min_rb_unit+1; - pre_nb_available_rbs[next_ue2] = pre_nb_available_rbs[next_ue2] + min_rb_unit-1; - } - else { - nb_rbs_required_remaining[next_ue1] = nb_rbs_required_remaining[next_ue1] - 4; - pre_nb_available_rbs[next_ue1] = pre_nb_available_rbs[next_ue1] + 4; - nb_rbs_required_remaining[next_ue2] = nb_rbs_required_remaining[next_ue2] - 4; - pre_nb_available_rbs[next_ue2] = pre_nb_available_rbs[next_ue2] + 4; - } - break; - } - } - } - } - } - } + + + + if ((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25) || + (mac_xface->lte_frame_parms->N_RB_DL == 50))){ + nb_rbs_required_remaining[next_ue1] = nb_rbs_required_remaining[next_ue1] - min_rb_unit+1; + pre_nb_available_rbs[next_ue1] = pre_nb_available_rbs[next_ue1] + min_rb_unit-1; + nb_rbs_required_remaining[next_ue2] = nb_rbs_required_remaining[next_ue2] - min_rb_unit+1; + pre_nb_available_rbs[next_ue2] = pre_nb_available_rbs[next_ue2] + min_rb_unit-1; + } + else { + nb_rbs_required_remaining[next_ue1] = nb_rbs_required_remaining[next_ue1] - 4; + pre_nb_available_rbs[next_ue1] = pre_nb_available_rbs[next_ue1] + 4; + nb_rbs_required_remaining[next_ue2] = nb_rbs_required_remaining[next_ue2] - 4; + pre_nb_available_rbs[next_ue2] = pre_nb_available_rbs[next_ue2] + 4; + } + break; + } + } + } + } + } + } + } } - } - // data channel for all TM - for (i = 0;i<granted_UEs; i++){ - - next_ue = UE_id_sorted[i]; - rnti = find_UE_RNTI(Mod_id,next_ue); - if (rnti == 0) - continue; - - mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframe,&harq_pid,&round,0); - - if ((mac_get_rrc_status(Mod_id,1,next_ue) >= RRC_RECONFIGURED) && (round==0)) { - - - for(j=0;j<N_RBGS;j++){ - - if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ - - - switch (mac_xface->get_transmission_mode(Mod_id,rnti)) { - case 1: - case 2: - case 4: - case 6: - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue][j] = 1; - - MIMO_mode_indicator[j] = 1; - - if((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))){ - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] +min_rb_unit-1; - } - else { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; - } - - break; - case 5: - if (dl_pow_off[next_ue] != 0){ - - dl_pow_off[next_ue] = 1; - - rballoc_sub[j] = 1; - rballoc_sub_UE[next_ue][j] = 1; - - MIMO_mode_indicator[j] = 1; - - if((j == N_RBGS-1) && - ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| - (mac_xface->lte_frame_parms->N_RB_DL == 50))){ - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit-1; - } - else { - nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; - pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; - } - } - break; - default: - break; - } - } - } + // data channel for all TM + for (i = 0;i<granted_UEs; i++){ + + next_ue = UE_id_sorted[i]; + rnti = find_UE_RNTI(Mod_id,next_ue); + if (rnti == 0) + continue; + + mac_xface->get_ue_active_harq_pid(Mod_id,rnti,subframeP,&harq_pid,&round,0); + + if ((mac_get_rrc_status(Mod_id,1,next_ue) >= RRC_RECONFIGURED) && (round==0)) { + + + for(j=0;j<N_RBGS;j++){ + + if((rballoc_sub[j] == 0) && (rballoc_sub_UE[next_ue][j] == 0) && (nb_rbs_required_remaining[next_ue]>0)){ + + + switch (mac_xface->get_transmission_mode(Mod_id,rnti)) { + case 1: + case 2: + case 4: + case 6: + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue][j] = 1; + + MIMO_mode_indicator[j] = 1; + + if((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))){ + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] +min_rb_unit-1; + } + else { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; + } + + break; + case 5: + if (dl_pow_off[next_ue] != 0){ + + dl_pow_off[next_ue] = 1; + + rballoc_sub[j] = 1; + rballoc_sub_UE[next_ue][j] = 1; + + MIMO_mode_indicator[j] = 1; + + if((j == N_RBGS-1) && + ((mac_xface->lte_frame_parms->N_RB_DL == 25)|| + (mac_xface->lte_frame_parms->N_RB_DL == 50))){ + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit+1; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit-1; + } + else { + nb_rbs_required_remaining[next_ue] = nb_rbs_required_remaining[next_ue] - min_rb_unit; + pre_nb_available_rbs[next_ue] = pre_nb_available_rbs[next_ue] + min_rb_unit; + } + } + break; + default: + break; + } + } + } + } } - } } - + i1=0; i2=0; i3=0; for (j=0;j<N_RBGS;j++){ - if(MIMO_mode_indicator[j] == 2) - i1 = i1+1; - else if(MIMO_mode_indicator[j] == 1) - i2 = i2+1; - else if(MIMO_mode_indicator[j] == 0) - i3 = i3+1; + if(MIMO_mode_indicator[j] == 2) + i1 = i1+1; + else if(MIMO_mode_indicator[j] == 1) + i2 = i2+1; + else if(MIMO_mode_indicator[j] == 0) + i3 = i3+1; } if((i1 < N_RBGS) && (i2>0) && (i3==0)) PHY_vars_eNB_g[Mod_id]->check_for_SUMIMO_transmissions = PHY_vars_eNB_g[Mod_id]->check_for_SUMIMO_transmissions + 1; - + if(i3 == N_RBGS && i1==0 && i2==0) PHY_vars_eNB_g[Mod_id]->FULL_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id]->FULL_MUMIMO_transmissions + 1; @@ -732,21 +746,21 @@ void dlsch_scheduler_pre_processor (unsigned char Mod_id, PHY_vars_eNB_g[Mod_id]->check_for_MUMIMO_transmissions = PHY_vars_eNB_g[Mod_id]->check_for_MUMIMO_transmissions + 1; PHY_vars_eNB_g[Mod_id]->check_for_total_transmissions = PHY_vars_eNB_g[Mod_id]->check_for_total_transmissions + 1; - - - - + + + + for(UE_id=0;UE_id<granted_UEs;UE_id++){ - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; - LOG_D(PHY,"******************Scheduling Information for UE%d ************************\n",UE_id); - LOG_D(PHY,"dl power offset UE%d = %d \n",UE_id,dl_pow_off[UE_id]); - LOG_D(PHY,"***********RB Alloc for every subband for UE%d ***********\n",UE_id); - for(j=0;j<N_RBGS;j++){ - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[UE_id][i]; - LOG_D(PHY,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,rballoc_sub_UE[UE_id][j]); - } - //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[UE_id]; - LOG_D(PHY,"Total RBs allocated for UE%d = %d\n",UE_id,pre_nb_available_rbs[UE_id]); + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].dl_pow_off = dl_pow_off[UE_id]; + LOG_D(PHY,"******************Scheduling Information for UE%d ************************\n",UE_id); + LOG_D(PHY,"dl power offset UE%d = %d \n",UE_id,dl_pow_off[UE_id]); + LOG_D(PHY,"***********RB Alloc for every subband for UE%d ***********\n",UE_id); + for(j=0;j<N_RBGS;j++){ + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].rballoc_sub[i] = rballoc_sub_UE[UE_id][i]; + LOG_D(PHY,"RB Alloc for UE%d and Subband%d = %d\n",UE_id,j,rballoc_sub_UE[UE_id][j]); + } + //PHY_vars_eNB_g[Mod_id]->mu_mimo_mode[UE_id].pre_nb_available_rbs = pre_nb_available_rbs[UE_id]; + LOG_D(PHY,"Total RBs allocated for UE%d = %d\n",UE_id,pre_nb_available_rbs[UE_id]); } } diff --git a/openair2/LAYER2/MAC/ra_procedures.c b/openair2/LAYER2/MAC/ra_procedures.c index 369ac7246d61fa7d91067cb393d07343eab323b5..b12fff2fcd66b638b8730c1a130a9871bfba6477 100644 --- a/openair2/LAYER2/MAC/ra_procedures.c +++ b/openair2/LAYER2/MAC/ra_procedures.c @@ -25,18 +25,18 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file openair2/LAYER2/MAC/ra_procedures.c -* \brief Routines for UE MAC-layer Random-access procedures (36.321) V8.6 2009-03 -* \author R. Knopp -* \date 2011 -* \version 0.1 -* \company Eurecom -* \email: knopp@eurecom.fr -* \note -* \warning -*/ + * \brief Routines for UE MAC-layer Random-access procedures (36.321) V8.6 2009-03 + * \author R. Knopp + * \date 2011 + * \version 0.1 + * \company Eurecom + * \email: knopp@eurecom.fr + * \note + * \warning + */ #include "extern.h" #include "defs.h" @@ -55,25 +55,25 @@ extern inline unsigned int taus(void); -s8 get_DELTA_PREAMBLE(u8 Mod_id) { +s8 get_DELTA_PREAMBLE(module_id_t module_idP) { - u8 prachConfigIndex = UE_mac_inst[Mod_id].radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; + u8 prachConfigIndex = UE_mac_inst[module_idP].radioResourceConfigCommon->prach_Config.prach_ConfigInfo.prach_ConfigIndex; u8 preambleformat; - if (UE_mac_inst[Mod_id].tdd_Config) { // TDD - if (prachConfigIndex < 20) - preambleformat = 0; - else if (prachConfigIndex < 30) - preambleformat = 1; - else if (prachConfigIndex < 40) - preambleformat = 2; - else if (prachConfigIndex < 48) - preambleformat = 3; - else - preambleformat = 4; + if (UE_mac_inst[module_idP].tdd_Config) { // TDD + if (prachConfigIndex < 20) + preambleformat = 0; + else if (prachConfigIndex < 30) + preambleformat = 1; + else if (prachConfigIndex < 40) + preambleformat = 2; + else if (prachConfigIndex < 48) + preambleformat = 3; + else + preambleformat = 4; } else { // FDD - preambleformat = prachConfigIndex>>2; + preambleformat = prachConfigIndex>>2; } switch (preambleformat) { case 0: @@ -86,8 +86,8 @@ s8 get_DELTA_PREAMBLE(u8 Mod_id) { return(8); default: LOG_E(MAC,"[UE %d] ue_procedures.c: FATAL, Illegal preambleformat %d, prachConfigIndex %d\n", - Mod_id, - preambleformat,prachConfigIndex); + module_idP, + preambleformat,prachConfigIndex); mac_xface->macphy_exit(""); return(0); } @@ -95,309 +95,309 @@ s8 get_DELTA_PREAMBLE(u8 Mod_id) { } /// This routine implements Section 5.1.2 (Random Access Resource Selection) from 36.321 -void get_prach_resources(u8 Mod_id, - u8 eNB_index, - u8 t_id, - u8 first_Msg3, - RACH_ConfigDedicated_t *rach_ConfigDedicated) { - - u8 Msg3_size = UE_mac_inst[Mod_id].RA_Msg3_size; - PRACH_RESOURCES_t *prach_resources = &UE_mac_inst[Mod_id].RA_prach_resources; +void get_prach_resources(module_id_t module_idP, + u8 eNB_index, + u8 t_id, + u8 first_Msg3, + RACH_ConfigDedicated_t *rach_ConfigDedicated) { + + u8 Msg3_size = UE_mac_inst[module_idP].RA_Msg3_size; + PRACH_RESOURCES_t *prach_resources = &UE_mac_inst[module_idP].RA_prach_resources; RACH_ConfigCommon_t *rach_ConfigCommon = NULL; u8 noGroupB = 0; u8 f_id = 0,num_prach=0; - if (UE_mac_inst[Mod_id].radioResourceConfigCommon) - rach_ConfigCommon = &UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon; + if (UE_mac_inst[module_idP].radioResourceConfigCommon) + rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; else { - LOG_E(MAC,"[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",Mod_id); - mac_xface->macphy_exit(""); + LOG_E(MAC,"[UE %d] FATAL radioResourceConfigCommon is NULL !!!\n",module_idP); + mac_xface->macphy_exit(""); } if (rach_ConfigDedicated) { // This is for network controlled Mobility, later - if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { - prach_resources->ra_PreambleIndex = rach_ConfigDedicated->ra_PreambleIndex; - prach_resources->ra_RACH_MaskIndex = rach_ConfigDedicated->ra_PRACH_MaskIndex; - return; - } + if (rach_ConfigDedicated->ra_PRACH_MaskIndex != 0) { + prach_resources->ra_PreambleIndex = rach_ConfigDedicated->ra_PreambleIndex; + prach_resources->ra_RACH_MaskIndex = rach_ConfigDedicated->ra_PRACH_MaskIndex; + return; + } } if (!rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) { - noGroupB = 1; + noGroupB = 1; } else { - if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA == - rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) - noGroupB = 1; + if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA == + rach_ConfigCommon->preambleInfo.numberOfRA_Preambles) + noGroupB = 1; } if (first_Msg3 == 1) { - if (noGroupB == 1) { - // use Group A procedure - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[Mod_id].RA_usedGroupA = 1; - } - else if ((Msg3_size < rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->messageSizeGroupA) || - (mac_xface->get_PL(Mod_id,eNB_index) > UE_mac_inst[Mod_id].RA_maxPL)) { - // use Group A procedure - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[Mod_id].RA_usedGroupA = 1; - } - else { // use Group B - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + - (taus())%(rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - UE_mac_inst[Mod_id].RA_usedGroupA = 0; - } - UE_mac_inst[Mod_id].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(Mod_id); + if (noGroupB == 1) { + // use Group A procedure + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } + else if ((Msg3_size < rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->messageSizeGroupA) || + (mac_xface->get_PL(module_idP,eNB_index) > UE_mac_inst[module_idP].RA_maxPL)) { + // use Group A procedure + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + UE_mac_inst[module_idP].RA_usedGroupA = 1; + } + else { // use Group B + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + + (taus())%(rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - + rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + UE_mac_inst[module_idP].RA_usedGroupA = 0; + } + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP); } else { // Msg3 is being retransmitted - if (UE_mac_inst[Mod_id].RA_usedGroupA == 1) { - if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; - else - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - } - else { - UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex = - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + - (taus())%(rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - - rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); - UE_mac_inst[Mod_id].RA_prach_resources.ra_RACH_MaskIndex = 0; - } + if (UE_mac_inst[module_idP].RA_usedGroupA == 1) { + if (rach_ConfigCommon->preambleInfo.preamblesGroupAConfig) + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())%rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA; + else + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = (taus())&0x3f; + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + } + else { + UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex = + rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA + + (taus())%(rach_ConfigCommon->preambleInfo.numberOfRA_Preambles - + rach_ConfigCommon->preambleInfo.preamblesGroupAConfig->sizeOfRA_PreamblesGroupA); + UE_mac_inst[module_idP].RA_prach_resources.ra_RACH_MaskIndex = 0; + } } // choose random PRACH resource in TDD - if (UE_mac_inst[Mod_id].tdd_Config) { - num_prach = mac_xface->get_num_prach_tdd(mac_xface->lte_frame_parms); - if ((num_prach>0) && (num_prach<6)) - UE_mac_inst[Mod_id].RA_prach_resources.ra_TDD_map_index = (taus()%num_prach); - f_id = mac_xface->get_fid_prach_tdd(mac_xface->lte_frame_parms, - UE_mac_inst[Mod_id].RA_prach_resources.ra_TDD_map_index); + if (UE_mac_inst[module_idP].tdd_Config) { + num_prach = mac_xface->get_num_prach_tdd(mac_xface->lte_frame_parms); + if ((num_prach>0) && (num_prach<6)) + UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index = (taus()%num_prach); + f_id = mac_xface->get_fid_prach_tdd(mac_xface->lte_frame_parms, + UE_mac_inst[module_idP].RA_prach_resources.ra_TDD_map_index); } // choose RA-RNTI - UE_mac_inst[Mod_id].RA_prach_resources.ra_RNTI = 1 + t_id + 10*f_id; + UE_mac_inst[module_idP].RA_prach_resources.ra_RNTI = 1 + t_id + 10*f_id; } -void Msg1_tx(u8 Mod_id,u32 frame, u8 eNB_id) { +void Msg1_tx(module_id_t module_idP,frame_t frameP, u8 eNB_id) { // start contention resolution timer - UE_mac_inst[Mod_id].RA_attempt_number++; + UE_mac_inst[module_idP].RA_attempt_number++; #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.opt_enabled) { - trace_pdu(0, NULL, 0, Mod_id, 3, UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex, - UE_mac_inst[Mod_id].subframe, 0, UE_mac_inst[Mod_id].RA_attempt_number); - LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", - Mod_id, frame, 1, UE_mac_inst[Mod_id].RA_Msg3_size); + trace_pdu(0, NULL, 0, module_idP, 3, UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex, + UE_mac_inst[module_idP].subframe, 0, UE_mac_inst[module_idP].RA_attempt_number); + LOG_D(OPT,"[UE %d][RAPROC] TX MSG1 Frame %d trace pdu for rnti %x with size %d\n", + module_idP, frameP, 1, UE_mac_inst[module_idP].RA_Msg3_size); } #endif } -void Msg3_tx(u8 Mod_id,u32 frame, u8 eNB_id) { +void Msg3_tx(module_id_t module_idP,frame_t frameP, u8 eNB_id) { // start contention resolution timer - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",Mod_id,frame); - UE_mac_inst[Mod_id].RA_contention_resolution_cnt = 0; - UE_mac_inst[Mod_id].RA_contention_resolution_timer_active = 1; + LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Msg3_tx: Setting contention resolution timer\n",module_idP,frameP); + UE_mac_inst[module_idP].RA_contention_resolution_cnt = 0; + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 1; #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.opt_enabled) { // msg3 - trace_pdu(0, &UE_mac_inst[Mod_id].CCCH_pdu.payload[0], UE_mac_inst[Mod_id].RA_Msg3_size, - Mod_id, 3, UE_mac_inst[Mod_id].crnti, UE_mac_inst[Mod_id].subframe, 0, 0); - LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", - Mod_id, frame, UE_mac_inst[Mod_id].crnti /*UE_mac_inst[Mod_id].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[Mod_id].RA_Msg3_size); + trace_pdu(0, &UE_mac_inst[module_idP].CCCH_pdu.payload[0], UE_mac_inst[module_idP].RA_Msg3_size, + module_idP, 3, UE_mac_inst[module_idP].crnti, UE_mac_inst[module_idP].subframe, 0, 0); + LOG_D(OPT,"[UE %d][RAPROC] MSG3 Frame %d trace pdu Preamble %d with size %d\n", + module_idP, frameP, UE_mac_inst[module_idP].crnti /*UE_mac_inst[module_idP].RA_prach_resources.ra_PreambleIndex*/, UE_mac_inst[module_idP].RA_Msg3_size); } #endif } -PRACH_RESOURCES_t *ue_get_rach(u8 Mod_id,u32 frame, u8 eNB_index,u8 subframe){ +PRACH_RESOURCES_t *ue_get_rach(module_id_t module_idP,frame_t frameP, u8 eNB_indexP,sub_frame_t subframeP){ - u8 Size=0; - UE_MODE_t UE_mode = mac_xface->get_ue_mode(Mod_id,eNB_index); - u8 lcid = CCCH; - u16 Size16; + u8 Size=0; + UE_MODE_t UE_mode = mac_xface->get_ue_mode(module_idP,eNB_indexP); + u8 lcid = CCCH; + u16 Size16; struct RACH_ConfigCommon *rach_ConfigCommon = (struct RACH_ConfigCommon *)NULL; - s32 frame_diff=0; - mac_rlc_status_resp_t rlc_status; - u8 dcch_header_len=0; - u16 sdu_lengths[8]; - u8 ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; + s32 frame_diff=0; + mac_rlc_status_resp_t rlc_status; + u8 dcch_header_len=0; + u16 sdu_lengths[8]; + u8 ulsch_buff[MAX_ULSCH_PAYLOAD_BYTES]; if (UE_mode == PRACH) { - if (UE_mac_inst[Mod_id].radioResourceConfigCommon) - rach_ConfigCommon = &UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon; - else { - return(NULL); - } - if (Is_rrc_registered == 1) { - - if (UE_mac_inst[Mod_id].RA_active == 0) { - // check if RRC is ready to initiate the RA procedure - Size = mac_rrc_data_req(Mod_id, - frame, - CCCH,1, - &UE_mac_inst[Mod_id].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, - eNB_index, - 0); - Size16 = (u16)Size; - - // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",Mod_id,frame,Size); - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",Mod_id,frame,Size); - - if (Size>0) { - - UE_mac_inst[Mod_id].RA_active = 1; - UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[Mod_id].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); - UE_mac_inst[Mod_id].RA_prachMaskIndex = 0; - UE_mac_inst[Mod_id].RA_prach_resources.Msg3 = UE_mac_inst[Mod_id].CCCH_pdu.payload; - UE_mac_inst[Mod_id].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - if (rach_ConfigCommon) { - UE_mac_inst[Mod_id].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - if (UE_mac_inst[Mod_id].RA_window_cnt == 9) - UE_mac_inst[Mod_id].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - else { - LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",Mod_id,frame); - mac_xface->macphy_exit(""); - } - UE_mac_inst[Mod_id].RA_tx_frame = frame; - UE_mac_inst[Mod_id].RA_tx_subframe = subframe; - UE_mac_inst[Mod_id].RA_backoff_frame = frame; - UE_mac_inst[Mod_id].RA_backoff_subframe = subframe; - // Fill in preamble and PRACH resource - get_prach_resources(Mod_id,eNB_index,subframe,1,NULL); - - generate_ulsch_header((u8*)&UE_mac_inst[Mod_id].CCCH_pdu.payload[0], // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - NULL, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 1); //post_padding - - return(&UE_mac_inst[Mod_id].RA_prach_resources); - } - else if (UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DCCH] > 0) { - // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) - dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element - rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO, - DCCH, - 6); - if (UE_mac_inst[Mod_id].crnti_before_ho) - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", - Mod_id,frame, UE_mac_inst[Mod_id].crnti,UE_mac_inst[Mod_id].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); - else - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", - Mod_id,frame, rlc_status.bytes_in_buffer,dcch_header_len); - - sdu_lengths[0] = mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO, - DCCH, - (char *)&ulsch_buff[0]); - - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",Mod_id,sdu_lengths[0]); - update_bsr(Mod_id, frame, DCCH,UE_mac_inst[Mod_id].scheduling_info.LCGID[DCCH]); - //header_len +=2; - UE_mac_inst[Mod_id].RA_active = 1; - UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; - UE_mac_inst[Mod_id].RA_Msg3_size = Size+dcch_header_len; - UE_mac_inst[Mod_id].RA_prachMaskIndex = 0; - UE_mac_inst[Mod_id].RA_prach_resources.Msg3 = ulsch_buff; - UE_mac_inst[Mod_id].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) - if (rach_ConfigCommon) { - UE_mac_inst[Mod_id].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - if (UE_mac_inst[Mod_id].RA_window_cnt == 9) - UE_mac_inst[Mod_id].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! - } - else { - LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",Mod_id,frame); - mac_xface->macphy_exit(""); - } - UE_mac_inst[Mod_id].RA_tx_frame = frame; - UE_mac_inst[Mod_id].RA_tx_subframe = subframe; - UE_mac_inst[Mod_id].RA_backoff_frame = frame; - UE_mac_inst[Mod_id].RA_backoff_subframe = subframe; - // Fill in preamble and PRACH resource - get_prach_resources(Mod_id,eNB_index,subframe,1,NULL); - generate_ulsch_header((u8*)ulsch_buff, // mac header - 1, // num sdus - 0, // short pading - &Size16, // sdu length - &lcid, // sdu lcid - NULL, // power headroom - &UE_mac_inst[Mod_id].crnti, // crnti - NULL, // truncated bsr - NULL, // short bsr - NULL, // long_bsr - 0); //post_padding - - return(&UE_mac_inst[Mod_id].RA_prach_resources); - } + if (UE_mac_inst[module_idP].radioResourceConfigCommon) + rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + else { + return(NULL); } - else { // RACH is active - LOG_D(MAC,"[MAC][UE %d][RAPROC] frame %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",Mod_id, - frame,subframe,UE_mac_inst[Mod_id].RA_window_cnt, - UE_mac_inst[Mod_id].RA_tx_frame,UE_mac_inst[Mod_id].RA_tx_subframe); - // compute backoff parameters - if (UE_mac_inst[Mod_id].RA_backoff_cnt>0) { - frame_diff = (s32)frame - UE_mac_inst[Mod_id].RA_backoff_frame; - if (frame_diff < 0) - frame_diff = -frame_diff; - UE_mac_inst[Mod_id].RA_backoff_cnt -= ((10*frame_diff) + (subframe-UE_mac_inst[Mod_id].RA_backoff_subframe)); - - UE_mac_inst[Mod_id].RA_backoff_frame = frame; - UE_mac_inst[Mod_id].RA_backoff_subframe = subframe; - } - // compute RA window parameters - if (UE_mac_inst[Mod_id].RA_window_cnt>0) { - frame_diff = (s32)frame - UE_mac_inst[Mod_id].RA_tx_frame; - if (frame_diff < 0) - frame_diff = -frame_diff; - UE_mac_inst[Mod_id].RA_window_cnt -= ((10*frame_diff) + (subframe-UE_mac_inst[Mod_id].RA_tx_subframe)); - LOG_D(MAC,"[MAC][UE %d][RAPROC] frame %d, subframe %d: RA Active, adjusted window cnt %d\n",Mod_id, - frame,subframe,UE_mac_inst[Mod_id].RA_window_cnt); - } - if ((UE_mac_inst[Mod_id].RA_window_cnt<=0) && - (UE_mac_inst[Mod_id].RA_backoff_cnt<=0)) { - - UE_mac_inst[Mod_id].RA_tx_frame = frame; - UE_mac_inst[Mod_id].RA_tx_subframe = subframe; - UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER++; - UE_mac_inst[Mod_id].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition - if (UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER == rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { - LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",Mod_id,frame,rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax); - // send message to RRC - UE_mac_inst[Mod_id].RA_PREAMBLE_TRANSMISSION_COUNTER=1; - UE_mac_inst[Mod_id].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(Mod_id); - } - UE_mac_inst[Mod_id].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; - UE_mac_inst[Mod_id].RA_backoff_cnt = 0; - - // Fill in preamble and PRACH resource - get_prach_resources(Mod_id,eNB_index,subframe,0,NULL); - return(&UE_mac_inst[Mod_id].RA_prach_resources); - } + if (Is_rrc_registered == 1) { + + if (UE_mac_inst[module_idP].RA_active == 0) { + // check if RRC is ready to initiate the RA procedure + Size = mac_rrc_data_req(module_idP, + frameP, + CCCH,1, + &UE_mac_inst[module_idP].CCCH_pdu.payload[sizeof(SCH_SUBHEADER_SHORT)+1],0, + eNB_indexP, + 0); + Size16 = (u16)Size; + + // LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_DATA_REQ (RRCConnectionRequest eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, module_idP, eNB_indexP, module_idP); + LOG_D(MAC,"[UE %d] Frame %d: Requested RRCConnectionRequest, got %d bytes\n",module_idP,frameP,Size); + + if (Size>0) { + + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+sizeof(SCH_SUBHEADER_SHORT)+sizeof(SCH_SUBHEADER_SHORT); + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = UE_mac_inst[module_idP].CCCH_pdu.payload; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + if (rach_ConfigCommon) { + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + if (UE_mac_inst[module_idP].RA_window_cnt == 9) + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + else { + LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + mac_xface->macphy_exit(""); + } + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,eNB_indexP,subframeP,1,NULL); + + generate_ulsch_header((u8*)&UE_mac_inst[module_idP].CCCH_pdu.payload[0], // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + NULL, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 1); //post_padding + + return(&UE_mac_inst[module_idP].RA_prach_resources); + } + else if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DCCH] > 0) { + // This is for triggering a transmission on DCCH using PRACH (during handover, or sending SR for example) + dcch_header_len = 2 + 2; /// SHORT Subheader + C-RNTI control element + rlc_status = mac_rlc_status_ind(0, module_idP,frameP,0,RLC_MBMS_NO, + DCCH, + 6); + if (UE_mac_inst[module_idP].crnti_before_ho) + LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, HO RRCConnectionReconfigurationComplete (%x, %x), RRC message has %d bytes to send throug PRACH (mac header len %d)\n", + module_idP,frameP, UE_mac_inst[module_idP].crnti,UE_mac_inst[module_idP].crnti_before_ho, rlc_status.bytes_in_buffer,dcch_header_len); + else + LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to send through PRACH(mac header len %d)\n", + module_idP,frameP, rlc_status.bytes_in_buffer,dcch_header_len); + + sdu_lengths[0] = mac_rlc_data_req(eNB_indexP, module_idP,frameP,0, RLC_MBMS_NO, + DCCH, + (char *)&ulsch_buff[0]); + + LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); + update_bsr(module_idP, frameP, DCCH,UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + //header_len +=2; + UE_mac_inst[module_idP].RA_active = 1; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER = 1; + UE_mac_inst[module_idP].RA_Msg3_size = Size+dcch_header_len; + UE_mac_inst[module_idP].RA_prachMaskIndex = 0; + UE_mac_inst[module_idP].RA_prach_resources.Msg3 = ulsch_buff; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; // add the backoff condition here if we have it from a previous RA reponse which failed (i.e. backoff indicator) + if (rach_ConfigCommon) { + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + if (UE_mac_inst[module_idP].RA_window_cnt == 9) + UE_mac_inst[module_idP].RA_window_cnt = 10; // Note: 9 subframe window doesn't exist, after 8 is 10! + } + else { + LOG_D(MAC,"[UE %d] FATAL Frame %d: rach_ConfigCommon is NULL !!!\n",module_idP,frameP); + mac_xface->macphy_exit(""); + } + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,eNB_indexP,subframeP,1,NULL); + generate_ulsch_header((u8*)ulsch_buff, // mac header + 1, // num sdus + 0, // short pading + &Size16, // sdu length + &lcid, // sdu lcid + NULL, // power headroom + &UE_mac_inst[module_idP].crnti, // crnti + NULL, // truncated bsr + NULL, // short bsr + NULL, // long_bsr + 0); //post_padding + + return(&UE_mac_inst[module_idP].RA_prach_resources); + } + } + else { // RACH is active + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, window cnt %d (RA_tx_frame %d, RA_tx_subframe %d)\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt, + UE_mac_inst[module_idP].RA_tx_frame,UE_mac_inst[module_idP].RA_tx_subframe); + // compute backoff parameters + if (UE_mac_inst[module_idP].RA_backoff_cnt>0) { + frame_diff = (s32)frameP - UE_mac_inst[module_idP].RA_backoff_frame; + if (frame_diff < 0) + frame_diff = -frame_diff; + UE_mac_inst[module_idP].RA_backoff_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_backoff_subframe)); + + UE_mac_inst[module_idP].RA_backoff_frame = frameP; + UE_mac_inst[module_idP].RA_backoff_subframe = subframeP; + } + // compute RA window parameters + if (UE_mac_inst[module_idP].RA_window_cnt>0) { + frame_diff = (frame_t)frameP - UE_mac_inst[module_idP].RA_tx_frame; + if (frame_diff < 0) + frame_diff = -frame_diff; + UE_mac_inst[module_idP].RA_window_cnt -= ((10*frame_diff) + (subframeP-UE_mac_inst[module_idP].RA_tx_subframe)); + LOG_D(MAC,"[MAC][UE %d][RAPROC] frameP %d, subframe %d: RA Active, adjusted window cnt %d\n",module_idP, + frameP,subframeP,UE_mac_inst[module_idP].RA_window_cnt); + } + if ((UE_mac_inst[module_idP].RA_window_cnt<=0) && + (UE_mac_inst[module_idP].RA_backoff_cnt<=0)) { + + UE_mac_inst[module_idP].RA_tx_frame = frameP; + UE_mac_inst[module_idP].RA_tx_subframe = subframeP; + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER++; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER += (rach_ConfigCommon->powerRampingParameters.powerRampingStep<<1); // 2dB increments in ASN.1 definition + if (UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER == rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax) { + LOG_D(MAC,"[UE %d] Frame %d: Maximum number of RACH attempts (%d)\n",module_idP,frameP,rach_ConfigCommon->ra_SupervisionInfo.preambleTransMax); + // send message to RRC + UE_mac_inst[module_idP].RA_PREAMBLE_TRANSMISSION_COUNTER=1; + UE_mac_inst[module_idP].RA_prach_resources.ra_PREAMBLE_RECEIVED_TARGET_POWER = get_Po_NOMINAL_PUSCH(module_idP); + } + UE_mac_inst[module_idP].RA_window_cnt = 2+ rach_ConfigCommon->ra_SupervisionInfo.ra_ResponseWindowSize; + UE_mac_inst[module_idP].RA_backoff_cnt = 0; + + // Fill in preamble and PRACH resource + get_prach_resources(module_idP,eNB_indexP,subframeP,0,NULL); + return(&UE_mac_inst[module_idP].RA_prach_resources); + } + } } - } } else if (UE_mode == PUSCH) { - LOG_D(MAC,"[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",Mod_id); - mac_xface->macphy_exit(""); + LOG_D(MAC,"[UE %d] FATAL: Should not have checked for RACH in PUSCH yet ...",module_idP); + mac_xface->macphy_exit(""); } return(NULL); } diff --git a/openair2/LAYER2/MAC/rar_tools.c b/openair2/LAYER2/MAC/rar_tools.c index 8696fcf5378516d0d6a0772595f9e15c990e4c11..70f20446d789d425761e964ac9a99e0759916017 100644 --- a/openair2/LAYER2/MAC/rar_tools.c +++ b/openair2/LAYER2/MAC/rar_tools.c @@ -25,15 +25,15 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file rar_tools.c -* \brief random access tools -* \author Raymond Knopp -* \date 2011 -* \version 0.5 -* @ingroup _mac + * \brief random access tools + * \author Raymond Knopp + * \date 2011 + * \version 0.5 + * @ingroup _mac -*/ + */ #include "defs.h" #include "extern.h" @@ -54,11 +54,11 @@ extern unsigned short RIV2first_rb_LUT25[512]; extern inline unsigned int taus(void); -unsigned short fill_rar(u8 Mod_id, - u32 frame, - u8 *dlsch_buffer, - u16 N_RB_UL, - u8 input_buffer_length) { +unsigned short fill_rar(module_id_t module_idP, + frame_t frameP, + u8 *dlsch_buffer, + u16 N_RB_UL, + u8 input_buffer_length) { RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; // RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); @@ -68,34 +68,34 @@ unsigned short fill_rar(u8 Mod_id, uint8_t mcs,TPC,ULdelay,cqireq; for (i=0;i<NB_RA_PROC_MAX;i++) { - if (eNB_mac_inst[Mod_id].RA_template[i].generate_rar == 1) { - ra_idx=i; - eNB_mac_inst[Mod_id].RA_template[i].generate_rar = 0; - break; - } + if (eNB_mac_inst[module_idP].RA_template[i].generate_rar == 1) { + ra_idx=i; + eNB_mac_inst[module_idP].RA_template[i].generate_rar = 0; + break; + } } // subheader fixed rarh->E = 0; // First and last RAR rarh->T = 1; // 0 for E/T/R/R/BI subheader, 1 for E/T/RAPID subheader - rarh->RAPID = eNB_mac_inst[Mod_id].RA_template[ra_idx].preamble_index; // Respond to Preamble 0 only for the moment + rarh->RAPID = eNB_mac_inst[module_idP].RA_template[ra_idx].preamble_index; // Respond to Preamble 0 only for the moment /* rar->R = 0; - rar->Timing_Advance_Command = eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset/4; + rar->Timing_Advance_Command = eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset/4; rar->hopping_flag = 0; rar->rb_alloc = mac_xface->computeRIV(N_RB_UL,12,2); // 2 RB rar->mcs = 2; // mcs 2 rar->TPC = 4; // 2 dB power adjustment rar->UL_delay = 0; rar->cqi_req = 1; - rar->t_crnti = eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti; - */ - rar[4] = (uint8_t)(eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti>>8); - rar[5] = (uint8_t)(eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti&0xff); - eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset = 0; - //eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset /= 16; - rar[0] = (uint8_t)(eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 - rar[1] = (uint8_t)(eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 + rar->t_crnti = eNB_mac_inst[module_idP].RA_template[ra_idx].rnti; + */ + rar[4] = (uint8_t)(eNB_mac_inst[module_idP].RA_template[ra_idx].rnti>>8); + rar[5] = (uint8_t)(eNB_mac_inst[module_idP].RA_template[ra_idx].rnti&0xff); + eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset = 0; + //eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset /= 16; + rar[0] = (uint8_t)(eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset>>(2+4)); // 7 MSBs of timing advance + divide by 4 + rar[1] = (uint8_t)(eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset<<(4-2))&0xf0; // 4 LSBs of timing advance + divide by 4 rballoc = mac_xface->computeRIV(N_RB_UL,1,1); // first PRB only for UL Grant rar[1] |= (rballoc>>7)&7; // Hopping = 0 (bit 3), 3 MSBs of rballoc rar[2] = ((uint8_t)(rballoc&0xff))<<1; // 7 LSBs of rballoc @@ -106,59 +106,59 @@ unsigned short fill_rar(u8 Mod_id, rar[2] |= ((mcs&0x8)>>3); // mcs 10 rar[3] = (((mcs&0x7)<<5)) | ((TPC&7)<<2) | ((ULdelay&1)<<1) | (cqireq&1); - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Generating RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ra_idx %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",Mod_id,frame, - *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], - ra_idx, - eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti, - rarh->RAPID,eNB_mac_inst[Mod_id].RA_template[0].preamble_index, - eNB_mac_inst[Mod_id].RA_template[ra_idx].timing_offset); + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Generating RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for ra_idx %d, CRNTI %x,preamble %d/%d,TIMING OFFSET %d\n",module_idP,frame, + *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], + ra_idx, + eNB_mac_inst[module_idP].RA_template[ra_idx].rnti, + rarh->RAPID,eNB_mac_inst[module_idP].RA_template[0].preamble_index, + eNB_mac_inst[module_idP].RA_template[ra_idx].timing_offset); #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.opt_enabled){ - trace_pdu(1, dlsch_buffer, input_buffer_length, Mod_id, 2, 1, - eNB_mac_inst[Mod_id].subframe, 0, 0); - LOG_I(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", - Mod_id, frame, eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti, + trace_pdu(1, dlsch_buffer, input_buffer_length, module_idP, 2, 1, + eNB_mac_inst[module_idP].subframe, 0, 0); + LOG_I(OPT,"[eNB %d][RAPROC] RAR Frame %d trace pdu for rnti %x and rapid %d size %d\n", + module_idP, frame, eNB_mac_inst[module_idP].RA_template[ra_idx].rnti, rarh->RAPID, input_buffer_length); } #endif - return(eNB_mac_inst[Mod_id].RA_template[ra_idx].rnti); + return(eNB_mac_inst[module_idP].RA_template[ra_idx].rnti); } -uint16_t ue_process_rar(u8 Mod_id, u32 frame, u8 *dlsch_buffer,u16 *t_crnti,u8 preamble_index) { +uint16_t ue_process_rar(module_id_t module_idP, frame_t frameP, u8 *dlsch_buffer,rnti_t *t_crnti,u8 preamble_index) { RA_HEADER_RAPID *rarh = (RA_HEADER_RAPID *)dlsch_buffer; // RAR_PDU *rar = (RAR_PDU *)(dlsch_buffer+1); uint8_t *rar = (uint8_t *)(dlsch_buffer+1); - - LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",Mod_id,frame, - *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], - rarh->RAPID,preamble_index); + + LOG_I(MAC,"[eNB %d][RAPROC] Frame %d Received RAR (%02x|%02x.%02x.%02x.%02x.%02x.%02x) for preamble %d/%d\n",module_idP,frame, + *(uint8_t*)rarh,rar[0],rar[1],rar[2],rar[3],rar[4],rar[5], + rarh->RAPID,preamble_index); #ifdef DEBUG_RAR - LOG_D(MAC,"[UE %d][RAPROC] rarh->E %d\n",Mod_id,rarh->E); - LOG_D(MAC,"[UE %d][RAPROC] rarh->T %d\n",Mod_id,rarh->T); - LOG_D(MAC,"[UE %d][RAPROC] rarh->RAPID %d\n",Mod_id,rarh->RAPID); - - // LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",Mod_id,rar->R); - LOG_I(MAC,"[UE %d][RAPROC] rar->Timing_Advance_Command %d\n",Mod_id,(((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); - // LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",Mod_id,rar->hopping_flag); - // LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",Mod_id,rar->rb_alloc); - // LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",Mod_id,rar->mcs); - // LOG_I(MAC,"[UE %d][RAPROC] rar->TPC %d\n",Mod_id,rar->TPC); - // LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",Mod_id,rar->UL_delay); - // LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",Mod_id,rar->cqi_req); - LOG_I(MAC,"[UE %d][RAPROC] rar->t_crnti %x\n",Mod_id,(uint16_t)rar[5]+(rar[4]<<8)); + LOG_D(MAC,"[UE %d][RAPROC] rarh->E %d\n",module_idP,rarh->E); + LOG_D(MAC,"[UE %d][RAPROC] rarh->T %d\n",module_idP,rarh->T); + LOG_D(MAC,"[UE %d][RAPROC] rarh->RAPID %d\n",module_idP,rarh->RAPID); + + // LOG_I(MAC,"[UE %d][RAPROC] rar->R %d\n",module_idP,rar->R); + LOG_I(MAC,"[UE %d][RAPROC] rar->Timing_Advance_Command %d\n",module_idP,(((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); + // LOG_I(MAC,"[UE %d][RAPROC] rar->hopping_flag %d\n",module_idP,rar->hopping_flag); + // LOG_I(MAC,"[UE %d][RAPROC] rar->rb_alloc %d\n",module_idP,rar->rb_alloc); + // LOG_I(MAC,"[UE %d][RAPROC] rar->mcs %d\n",module_idP,rar->mcs); + // LOG_I(MAC,"[UE %d][RAPROC] rar->TPC %d\n",module_idP,rar->TPC); + // LOG_I(MAC,"[UE %d][RAPROC] rar->UL_delay %d\n",module_idP,rar->UL_delay); + // LOG_I(MAC,"[UE %d][RAPROC] rar->cqi_req %d\n",module_idP,rar->cqi_req); + LOG_I(MAC,"[UE %d][RAPROC] rar->t_crnti %x\n",module_idP,(uint16_t)rar[5]+(rar[4]<<8)); #endif - + if (preamble_index == rarh->RAPID) { - *t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti; - UE_mac_inst[Mod_id].crnti = *t_crnti;//rar->t_crnti; - //return(rar->Timing_Advance_Command); - return((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); + *t_crnti = (uint16_t)rar[5]+(rar[4]<<8);//rar->t_crnti; + UE_mac_inst[module_idP].crnti = *t_crnti;//rar->t_crnti; + //return(rar->Timing_Advance_Command); + return((((uint16_t)(rar[0]&0x7f))<<4) + (rar[1]>>4)); } else { - UE_mac_inst[Mod_id].crnti=0; - return(0xffff); + UE_mac_inst[module_idP].crnti=0; + return(0xffff); } } diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c index 3cff02fafcd5b0fcc61da2ff43c14e1e706b2c2e..910cd145c6cbadca28a60074ab782d28099ec05e 100644 --- a/openair2/LAYER2/MAC/ue_procedures.c +++ b/openair2/LAYER2/MAC/ue_procedures.c @@ -25,16 +25,16 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file ue_procedures.c -* \brief procedures related to UE -* \author Raymond Knopp, Navid Nikaein -* \date 2011 -* \version 0.5 -* \email: navid.nikaein@eurecom.fr -* @ingroup _mac + * \brief procedures related to UE + * \author Raymond Knopp, Navid Nikaein + * \date 2011 + * \version 0.5 + * \email: navid.nikaein@eurecom.fr + * @ingroup _mac -*/ + */ #ifdef EXMIMO #include <pthread.h> @@ -78,7 +78,7 @@ #ifndef USER_MODE #define msg debug_msg #endif -*/ + */ mapping BSR_names[] = { {"NONE", 0}, {"SHORT BSR", 1}, @@ -91,52 +91,51 @@ mapping BSR_names[] = { extern inline unsigned int taus(void); -void ue_init_mac(u8 Mod_id){ +void ue_init_mac(module_id_t module_idP){ 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); - + LOG_I(MAC,"[UE%d] Applying default macMainConfig\n",module_idP); + + //UE_mac_inst[module_idP].scheduling_info.macConfig=NULL; + UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer= MAC_MainConfig__ul_SCH_Config__retxBSR_Timer_sf2560; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer=MAC_MainConfig__ul_SCH_Config__periodicBSR_Timer_infinity; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer = MAC_MainConfig__phr_Config__setup__periodicPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer = MAC_MainConfig__phr_Config__setup__prohibitPHR_Timer_sf20; + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = MAC_MainConfig__phr_Config__setup__dl_PathlossChange_dB1; + UE_mac_inst[module_idP].PHR_state = MAC_MainConfig__phr_Config_PR_setup; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer=0; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; + UE_mac_inst[module_idP].scheduling_info.maxHARQ_Tx=MAC_MainConfig__ul_SCH_Config__maxHARQ_Tx_n5; + UE_mac_inst[module_idP].scheduling_info.ttiBundling=0; + UE_mac_inst[module_idP].scheduling_info.drx_config=NULL; + UE_mac_inst[module_idP].scheduling_info.phr_config=NULL; + UE_mac_inst[module_idP].scheduling_info.periodicBSR_SF = get_sf_periodicBSRTimer(UE_mac_inst[module_idP].scheduling_info.periodicBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.retxBSR_SF = get_sf_retxBSRTimer(UE_mac_inst[module_idP].scheduling_info.retxBSR_Timer); + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.PathlossChange_db = get_db_dl_PathlossChange(UE_mac_inst[module_idP].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; + LOG_D(MAC,"[UE%d] Applying default logical channel config for LCGID %d\n",module_idP,i); + UE_mac_inst[module_idP].scheduling_info.Bj[i]=-1; + UE_mac_inst[module_idP].scheduling_info.bucket_size[i]=-1; + if (i < DTCH) // initilize all control channels lcgid to 0 + UE_mac_inst[module_idP].scheduling_info.LCGID[i]=0; + else // initialize all the data channels lcgid to 1 + UE_mac_inst[module_idP].scheduling_info.LCGID[i]=1; + UE_mac_inst[module_idP].scheduling_info.LCID_status[i]=0; } } unsigned char *parse_header(unsigned char *mac_header, - unsigned char *num_ce, - unsigned char *num_sdu, - unsigned char *rx_ces, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) { + unsigned char *num_ce, + unsigned char *num_sdu, + unsigned char *rx_ces, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { unsigned char not_done=1,num_ces=0,num_sdus=0,lcid, num_sdu_cnt; unsigned char *mac_header_ptr = mac_header; @@ -144,57 +143,57 @@ unsigned char *parse_header(unsigned char *mac_header, while (not_done==1) { - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { - // printf("E=0\n"); - not_done = 0; - } - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - if (lcid < UE_CONT_RES) { - //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); - if (not_done==0) {// last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length-(mac_header_ptr-mac_header)-ce_len; - for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) - length -= rx_lengths[num_sdu_cnt]; + if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { + // printf("E=0\n"); + not_done = 0; } - else { - if (((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) { - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3; + lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; + if (lcid < UE_CONT_RES) { + //printf("[MAC][UE] header %x.%x.%x\n",mac_header_ptr[0],mac_header_ptr[1],mac_header_ptr[2]); + if (not_done==0) {// last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length-(mac_header_ptr-mac_header)-ce_len; + for (num_sdu_cnt=0; num_sdu_cnt < num_sdus ; num_sdu_cnt++) + length -= rx_lengths[num_sdu_cnt]; + } + else { + if (((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) { + length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); + mac_header_ptr += 3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] parse long sdu, size %x \n",length); + LOG_D(MAC,"[UE] parse long sdu, size %x \n",length); #endif - - } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2; - } - } + + } else { //if (((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F == 0) { + length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; + mac_header_ptr += 2; + } + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] sdu %d lcid %d length %d (offset now %d)\n", - num_sdus,lcid,length,mac_header_ptr-mac_header); + LOG_D(MAC,"[UE] sdu %d lcid %d length %d (offset now %d)\n", + num_sdus,lcid,length,mac_header_ptr-mac_header); #endif - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } - else { // This is a control element subheader - if (lcid == SHORT_PADDING) { - mac_header_ptr++; - } - else { - rx_ces[num_ces] = lcid; - num_ces++; - mac_header_ptr ++; - if (lcid==TIMING_ADV_CMD) - ce_len++; - else if (lcid==UE_CONT_RES) - ce_len+=6; + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; } + else { // This is a control element subheader + if (lcid == SHORT_PADDING) { + mac_header_ptr++; + } + else { + rx_ces[num_ces] = lcid; + num_ces++; + mac_header_ptr ++; + if (lcid==TIMING_ADV_CMD) + ce_len++; + else if (lcid==UE_CONT_RES) + ce_len+=6; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] ce %d lcid %d (offset now %d)\n",num_ces,lcid,mac_header_ptr-mac_header); + LOG_D(MAC,"[UE] ce %d lcid %d (offset now %d)\n",num_ces,lcid,mac_header_ptr-mac_header); #endif - } + } } *num_ce = num_ces; *num_sdu = num_sdus; @@ -202,74 +201,73 @@ unsigned char *parse_header(unsigned char *mac_header, return(mac_header_ptr); } -u32 ue_get_SR(u8 Mod_id,u32 frame,u8 eNB_id,u16 rnti, u8 subframe) { +u32 ue_get_SR(module_id_t module_idP,frame_t frame,u8 eNB_id,u16 rnti, sub_frame_t subframe) { // no UL-SCH resources available for this tti && UE has a valid PUCCH resources for SR configuration for this tti // int MGL=6;// measurement gap length in ms - int MGRP=0; // measurement gap repition period in ms - int gapOffset=-1; - int T=0; - // int sfn=0; + int MGRP = 0; // measurement gap repetition period in ms + int gapOffset = -1; + int T = 0; - DevCheck(Mod_id < NB_UE_INST, Mod_id, NB_UE_INST, 0); + DevCheck(module_idP < NB_UE_INST, module_idP, NB_UE_INST, 0); // determin the measurement gap LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d PHY asks for SR (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - Mod_id,rnti,frame,subframe, - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER, - (1<<(2+UE_mac_inst[Mod_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), - UE_mac_inst[Mod_id].scheduling_info.SR_pending); - - if (UE_mac_inst[Mod_id].measGapConfig !=NULL){ - if (UE_mac_inst[Mod_id].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0){ - MGRP= 40; - gapOffset= UE_mac_inst[Mod_id].measGapConfig->choice.setup.gapOffset.choice.gp0; - }else if (UE_mac_inst[Mod_id].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1){ - MGRP= 80; - gapOffset= UE_mac_inst[Mod_id].measGapConfig->choice.setup.gapOffset.choice.gp1; - }else{ - LOG_W(MAC, "Measurement GAP offset is unknown\n"); - } - T=MGRP/10; - //check the measurement gap and sr prohibit timer - if ((subframe == gapOffset %10) && ((frame %T) == (floor(gapOffset/10))) - && (UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer_Running =0)){ - UE_mac_inst[Mod_id].scheduling_info.SR_pending=1; - return(0); - } + module_idP,rnti,frame,subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + + if (UE_mac_inst[module_idP].measGapConfig !=NULL){ + if (UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp0){ + MGRP= 40; + gapOffset= UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.choice.gp0; + }else if (UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.present == MeasGapConfig__setup__gapOffset_PR_gp1){ + MGRP= 80; + gapOffset= UE_mac_inst[module_idP].measGapConfig->choice.setup.gapOffset.choice.gp1; + }else{ + LOG_W(MAC, "Measurement GAP offset is unknown\n"); + } + T=MGRP/10; + //check the measurement gap and sr prohibit timer + if ((subframe == gapOffset %10) && ((frame %T) == (floor(gapOffset/10))) + && (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running =0)){ + UE_mac_inst[module_idP].scheduling_info.SR_pending=1; + return(0); + } } - if ((UE_mac_inst[Mod_id].scheduling_info.SR_pending==1) && - (UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER < - (1<<(2+UE_mac_inst[Mod_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax))) - ){ - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER++; - // start the sr-prohibittimer : rel 9 and above - if (UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer > 0) { // timer configured - UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer--; - UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer_Running=1; - } else - UE_mac_inst[Mod_id].scheduling_info.sr_ProhibitTimer_Running=0; - LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR_indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", - Mod_id,rnti,frame,subframe, - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER, - (1<<(2+UE_mac_inst[Mod_id].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), - UE_mac_inst[Mod_id].scheduling_info.SR_pending); - - //UE_mac_inst[Mod_id].ul_active =1; - - return(1); //instruct phy to signal SR + if ((UE_mac_inst[module_idP].scheduling_info.SR_pending==1) && + (UE_mac_inst[module_idP].scheduling_info.SR_COUNTER < + (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax))) + ){ + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER++; + // start the sr-prohibittimer : rel 9 and above + if (UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer > 0) { // timer configured + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer--; + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=1; + } else + UE_mac_inst[module_idP].scheduling_info.sr_ProhibitTimer_Running=0; + LOG_D(MAC,"[UE %d][SR %x] Frame %d subframe %d send SR_indication (SR_COUNTER/dsr_TransMax %d/%d), SR_pending %d\n", + module_idP,rnti,frame,subframe, + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER, + (1<<(2+UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->choice.setup.dsr_TransMax)), + UE_mac_inst[module_idP].scheduling_info.SR_pending); + + //UE_mac_inst[module_idP].ul_active =1; + + return(1); //instruct phy to signal SR } else{ - // notify RRC to relase PUCCH/SRS - // clear any configured dl/ul - // initiate RA - UE_mac_inst[Mod_id].scheduling_info.SR_pending=0; - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER=0; - return(0); + // notify RRC to relase PUCCH/SRS + // clear any configured dl/ul + // initiate RA + UE_mac_inst[module_idP].scheduling_info.SR_pending=0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + return(0); } } -void ue_send_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index) { +void ue_send_sdu(module_id_t module_idP,frame_t frameP,u8 *sdu,u16 sdu_len,u8 eNB_index) { unsigned char rx_ces[MAX_NUM_CE],num_ce,num_sdu,i,*payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; @@ -282,16 +280,16 @@ void ue_send_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index) { #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.opt_enabled) { - trace_pdu(1, sdu, sdu_len, Mod_id, 3, UE_mac_inst[Mod_id].crnti, - UE_mac_inst[Mod_id].subframe, 0, 0); + trace_pdu(1, sdu, sdu_len, module_idP, 3, UE_mac_inst[module_idP].crnti, + UE_mac_inst[module_idP].subframe, 0, 0); } #endif payload_ptr = parse_header(sdu,&num_ce,&num_sdu,rx_ces,rx_lcids,rx_lengths,sdu_len); #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",Mod_id, - frame,eNB_index,num_ce,num_sdu); + LOG_D(MAC,"[UE %d] ue_send_sdu : Frame %d eNB_index %d : num_ce %d num_sdu %d\n",module_idP, + frame,eNB_index,num_ce,num_sdu); #endif #if defined(ENABLE_MAC_PAYLOAD_DEBUG) @@ -302,465 +300,470 @@ void ue_send_sdu(u8 Mod_id,u32 frame,u8 *sdu,u16 sdu_len,u8 eNB_index) { #endif for (i=0;i<num_ce;i++) { - // printf("ce %d : %d\n",i,rx_ces[i]); + // printf("ce %d : %d\n",i,rx_ces[i]); switch (rx_ces[i]) { case UE_CONT_RES: - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", - Mod_id,frame,payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4],payload_ptr[5]); - if (UE_mac_inst[Mod_id].RA_active == 1) { - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n"); - UE_mac_inst[Mod_id].RA_active=0; - // check if RA procedure has finished completely (no contention) - tx_sdu = &UE_mac_inst[Mod_id].CCCH_pdu.payload[3]; - //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) - // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) - for (i=0;i<6;i++) - if (tx_sdu[i] != payload_ptr[i]) { - LOG_E(MAC,"[UE %d][RAPROC] Contention detected, RA failed\n",Mod_id); - mac_xface->ra_failed(Mod_id,eNB_index); - UE_mac_inst[Mod_id].RA_contention_resolution_timer_active = 0; - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); - return; - } - LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n"); - UE_mac_inst[Mod_id].RA_contention_resolution_timer_active = 0; - mac_xface->ra_succeeded(Mod_id,eNB_index); - } - payload_ptr+=6; - break; + LOG_I(MAC,"[UE %d][RAPROC] Frame %d : received contention resolution msg: %x.%x.%x.%x.%x.%x, Terminating RA procedure\n", + module_idP,frame,payload_ptr[0],payload_ptr[1],payload_ptr[2],payload_ptr[3],payload_ptr[4],payload_ptr[5]); + if (UE_mac_inst[module_idP].RA_active == 1) { + LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing RA_active flag\n"); + UE_mac_inst[module_idP].RA_active=0; + // check if RA procedure has finished completely (no contention) + tx_sdu = &UE_mac_inst[module_idP].CCCH_pdu.payload[3]; + //Note: 3 assumes sizeof(SCH_SUBHEADER_SHORT) + PADDING CE, which is when UL-Grant has TBS >= 9 (64 bits) + // (other possibility is 1 for TBS=7 (SCH_SUBHEADER_FIXED), or 2 for TBS=8 (SCH_SUBHEADER_FIXED+PADDING or SCH_SUBHEADER_SHORT) + for (i=0;i<6;i++) + if (tx_sdu[i] != payload_ptr[i]) { + LOG_E(MAC,"[UE %d][RAPROC] Contention detected, RA failed\n",module_idP); + mac_xface->ra_failed(module_idP,eNB_index); + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); + return; + } + LOG_I(MAC,"[UE %d][RAPROC] Frame %d : Clearing contention resolution timer\n"); + UE_mac_inst[module_idP].RA_contention_resolution_timer_active = 0; + mac_xface->ra_succeeded(module_idP,eNB_index); + } + payload_ptr+=6; + break; case TIMING_ADV_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CE %d : UE Timing Advance : %d\n",i,payload_ptr[0]); + LOG_D(MAC,"[UE] CE %d : UE Timing Advance : %d\n",i,payload_ptr[0]); #endif - //mac_xface->process_timing_advance(Mod_id,payload_ptr[0]); - payload_ptr++; - break; + //mac_xface->process_timing_advance(module_idP,payload_ptr[0]); + payload_ptr++; + break; case DRX_CMD: #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CE %d : UE DRX :",i); + LOG_D(MAC,"[UE] CE %d : UE DRX :",i); #endif - payload_ptr++; - break; + payload_ptr++; + break; } } for (i=0;i<num_sdu;i++) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] SDU %d : LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]); + LOG_D(MAC,"[UE] SDU %d : LCID %d, length %d\n",i,rx_lcids[i],rx_lengths[i]); #endif - if (rx_lcids[i] == CCCH) { + if (rx_lcids[i] == CCCH) { + + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",module_idP,frame, eNB_index, rx_lengths[i]); - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-CCCH, RRC message (eNB %d, %d bytes)\n",Mod_id,frame, eNB_index, rx_lengths[i]); - #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; - for (j=0;j<rx_lengths[i];j++) - LOG_T(MAC,"%x.",(u8)payload_ptr[j]); - LOG_T(MAC,"\n"); + int j; + for (j=0;j<rx_lengths[i];j++) + LOG_T(MAC,"%x.",(u8)payload_ptr[j]); + LOG_T(MAC,"\n"); #endif - mac_rrc_data_ind(Mod_id, - frame, - CCCH, - (u8 *)payload_ptr,rx_lengths[i],0,eNB_index,0); + mac_rrc_data_ind(module_idP, + frame, + CCCH, + (u8 *)payload_ptr,rx_lengths[i],0,eNB_index,0); - } - else if (rx_lcids[i] == DCCH) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", Mod_id, frame, rx_lcids[i],eNB_index,rx_lengths[i]); - mac_rlc_data_ind(Mod_id+NB_eNB_INST, - frame, - 0, - RLC_MBMS_NO, - DCCH, - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - } - else if (rx_lcids[i] == DCCH1) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", Mod_id, frame, rx_lcids[i], eNB_index,rx_lengths[i]); - mac_rlc_data_ind(Mod_id+NB_eNB_INST, - frame, - 0, - RLC_MBMS_NO, - DCCH1, - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - } - else if (rx_lcids[i] == DTCH) { - LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", Mod_id, frame,rx_lcids[i], eNB_index,rx_lengths[i]); + } + else if (rx_lcids[i] == DCCH) { + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frame, rx_lcids[i],eNB_index,rx_lengths[i]); + mac_rlc_data_ind(eNB_index, + module_idP, + frame, + 0, + RLC_MBMS_NO, + DCCH, + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + } + else if (rx_lcids[i] == DCCH1) { + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DCCH%d, RRC message (eNB %d, %d bytes)\n", module_idP, frame, rx_lcids[i], eNB_index,rx_lengths[i]); + mac_rlc_data_ind(eNB_index, + module_idP, + frame, + 0, + RLC_MBMS_NO, + DCCH1, + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + } + else if (rx_lcids[i] == DTCH) { + LOG_D(MAC,"[UE %d] Frame %d : DLSCH -> DL-DTCH%d (eNB %d, %d bytes)\n", module_idP, frame,rx_lcids[i], eNB_index,rx_lengths[i]); #if defined(ENABLE_MAC_PAYLOAD_DEBUG) - int j; - for (j=0;j<rx_lengths[i];j++) - LOG_T(MAC,"%x.",(unsigned char)payload_ptr[j]); - LOG_T(MAC,"\n"); + int j; + for (j=0;j<rx_lengths[i];j++) + LOG_T(MAC,"%x.",(unsigned char)payload_ptr[j]); + LOG_T(MAC,"\n"); #endif - mac_rlc_data_ind(Mod_id+NB_eNB_INST, - frame, - 0, - RLC_MBMS_NO, - DTCH, - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - } - payload_ptr+= rx_lengths[i]; + mac_rlc_data_ind(eNB_index, + module_idP, + frame, + 0, + RLC_MBMS_NO, + DTCH, + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + } + payload_ptr+= rx_lengths[i]; } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_SDU, VCD_FUNCTION_OUT); } -void ue_decode_si(u8 Mod_id,u32 frame, u8 eNB_index, void *pdu,u16 len) { +void ue_decode_si(module_id_t module_idP,frame_t frameP, u8 eNB_index, void *pdu,u16 len) { vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_IN); - LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",Mod_id,frame,BCCH,len); + LOG_D(MAC,"[UE %d] Frame %d Sending SI to RRC (LCID Id %d,len %d)\n",module_idP,frame,BCCH,len); - mac_rrc_data_ind(Mod_id, - frame, - BCCH, - (u8 *)pdu, - len, - 0, - eNB_index, - 0); + mac_rrc_data_ind(module_idP, + frame, + BCCH, + (u8 *)pdu, + len, + 0, + eNB_index, + 0); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_SI, VCD_FUNCTION_OUT); } #ifdef Rel10 unsigned char *parse_mch_header(unsigned char *mac_header, - unsigned char *num_sdu, - unsigned char *rx_lcids, - unsigned short *rx_lengths, - unsigned short tb_length) { + unsigned char *num_sdu, + unsigned char *rx_lcids, + unsigned short *rx_lengths, + unsigned short tb_length) { unsigned char not_done=1, num_sdus=0, lcid, i; unsigned char *mac_header_ptr = mac_header; unsigned short length; while (not_done == 1) { - if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { - not_done = 0; - } - lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; - if (lcid < SHORT_PADDING) {// subheader for MSI, MCCH or MTCH - if (not_done == 0) { // last MAC SDU, length is implicit - mac_header_ptr++; - length = tb_length- (mac_header_ptr - mac_header); - for (i=0; i<num_sdus; i++) - length -= rx_lengths[i]; + if (((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E == 0) { + not_done = 0; } - else { // not the last MAC SDU - if ( ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) {// subheader has length of 3octets - // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; - length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); - mac_header_ptr += 3; - } - else {// subheader has length of 2octets - length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; - mac_header_ptr += 2; - } + lcid = ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID; + if (lcid < SHORT_PADDING) {// subheader for MSI, MCCH or MTCH + if (not_done == 0) { // last MAC SDU, length is implicit + mac_header_ptr++; + length = tb_length- (mac_header_ptr - mac_header); + for (i=0; i<num_sdus; i++) + length -= rx_lengths[i]; + } + else { // not the last MAC SDU + if ( ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F == 1) {// subheader has length of 3octets + // length = ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L; + length = ((((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB & 0x7f ) << 8 ) | (((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB & 0xff); + mac_header_ptr += 3; + } + else {// subheader has length of 2octets + length = ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L; + mac_header_ptr += 2; + } + } + rx_lcids[num_sdus] = lcid; + rx_lengths[num_sdus] = length; + num_sdus++; + } + else {// subheader for padding + // if (lcid == SHORT_PADDING) + mac_header_ptr++; } - rx_lcids[num_sdus] = lcid; - rx_lengths[num_sdus] = length; - num_sdus++; - } - else {// subheader for padding - // if (lcid == SHORT_PADDING) - mac_header_ptr++; - } } *num_sdu = num_sdus; return(mac_header_ptr); } // this function is for sending mch_sdu from phy to mac -void ue_send_mch_sdu(u8 Mod_id, u32 frame, u8 *sdu, u16 sdu_len, u8 eNB_index, u8 sync_area) { +void ue_send_mch_sdu(module_id_t module_idP, frame_t frameP, u8 *sdu, u16 sdu_len, u8 eNB_index, u8 sync_area) { unsigned char num_sdu, i, *payload_ptr; unsigned char rx_lcids[NB_RB_MAX]; unsigned short rx_lengths[NB_RB_MAX]; // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_IN); - LOG_D(MAC,"[UE %d] Frame %d : process the mch PDU for sync area %d \n",Mod_id,frame, sync_area); - LOG_D(MAC,"[UE %d] sdu: %x.%x\n", Mod_id,sdu[0], sdu[1]); - LOG_D(MAC,"[UE %d] parse_mch_header, demultiplex\n",Mod_id); + LOG_D(MAC,"[UE %d] Frame %d : process the mch PDU for sync area %d \n",module_idP,frame, sync_area); + LOG_D(MAC,"[UE %d] sdu: %x.%x\n", module_idP,sdu[0], sdu[1]); + LOG_D(MAC,"[UE %d] parse_mch_header, demultiplex\n",module_idP); payload_ptr = parse_mch_header(sdu, &num_sdu, rx_lcids, rx_lengths, sdu_len); - LOG_D(MAC,"[UE %d] parse_mch_header, found %d sdus\n",Mod_id,num_sdu); + LOG_D(MAC,"[UE %d] parse_mch_header, found %d sdus\n",module_idP,num_sdu); for (i=0; i<num_sdu; i++) { - if (rx_lcids[i] == MCH_SCHDL_INFO) { - if (UE_mac_inst[Mod_id].mcch_status==1) { - LOG_I(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n",Mod_id,frame, sync_area, eNB_index, rx_lengths[i]); - // ??store necessary scheduling info to ue_mac_inst in order to - // calculate exact position of interested service (for the complex case has >1 mtch) - // set msi_status to 1 - UE_mac_inst[Mod_id].msi_status = 1; + if (rx_lcids[i] == MCH_SCHDL_INFO) { + if (UE_mac_inst[module_idP].mcch_status==1) { + LOG_I(MAC,"[UE %d] Frame %d : MCH->MSI for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, sync_area, eNB_index, rx_lengths[i]); + // ??store necessary scheduling info to ue_mac_inst in order to + // calculate exact position of interested service (for the complex case has >1 mtch) + // set msi_status to 1 + UE_mac_inst[module_idP].msi_status = 1; + } } - } - else if (rx_lcids[i] == MCCH_LCHANID) { - LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",Mod_id,frame, i, sync_area, eNB_index, rx_lengths[i]); - mac_rrc_data_ind(Mod_id, - frame, - MCCH, - payload_ptr, rx_lengths[i], 0, eNB_index, sync_area); - } - else if (rx_lcids[i] == MTCH) { - if (UE_mac_inst[Mod_id].msi_status==1) { - LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",Mod_id,frame, sync_area, eNB_index, rx_lengths[i]); - - mac_rlc_data_ind(Mod_id+NB_eNB_INST, // because rlc[module_idP] (to differential between eNB and UE) - frame, - 0, - RLC_MBMS_YES, - MTCH + (maxDRB + 3), - (char *)payload_ptr, - rx_lengths[i], - 1, - NULL); - + else if (rx_lcids[i] == MCCH_LCHANID) { + LOG_I(MAC,"[UE %d] Frame %d : SDU %d MCH->MCCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, i, sync_area, eNB_index, rx_lengths[i]); + mac_rrc_data_ind(module_idP, + frame, + MCCH, + payload_ptr, rx_lengths[i], 0, eNB_index, sync_area); } - } else { - LOG_W(MAC,"[UE %d] Frame %d : unknown sdu %d mcch status %d eNB %d \n",Mod_id,frame,rx_lengths[i], - UE_mac_inst[Mod_id].mcch_status, eNB_index); - } - - payload_ptr += rx_lengths[i]; + else if (rx_lcids[i] == MTCH) { + if (UE_mac_inst[module_idP].msi_status==1) { + LOG_I(MAC,"[UE %d] Frame %d : MCH->MTCH for sync area %d (eNB %d, %d bytes)\n",module_idP,frame, sync_area, eNB_index, rx_lengths[i]); + + mac_rlc_data_ind( + 0 + module_idP, + frame, + 0, + RLC_MBMS_YES, + MTCH + (maxDRB + 3), + (char *)payload_ptr, + rx_lengths[i], + 1, + NULL); + + } + } else { + LOG_W(MAC,"[UE %d] Frame %d : unknown sdu %d mcch status %d eNB %d \n",module_idP,frame,rx_lengths[i], + UE_mac_inst[module_idP].mcch_status, eNB_index); + } + + payload_ptr += rx_lengths[i]; } // vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SEND_MCH_SDU, VCD_FUNCTION_OUT); } -s8 ue_get_mbsfn_sf_alloction (unsigned char Mod_id, u8 mbsfn_sync_area, unsigned char eNB_index){ - // currently there is one-to-one mapping between sf allocation pattern and sync area +s8 ue_get_mbsfn_sf_alloction (module_id_t module_idP, u8 mbsfn_sync_area, unsigned char eNB_index){ + // currently there is one-to-one mapping between sf allocation pattern and sync area if (mbsfn_sync_area > MAX_MBSFN_AREA){ - LOG_W(MAC,"[UE %d] MBSFN synchronization area %d out of range for eNB %d\n ", Mod_id, mbsfn_sync_area, eNB_index); - return -1; + LOG_W(MAC,"[UE %d] MBSFN synchronization area %d out of range for eNB %d\n ", module_idP, mbsfn_sync_area, eNB_index); + return -1; } - else if (UE_mac_inst[Mod_id].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) + else if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[mbsfn_sync_area] != NULL) return mbsfn_sync_area; else { - LOG_W(MAC,"[UE %d] MBSFN Subframe Config pattern %d not found \n ", Mod_id, mbsfn_sync_area); - return -1; + LOG_W(MAC,"[UE %d] MBSFN Subframe Config pattern %d not found \n ", module_idP, mbsfn_sync_area); + return -1; } } -int ue_query_mch(uint8_t Mod_id, uint32_t frame, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) { +int ue_query_mch(module_id_t module_idP, uint32_t frame, uint32_t subframe, uint8_t eNB_index,uint8_t *sync_area, uint8_t *mcch_active) { int i=0, j=0, ii=0, msi_pos=0, mcch_mcs = - 1; int mcch_flag=0, mtch_flag=0, msi_flag=0; - int mbsfn_period = 0;// 1<<(UE_mac_inst[Mod_id].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - int mcch_period = 0;// 32<<(UE_mac_inst[Mod_id].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + int mbsfn_period = 0;// 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + int mcch_period = 0;// 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); int mch_scheduling_period = -1; - if (UE_mac_inst[Mod_id].pmch_Config[0]) - mch_scheduling_period = 8<<(UE_mac_inst[Mod_id].pmch_Config[0]->mch_SchedulingPeriod_r9); + if (UE_mac_inst[module_idP].pmch_Config[0]) + mch_scheduling_period = 8<<(UE_mac_inst[module_idP].pmch_Config[0]->mch_SchedulingPeriod_r9); for (i=0; - i< UE_mac_inst[Mod_id].num_active_mbsfn_area; - i++ ){ - // assume, that there is always a mapping - if ((j=ue_get_mbsfn_sf_alloction(Mod_id,i,eNB_index)) == -1) - return -1; // continue; - ii=0; - msi_pos=0; - mbsfn_period = 1<<(UE_mac_inst[Mod_id].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); - mcch_period = 32<<(UE_mac_inst[Mod_id].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); - - LOG_D(MAC,"[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%d))\n", - Mod_id,frame, subframe,i,UE_mac_inst[Mod_id].num_active_mbsfn_area, - j,UE_mac_inst[Mod_id].num_sf_allocation_pattern,mbsfn_period,mcch_period, - mch_scheduling_period,UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset); - - // get the real MCS value - switch (UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { - case 0: - mcch_mcs = 2; - break; - case 1: - mcch_mcs = 7; - break; - case 2: - mcch_mcs = 13; - break; - case 3: - mcch_mcs = 19; - break; - } - - if (frame % mbsfn_period == UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frame - if (UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frame format - - if (UE_mac_inst[Mod_id].pmch_Config[0]) { - // Find the first subframe in this MCH to transmit MSI - if (frame % mch_scheduling_period == UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { - while (ii == 0) { - ii = UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); - msi_pos++; - } - } - } - - // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 - switch (subframe) { - case 1: - if (mac_xface->lte_frame_parms->frame_type == FDD) { - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { - if (msi_pos == 1) - msi_flag = 1; - if ( (frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 2: - if (mac_xface->lte_frame_parms->frame_type == FDD){ - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { - if (msi_pos == 2) - msi_flag = 1; - if ( (frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 3: - if (mac_xface->lte_frame_parms->frame_type == TDD){// TDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { - if (msi_pos == 1) - msi_flag = 1; - if ( (frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else {// FDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { - if (msi_pos == 3) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 4: - if (mac_xface->lte_frame_parms->frame_type == TDD){ - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { - if (msi_pos == 2) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 6: - if (mac_xface->lte_frame_parms->frame_type == FDD){ - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { - if (msi_pos == 4) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 7: - if (mac_xface->lte_frame_parms->frame_type == TDD){ // TDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { - if (msi_pos == 3) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else {// FDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { - if (msi_pos == 5) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 8: - if (mac_xface->lte_frame_parms->frame_type == TDD){ //TDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { - if (msi_pos == 4) - msi_flag = 1; - if ( (frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - else{ // FDD - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { - if (msi_pos == 6) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - - case 9: - if (mac_xface->lte_frame_parms->frame_type == TDD){ - if ((UE_mac_inst[Mod_id].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { - if (msi_pos == 5) - msi_flag = 1; - if ((frame % mcch_period == UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && - ((UE_mac_inst[Mod_id].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) - mcch_flag = 1; - mtch_flag = 1; - } - } - break; - }// end switch - // sf allocation is non-overlapping - if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)){ - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", - Mod_id, frame, subframe,i,j,msi_flag,mcch_flag,mtch_flag); - - *sync_area=i; - break; - } + i< UE_mac_inst[module_idP].num_active_mbsfn_area; + i++ ){ + // assume, that there is always a mapping + if ((j=ue_get_mbsfn_sf_alloction(module_idP,i,eNB_index)) == -1) + return -1; // continue; + ii=0; + msi_pos=0; + mbsfn_period = 1<<(UE_mac_inst[module_idP].mbsfn_SubframeConfig[0]->radioframeAllocationPeriod); + mcch_period = 32<<(UE_mac_inst[module_idP].mbsfn_AreaInfo[0]->mcch_Config_r9.mcch_RepetitionPeriod_r9); + + LOG_D(MAC,"[UE %d] Frame %d subframe %d: Checking MBSFN Sync Area %d/%d with SF allocation %d/%d for MCCH and MTCH (mbsfn period %d, mcch period %d,mac sched period (%d,%d))\n", + module_idP,frame, subframe,i,UE_mac_inst[module_idP].num_active_mbsfn_area, + j,UE_mac_inst[module_idP].num_sf_allocation_pattern,mbsfn_period,mcch_period, + mch_scheduling_period,UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset); + + // get the real MCS value + switch (UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.signallingMCS_r9) { + case 0: + mcch_mcs = 2; + break; + case 1: + mcch_mcs = 7; + break; + case 2: + mcch_mcs = 13; + break; + case 3: + mcch_mcs = 19; + break; } - else {// four-frame format + + if (frame % mbsfn_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset){ // MBSFN frame + if (UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.present == MBSFN_SubframeConfig__subframeAllocation_PR_oneFrame){// one-frame format + + if (UE_mac_inst[module_idP].pmch_Config[0]) { + // Find the first subframe in this MCH to transmit MSI + if (frame % mch_scheduling_period == UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->radioframeAllocationOffset ) { + while (ii == 0) { + ii = UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & (0x80>>msi_pos); + msi_pos++; + } + } + } + + // Check if the subframe is for MSI, MCCH or MTCHs and Set the correspoding flag to 1 + switch (subframe) { + case 1: + if (mac_xface->lte_frame_parms->frame_type == FDD) { + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) { + if (msi_pos == 1) + msi_flag = 1; + if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF1) == MBSFN_FDD_SF1) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 2: + if (mac_xface->lte_frame_parms->frame_type == FDD){ + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) { + if (msi_pos == 2) + msi_flag = 1; + if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF2) == MBSFN_FDD_SF2) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 3: + if (mac_xface->lte_frame_parms->frame_type == TDD){// TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) { + if (msi_pos == 1) + msi_flag = 1; + if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF3) == MBSFN_TDD_SF3) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else {// FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) { + if (msi_pos == 3) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF3) == MBSFN_FDD_SF3) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 4: + if (mac_xface->lte_frame_parms->frame_type == TDD){ + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) { + if (msi_pos == 2) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF4) == MBSFN_TDD_SF4) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 6: + if (mac_xface->lte_frame_parms->frame_type == FDD){ + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) { + if (msi_pos == 4) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF6) == MBSFN_FDD_SF6) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 7: + if (mac_xface->lte_frame_parms->frame_type == TDD){ // TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) { + if (msi_pos == 3) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF7) == MBSFN_TDD_SF7) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else {// FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) { + if (msi_pos == 5) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF7) == MBSFN_FDD_SF7) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 8: + if (mac_xface->lte_frame_parms->frame_type == TDD){ //TDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) { + if (msi_pos == 4) + msi_flag = 1; + if ( (frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF8) == MBSFN_TDD_SF8) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + else{ // FDD + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) { + if (msi_pos == 6) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_FDD_SF8) == MBSFN_FDD_SF8) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + + case 9: + if (mac_xface->lte_frame_parms->frame_type == TDD){ + if ((UE_mac_inst[module_idP].mbsfn_SubframeConfig[j]->subframeAllocation.choice.oneFrame.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) { + if (msi_pos == 5) + msi_flag = 1; + if ((frame % mcch_period == UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.mcch_Offset_r9) && + ((UE_mac_inst[module_idP].mbsfn_AreaInfo[i]->mcch_Config_r9.sf_AllocInfo_r9.buf[0] & MBSFN_TDD_SF9) == MBSFN_TDD_SF9) ) + mcch_flag = 1; + mtch_flag = 1; + } + } + break; + }// end switch + // sf allocation is non-overlapping + if ((msi_flag==1) || (mcch_flag==1) || (mtch_flag==1)){ + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: sync area %d SF alloc %d: msi flag %d, mcch flag %d, mtch flag %d\n", + module_idP, frame, subframe,i,j,msi_flag,mcch_flag,mtch_flag); + + *sync_area=i; + break; + } + } + else {// four-frame format + } } - } } // end of for - + if ( (mcch_flag==1))// || (msi_flag==1)) *mcch_active=1; - if ( (mcch_flag==1) || ((msi_flag==1) && (UE_mac_inst[Mod_id].mcch_status==1)) ){ - return mcch_mcs; - } else if ((mtch_flag==1) && (UE_mac_inst[Mod_id].msi_status==1)) - return UE_mac_inst[Mod_id].pmch_Config[0]->dataMCS_r9; + if ( (mcch_flag==1) || ((msi_flag==1) && (UE_mac_inst[module_idP].mcch_status==1)) ){ + return mcch_mcs; + } else if ((mtch_flag==1) && (UE_mac_inst[module_idP].msi_status==1)) + return UE_mac_inst[module_idP].pmch_Config[0]->dataMCS_r9; else return -1; } @@ -768,16 +771,16 @@ int ue_query_mch(uint8_t Mod_id, uint32_t frame, uint32_t subframe, uint8_t eNB_ #endif unsigned char generate_ulsch_header(u8 *mac_header, - u8 num_sdus, - u8 short_padding, - u16 *sdu_lengths, - u8 *sdu_lcids, - POWER_HEADROOM_CMD *power_headroom, - u16 *crnti, - BSR_SHORT *truncated_bsr, - BSR_SHORT *short_bsr, - BSR_LONG *long_bsr, - unsigned short post_padding) { + u8 num_sdus, + u8 short_padding, + u16 *sdu_lengths, + u8 *sdu_lcids, + POWER_HEADROOM_CMD *power_headroom, + u16 *crnti, + BSR_SHORT *truncated_bsr, + BSR_SHORT *short_bsr, + BSR_LONG *long_bsr, + unsigned short post_padding) { SCH_SUBHEADER_FIXED *mac_header_ptr = (SCH_SUBHEADER_FIXED *)mac_header; unsigned char first_element=0,last_size=0,i; @@ -792,212 +795,212 @@ unsigned char generate_ulsch_header(u8 *mac_header, ce_ptr = &mac_header_control_elements[0]; if ((short_padding == 1) || (short_padding == 2)) { - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - first_element=1; - last_size=1; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + first_element=1; + last_size=1; } if (short_padding == 2) { - mac_header_ptr->E = 1; - mac_header_ptr++; - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - last_size=1; + mac_header_ptr->E = 1; + mac_header_ptr++; + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + last_size=1; } if (power_headroom) { - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } - else { - first_element=1; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = POWER_HEADROOM; - last_size=1; - *((POWER_HEADROOM_CMD *)ce_ptr)=(*power_headroom); - ce_ptr+=sizeof(POWER_HEADROOM_CMD); - LOG_D(MAC, "phr header size %d\n",sizeof(POWER_HEADROOM_CMD)); + if (first_element>0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } + else { + first_element=1; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = POWER_HEADROOM; + last_size=1; + *((POWER_HEADROOM_CMD *)ce_ptr)=(*power_headroom); + ce_ptr+=sizeof(POWER_HEADROOM_CMD); + LOG_D(MAC, "phr header size %d\n",sizeof(POWER_HEADROOM_CMD)); } if (crnti) { #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] CRNTI : %x (first_element %d)\n",*crnti,first_element); + LOG_D(MAC,"[UE] CRNTI : %x (first_element %d)\n",*crnti,first_element); #endif - if (first_element>0) { - mac_header_ptr->E = 1; - mac_header_ptr++; - } - else { - first_element=1; - } - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = CRNTI; - last_size=1; - *((u16 *)ce_ptr)=(*crnti); - ce_ptr+=sizeof(u16); - // printf("offset %d\n",ce_ptr-mac_header_control_elements); + if (first_element>0) { + mac_header_ptr->E = 1; + mac_header_ptr++; + } + else { + first_element=1; + } + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = CRNTI; + last_size=1; + *((u16 *)ce_ptr)=(*crnti); + ce_ptr+=sizeof(u16); + // printf("offset %d\n",ce_ptr-mac_header_control_elements); } if (truncated_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* + if (first_element>0) { + mac_header_ptr->E = 1; + /* printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } - else { - first_element=1; - } + */ + mac_header_ptr++; + } + else { + first_element=1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler Truncated BSR Header\n"); + LOG_D(MAC,"[UE] Scheduler Truncated BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = TRUNCATED_BSR; - last_size=1; - *((BSR_TRUNCATED *)ce_ptr)=(*truncated_bsr); - ce_ptr+=sizeof(BSR_TRUNCATED); - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = TRUNCATED_BSR; + last_size=1; + *((BSR_TRUNCATED *)ce_ptr)=(*truncated_bsr); + ce_ptr+=sizeof(BSR_TRUNCATED); + + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } else if (short_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* + if (first_element>0) { + mac_header_ptr->E = 1; + /* printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } - else { - first_element=1; - } + */ + mac_header_ptr++; + } + else { + first_element=1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler SHORT BSR Header\n"); + LOG_D(MAC,"[UE] Scheduler SHORT BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_BSR; - last_size=1; - *((BSR_SHORT *)ce_ptr)=(*short_bsr); - ce_ptr+=sizeof(BSR_SHORT); - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_BSR; + last_size=1; + *((BSR_SHORT *)ce_ptr)=(*short_bsr); + ce_ptr+=sizeof(BSR_SHORT); + + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } else if (long_bsr) { - if (first_element>0) { - mac_header_ptr->E = 1; - /* + if (first_element>0) { + mac_header_ptr->E = 1; + /* printf("last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); - */ - mac_header_ptr++; - } - else { - first_element=1; - } + */ + mac_header_ptr++; + } + else { + first_element=1; + } #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] Scheduler Long BSR Header\n"); + LOG_D(MAC,"[UE] Scheduler Long BSR Header\n"); #endif - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = LONG_BSR; - last_size=1; - - *(ce_ptr) = (long_bsr->Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); - *(ce_ptr + 1) = ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->Buffer_size2 & 0x3C) >> 2); - *(ce_ptr + 2) = ((long_bsr->Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); - /* Padding */ - *(ce_ptr + 3) = 0; - ce_ptr += BSR_LONG_SIZE; - - // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = LONG_BSR; + last_size=1; + + *(ce_ptr) = (long_bsr->Buffer_size0 << 2) | ((long_bsr->Buffer_size1 & 0x30) >> 4); + *(ce_ptr + 1) = ((long_bsr->Buffer_size1 & 0x0F) << 4) | ((long_bsr->Buffer_size2 & 0x3C) >> 2); + *(ce_ptr + 2) = ((long_bsr->Buffer_size2 & 0x03) << 2) | (long_bsr->Buffer_size3 & 0x3F); + /* Padding */ + *(ce_ptr + 3) = 0; + ce_ptr += BSR_LONG_SIZE; + + // printf("(cont_res) : offset %d\n",ce_ptr-mac_header_control_elements); } // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); for (i=0;i<num_sdus;i++) { #ifdef DEBUG_HEADER_PARSING - LOG_T(MAC,"[UE] sdu subheader %d (lcid %d, %d bytes)\n",i,sdu_lcids[i],sdu_lengths[i]); + LOG_T(MAC,"[UE] sdu subheader %d (lcid %d, %d bytes)\n",i,sdu_lcids[i],sdu_lengths[i]); #endif - if ((first_element>0)) { - mac_header_ptr->E = 1; + if ((first_element>0)) { + mac_header_ptr->E = 1; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, - ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); + LOG_D(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d)\n",*(unsigned char*)mac_header_ptr, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->R, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->E, + ((SCH_SUBHEADER_FIXED *)mac_header_ptr)->LCID); #endif - mac_header_ptr+=last_size; - // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); - } - else { - first_element=1; + mac_header_ptr+=last_size; + // printf("last_size %d,mac_header_ptr %p\n",last_size,mac_header_ptr); + } + else { + first_element=1; - } - if (sdu_lengths[i] < 128) { - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; // 3 - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; - last_size=2; + } + if (sdu_lengths[i] < 128) { + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R = 0; // 3 + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F = 0; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L = (unsigned char)sdu_lengths[i]; + last_size=2; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] short sdu\n"); - LOG_T(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", - ((u16*)mac_header_ptr)[0], - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F, - ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L); + LOG_D(MAC,"[UE] short sdu\n"); + LOG_T(MAC,"[UE] last subheader : %x (R%d,E%d,LCID%d,F%d,L%d)\n", + ((u16*)mac_header_ptr)[0], + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->R, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->E, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->LCID, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->F, + ((SCH_SUBHEADER_SHORT *)mac_header_ptr)->L); #endif - } - else { - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; - ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; - last_size=3; + } + else { + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->R = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->E = 0; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->F = 1; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->LCID = sdu_lcids[i]; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_MSB = ((unsigned short) sdu_lengths[i]>>8)&0x7f; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->L_LSB = (unsigned short) sdu_lengths[i]&0xff; + ((SCH_SUBHEADER_LONG *)mac_header_ptr)->padding = 0x00; + last_size=3; #ifdef DEBUG_HEADER_PARSING - LOG_D(MAC,"[UE] long sdu\n"); + LOG_D(MAC,"[UE] long sdu\n"); #endif - } + } } if (post_padding>0) {// we have lots of padding at the end of the packet - mac_header_ptr->E = 1; - mac_header_ptr+=last_size; - // add a padding element - mac_header_ptr->R = 0; - mac_header_ptr->E = 0; - mac_header_ptr->LCID = SHORT_PADDING; - mac_header_ptr++; + mac_header_ptr->E = 1; + mac_header_ptr+=last_size; + // add a padding element + mac_header_ptr->R = 0; + mac_header_ptr->E = 0; + mac_header_ptr->LCID = SHORT_PADDING; + mac_header_ptr++; } else { // no end of packet padding - // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) - mac_header_ptr++; - //mac_header_ptr=last_size; // FIXME: should be ++ + // last SDU subhead is of fixed type (sdu length implicitly to be computed at UE) + mac_header_ptr++; + //mac_header_ptr=last_size; // FIXME: should be ++ } - + if ((ce_ptr-mac_header_control_elements) > 0) { - memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); - mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); + memcpy((void*)mac_header_ptr,mac_header_control_elements,ce_ptr-mac_header_control_elements); + mac_header_ptr+=(unsigned char)(ce_ptr-mac_header_control_elements); } #ifdef DEBUG_HEADER_PARSING LOG_T(MAC," [UE %d] header : ", crnti); @@ -1009,7 +1012,7 @@ unsigned char generate_ulsch_header(u8 *mac_header, } -void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen, u8 *access_mode) { +void ue_get_sdu(module_id_t module_idP,frame_t frame,sub_frame_t subframe, u8 eNB_index,u8 *ulsch_buffer,u16 buflen, u8 *access_mode) { mac_rlc_status_resp_t rlc_status; u8 dcch_header_len=0,dcch1_header_len=0,dtch_header_len=0; @@ -1036,16 +1039,16 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u #ifdef CBA if (*access_mode==CBA_ACCESS){ - LOG_D(MAC,"[UE %d] frame %d subframe %d try CBA transmission\n", - Mod_id, frame, subframe); - //if (UE_mac_inst[Mod_id].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) - if (use_cba_access(Mod_id,frame,subframe,eNB_index)==0){ - *access_mode=POSTPONED_ACCESS; - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); - return; - } - LOG_D(MAC,"[UE %d] frame %d subframe %d CBA transmission oppurtunity, tbs %d\n", - Mod_id, frame, subframe,buflen); + LOG_D(MAC,"[UE %d] frame %d subframe %d try CBA transmission\n", + module_idP, frame, subframe); + //if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_EMPTY) + if (use_cba_access(module_idP,frame,subframe,eNB_index)==0){ + *access_mode=POSTPONED_ACCESS; + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + return; + } + LOG_D(MAC,"[UE %d] frame %d subframe %d CBA transmission oppurtunity, tbs %d\n", + module_idP, frame, subframe,buflen); } #endif dcch_header_len=2;//sizeof(SCH_SUBHEADER_SHORT); @@ -1054,151 +1057,151 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u dtch_header_len=(buflen > 128 ) ? 3 : 2 ; //sizeof(SCH_SUBHEADER_LONG)-1 : sizeof(SCH_SUBHEADER_SHORT); bsr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); phr_header_len = 1;//sizeof(SCH_SUBHEADER_FIXED); - phr_ce_len = (UE_mac_inst[Mod_id].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; + phr_ce_len = (UE_mac_inst[module_idP].PHR_reporting_active == 1) ? 1 /* sizeof(POWER_HEADROOM_CMD)*/: 0; if (phr_ce_len > 0){ - phr_len = phr_ce_len + phr_header_len; - LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", - Mod_id, phr_len, phr_ce_len, phr_header_len, buflen); + phr_len = phr_ce_len + phr_header_len; + LOG_D(MAC,"[UE %d] header size info: PHR len %d (ce%d,hdr%d) buff_len %d\n", + module_idP, phr_len, phr_ce_len, phr_header_len, buflen); }else phr_len=0; - - bsr_ce_len = get_bsr_len (Mod_id, buflen-phr_len); + + bsr_ce_len = get_bsr_len (module_idP, buflen-phr_len); if (bsr_ce_len > 0 ){ - bsr_len = bsr_ce_len + bsr_header_len; - LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", - Mod_id, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); + bsr_len = bsr_ce_len + bsr_header_len; + LOG_D(MAC,"[UE %d] header size info: dcch %d, dcch1 %d, dtch %d, bsr (ce%d,hdr%d) buff_len %d\n", + module_idP, dcch_header_len,dcch1_header_len,dtch_header_len, bsr_ce_len, bsr_header_len, buflen); } else bsr_len = 0; - - // check for UL bandwidth requests and add SR control element + + // check for UL bandwidth requests and add SR control element // Check for DCCH first sdu_lengths[0]=0; - - if (UE_mac_inst[Mod_id].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) { - - rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO, - DCCH, - (buflen-dcch_header_len-bsr_len-phr_len)); - LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to " + + if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH] == LCID_NOT_EMPTY) { + + rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO, + DCCH, + (buflen-dcch_header_len-bsr_len-phr_len)); + LOG_D(MAC, "[UE %d] Frame %d : UL-DCCH -> ULSCH, RRC message has %d bytes to " "send (Transport Block size %d, mac header len %d)\n", - Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch_header_len); - - sdu_lengths[0] += mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO, - DCCH, - (char *)&ulsch_buff[sdu_lengths[0]]); - - sdu_length_total += sdu_lengths[0]; - sdu_lcids[0] = DCCH; - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",Mod_id,sdu_lengths[0]); - num_sdus = 1; - update_bsr(Mod_id, frame, DCCH, UE_mac_inst[Mod_id].scheduling_info.LCGID[DCCH]); - //header_len +=2; + module_idP,frame, rlc_status.bytes_in_buffer,buflen,dcch_header_len); + + sdu_lengths[0] += mac_rlc_data_req(0, module_idP,frame,0, RLC_MBMS_NO, + DCCH, + (char *)&ulsch_buff[sdu_lengths[0]]); + + sdu_length_total += sdu_lengths[0]; + sdu_lcids[0] = DCCH; + LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH\n",module_idP,sdu_lengths[0]); + num_sdus = 1; + update_bsr(module_idP, frame, DCCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DCCH]); + //header_len +=2; } else { - dcch_header_len=0; - num_sdus = 0; + dcch_header_len=0; + num_sdus = 0; } // DCCH1 - if (UE_mac_inst[Mod_id].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) { + if (UE_mac_inst[module_idP].scheduling_info.LCID_status[DCCH1] == LCID_NOT_EMPTY) { - rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO, - DCCH1, - (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); + rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO, + DCCH1, + (buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-sdu_length_total)); - LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to" + LOG_D(MAC,"[UE %d] Frame %d : UL-DCCH1 -> ULSCH, RRC message has %d bytes to" " send (Transport Block size %d, mac header len %d)\n", - Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dcch1_header_len); - - sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO, - DCCH1, - (char *)&ulsch_buff[sdu_lengths[0]]); - sdu_length_total += sdu_lengths[num_sdus]; - sdu_lcids[num_sdus] = DCCH1; - LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",Mod_id,sdu_lengths[num_sdus]); - num_sdus++; - //update_bsr(Mod_id, frame, DCCH1); - //dcch_header_len +=2; // include dcch1 + module_idP,frame, rlc_status.bytes_in_buffer,buflen,dcch1_header_len); + + sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frame,0,RLC_MBMS_NO, + DCCH1, + (char *)&ulsch_buff[sdu_lengths[0]]); + sdu_length_total += sdu_lengths[num_sdus]; + sdu_lcids[num_sdus] = DCCH1; + LOG_D(MAC,"[UE %d] TX Got %d bytes for DCCH1\n",module_idP,sdu_lengths[num_sdus]); + num_sdus++; + //update_bsr(module_idP, frame, DCCH1); + //dcch_header_len +=2; // include dcch1 } else { - dcch1_header_len =0; + dcch1_header_len =0; } - if ((UE_mac_inst[Mod_id].scheduling_info.LCID_status[DTCH] == LCID_NOT_EMPTY) && + if ((UE_mac_inst[module_idP].scheduling_info.LCID_status[DTCH] == LCID_NOT_EMPTY) && ((bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len+sdu_length_total) <= buflen)){ - // optimize the dtch header lenght - //if ((UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH] > 128) && - /* if (((UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH] >= 128) && - ((UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH]+bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len) > buflen)&& + // optimize the dtch header lenght + //if ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] > 128) && + /* if (((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH] >= 128) && + ((UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]+bsr_len+phr_len+dcch_header_len+dcch1_header_len+dtch_header_len) > buflen)&& buflen >=128 )) dtch_header_len = 3;//sizeof(SCH_SUBHEADER_LONG); else dtch_header_len = 2;//sizeof(SCH_SUBHEADER_SHORT); - */ - rlc_status = mac_rlc_status_ind(Mod_id+NB_eNB_INST,frame,0,RLC_MBMS_NO, - DTCH, - buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); - - LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[DTCH] %d)\n", - Mod_id,frame, rlc_status.bytes_in_buffer,buflen,dtch_header_len, - UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[DTCH]); - - sdu_lengths[num_sdus] = mac_rlc_data_req(Mod_id+NB_eNB_INST,frame,RLC_MBMS_NO, - DTCH, - (char *)&ulsch_buff[sdu_length_total]); - - //adjust dtch header - dtch_header_len = (sdu_lengths[num_sdus] >= 128) ? 3 : 2; - LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",Mod_id,sdu_lengths[num_sdus]); - sdu_lcids[num_sdus] = DTCH; - sdu_length_total += sdu_lengths[num_sdus]; - num_sdus++; - UE_mac_inst[Mod_id].ul_active = update_bsr(Mod_id, frame, DTCH, UE_mac_inst[Mod_id].scheduling_info.LCGID[DTCH]); + */ + rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO, + DTCH, + buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total); + + LOG_D(MAC,"[UE %d] Frame %d : UL-DTCH -> ULSCH, %d bytes to send (Transport Block size %d, mac header len %d, BSR byte[DTCH] %d)\n", + module_idP,frame, rlc_status.bytes_in_buffer,buflen,dtch_header_len, + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[DTCH]); + + sdu_lengths[num_sdus] = mac_rlc_data_req(0, module_idP,frame, 0, RLC_MBMS_NO, + DTCH, + (char *)&ulsch_buff[sdu_length_total]); + + //adjust dtch header + dtch_header_len = (sdu_lengths[num_sdus] >= 128) ? 3 : 2; + LOG_D(MAC,"[UE %d] TX Got %d bytes for DTCH\n",module_idP,sdu_lengths[num_sdus]); + sdu_lcids[num_sdus] = DTCH; + sdu_length_total += sdu_lengths[num_sdus]; + num_sdus++; + UE_mac_inst[module_idP].ul_active = update_bsr(module_idP, frame, DTCH, UE_mac_inst[module_idP].scheduling_info.LCGID[DTCH]); } else { // no rlc pdu : generate the dummy header - dtch_header_len = 0; + dtch_header_len = 0; } - - lcgid= get_bsr_lcgid(Mod_id); + + lcgid= get_bsr_lcgid(module_idP); if (lcgid < 0 ) { - bsr_s = NULL; - bsr_l = NULL ; + bsr_s = NULL; + bsr_l = NULL ; } else if ((lcgid ==MAX_NUM_LCGID) && (bsr_ce_len == sizeof(BSR_LONG))) { - bsr_s = NULL; - bsr_l->Buffer_size0 = UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID0]; - bsr_l->Buffer_size1 = UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1]; - bsr_l->Buffer_size2 = UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2]; - bsr_l->Buffer_size3 = UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3]; - LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", Mod_id,frame, - UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID0], - UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1], - UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2], - UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3]); + bsr_s = NULL; + bsr_l->Buffer_size0 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0]; + bsr_l->Buffer_size1 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]; + bsr_l->Buffer_size2 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]; + bsr_l->Buffer_size3 = UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]; + LOG_D(MAC, "[UE %d] Frame %d report long BSR (level LCGID0 %d,level LCGID1 %d,level LCGID2 %d,level LCGID3 %d)\n", module_idP,frame, + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID0], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2], + UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]); } else if (bsr_ce_len == sizeof(BSR_SHORT)) { - bsr_l = NULL; - bsr_s->LCGID = lcgid; - bsr_s->Buffer_size = UE_mac_inst[Mod_id].scheduling_info.BSR[lcgid]; - LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", - Mod_id, frame, UE_mac_inst[Mod_id].scheduling_info.BSR[lcgid],lcgid); + bsr_l = NULL; + bsr_s->LCGID = lcgid; + bsr_s->Buffer_size = UE_mac_inst[module_idP].scheduling_info.BSR[lcgid]; + LOG_D(MAC,"[UE %d] Frame %d report SHORT BSR with level %d for LCGID %d\n", + module_idP, frame, UE_mac_inst[module_idP].scheduling_info.BSR[lcgid],lcgid); } else { bsr_s = NULL; bsr_l = NULL; } - // build PHR and update the timers + // build PHR and update the timers if (phr_ce_len == sizeof(POWER_HEADROOM_CMD)){ - phr_p->PH = get_phr_mapping(Mod_id,eNB_index); - phr_p->R = 0; - LOG_D(MAC,"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", - Mod_id,frame, mac_xface->get_PHR(Mod_id,eNB_index), phr_p->PH,POWER_HEADROOM); - update_phr(Mod_id); + phr_p->PH = get_phr_mapping(module_idP,eNB_index); + phr_p->R = 0; + LOG_D(MAC,"[UE %d] Frame %d report PHR with mapping (%d->%d) for LCID %d\n", + module_idP,frame, mac_xface->get_PHR(module_idP,eNB_index), phr_p->PH,POWER_HEADROOM); + update_phr(module_idP); }else phr_p=NULL; - LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", Mod_id,frame,bsr_s, bsr_l, phr_p); + LOG_T(MAC,"[UE %d] Frame %d: bsr s %p bsr_l %p, phr_p %p\n", module_idP,frame,bsr_s, bsr_l, phr_p); // adjust the header length dcch_header_len_tmp = dcch_header_len; @@ -1207,42 +1210,41 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u dcch_header_len = (dcch_header_len>0)? 1: dcch_header_len; else dtch_header_len= (dtch_header_len >0)? 1: dtch_header_len; // for short and long, cut the length+F fields - - if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { - *access_mode=CANCELED_ACCESS; - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); - return; - } else if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { - short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; - post_padding = 0; + + if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) <= 2) { + short_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total; + post_padding = 0; } else { - short_padding = 0; - if (dtch_header_len==0) - dcch_header_len = dcch_header_len_tmp; - else - dtch_header_len= dtch_header_len_tmp; - - post_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total -1 ; + if ((buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total) == buflen) { + *access_mode=CANCELED_ACCESS; + } + short_padding = 0; + if (dtch_header_len==0) + dcch_header_len = dcch_header_len_tmp; + else + dtch_header_len= dtch_header_len_tmp; + + post_padding = buflen-bsr_len-phr_len-dcch_header_len-dcch1_header_len-dtch_header_len-sdu_length_total -1 ; } - + // Generate header // if (num_sdus>0) { - + payload_offset = generate_ulsch_header(ulsch_buffer, // mac header - num_sdus, // num sdus - short_padding, // short pading - sdu_lengths, // sdu length - sdu_lcids, // sdu lcid - phr_p, // power headroom - NULL, // crnti - NULL, // truncated bsr - bsr_s, // short bsr - bsr_l, - post_padding); // long_bsr + num_sdus, // num sdus + short_padding, // short pading + sdu_lengths, // sdu length + sdu_lcids, // sdu lcid + phr_p, // power headroom + NULL, // crnti + NULL, // truncated bsr + bsr_s, // short bsr + bsr_l, + post_padding); // long_bsr LOG_I(MAC,"[UE %d] Generate header :bufflen %d sdu_length_total %d, num_sdus %d, sdu_lengths[0] %d, sdu_lcids[0] %d => payload offset %d, dcch_header_len %d, dtch_header_len %d, padding %d,post_padding %d, bsr len %d, phr len %d, reminder %d \n", - Mod_id,buflen, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],payload_offset, dcch_header_len, dtch_header_len, - short_padding,post_padding, bsr_len, phr_len,buflen-sdu_length_total-payload_offset); + module_idP,buflen, sdu_length_total,num_sdus,sdu_lengths[0],sdu_lcids[0],payload_offset, dcch_header_len, dtch_header_len, + short_padding,post_padding, bsr_len, phr_len,buflen-sdu_length_total-payload_offset); // cycle through SDUs and place in ulsch_buffer memcpy(&ulsch_buffer[payload_offset],ulsch_buff,sdu_length_total); // fill remainder of DLSCH with random data @@ -1251,16 +1253,16 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.opt_enabled) - trace_pdu(0, ulsch_buffer, buflen, Mod_id, 3, UE_mac_inst[Mod_id].crnti, subframe, 0, 0); + trace_pdu(0, ulsch_buffer, buflen, module_idP, 3, UE_mac_inst[module_idP].crnti, subframe, 0, 0); LOG_D(OPT,"[UE %d][ULSCH] Frame %d trace pdu for rnti %x with size %d\n", - Mod_id, frame, UE_mac_inst[Mod_id].crnti, buflen); + module_idP, frame, UE_mac_inst[module_idP].crnti, buflen); #endif - - LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", - Mod_id,payload_offset, sdu_length_total); - UE_mac_inst[Mod_id].scheduling_info.SR_pending=0; - UE_mac_inst[Mod_id].scheduling_info.SR_COUNTER=0; - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); + + LOG_D(MAC,"[UE %d][SR] Gave SDU to PHY, clearing any scheduling request\n", + module_idP,payload_offset, sdu_length_total); + UE_mac_inst[module_idP].scheduling_info.SR_pending=0; + UE_mac_inst[module_idP].scheduling_info.SR_COUNTER=0; + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GET_SDU, VCD_FUNCTION_OUT); } // called at each subframe @@ -1272,7 +1274,7 @@ void ue_get_sdu(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index,u8 *ulsch_buffer,u -UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t direction,u8 eNB_index) { +UE_L2_STATE_t ue_scheduler(module_id_t module_idP,frame_t frameP, sub_frame_t subframeP, lte_subframe_t directionP,u8 eNB_indexP) { int lcid; // lcid index int TTI= 1; @@ -1295,31 +1297,31 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire #if defined(ENABLE_ITTI) do { - // Checks if a message has been sent to MAC sub-task - itti_poll_msg (TASK_MAC_UE, &msg_p); + // Checks if a message has been sent to MAC sub-task + itti_poll_msg (TASK_MAC_UE, &msg_p); - if (msg_p != NULL) { - msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); + if (msg_p != NULL) { + msg_name = ITTI_MSG_NAME (msg_p); + instance = ITTI_MSG_INSTANCE (msg_p); - switch (ITTI_MSG_ID(msg_p)) { - case RRC_MAC_CCCH_DATA_REQ: - LOG_I(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n", + switch (ITTI_MSG_ID(msg_p)) { + case RRC_MAC_CCCH_DATA_REQ: + LOG_I(MAC, "Received %s from %s: instance %d, frame %d, eNB_index %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, RRC_MAC_CCCH_DATA_REQ (msg_p).frame, RRC_MAC_CCCH_DATA_REQ (msg_p).enb_index); - // TODO process CCCH data req. - break; + // TODO process CCCH data req. + break; - default: - LOG_E(MAC, "Received unexpected message %s\n", msg_name); - break; - } + default: + LOG_E(MAC, "Received unexpected message %s\n", msg_name); + break; + } - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } } while(msg_p != NULL); #endif @@ -1327,7 +1329,7 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire //Rrc_xface->Frame_index=Mac_rlc_xface->frame; //if (subframe%5 == 0) #ifdef EXMIMO - pdcp_run(frame, 0, Mod_id, eNB_index); + pdcp_run(frame, 0, module_idP, eNB_index); /* ret = pthread_mutex_trylock (&pdcp_mutex); if (ret != 0) { @@ -1340,7 +1342,7 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire else { pdcp_instance_cnt++; pthread_mutex_unlock(&pdcp_mutex); - + if (pdcp_instance_cnt == 0) { if (pthread_cond_signal(&pdcp_cond) != 0) { LOG_E(PDCP,"pthread_cond_signal unsuccessfull\n"); @@ -1351,20 +1353,20 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire LOG_W(PDCP,"PDCP thread busy!!! inst_cnt=%d\n",pdcp_instance_cnt); } } - */ + */ #endif - UE_mac_inst[Mod_id].frame = frame; - UE_mac_inst[Mod_id].subframe = subframe; + UE_mac_inst[module_idP].frame = frameP; + UE_mac_inst[module_idP].subframe = subframeP; #ifdef CELLULAR - rrc_rx_tx(Mod_id, frame, 0, eNB_index); + rrc_rx_tx(module_idP, frameP, 0, eNB_indexP); #else - switch (rrc_rx_tx(Mod_id, - frame, - 0, - eNB_index)) { + switch (rrc_rx_tx(module_idP, + frameP, + 0, + eNB_indexP)) { case RRC_OK: break; case RRC_ConnSetup_failed: @@ -1375,9 +1377,9 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire LOG_E(MAC,"RRC Loss of synch, returning PHY_RESYNCH\n"); return(PHY_RESYNCH); case RRC_Handover_failed: - LOG_N(MAC,"Handover failure for UE %d eNB_index %d\n",Mod_id,eNB_index); + LOG_N(MAC,"Handover failure for UE %d eNB_index %d\n",module_idP,eNB_indexP); //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); + mac_xface->phy_config_afterHO_ue(module_idP,eNB_indexP,(MobilityControlInfo_t *)NULL,1); //return(3); break; case RRC_HO_STARTED: @@ -1389,28 +1391,28 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire #endif // Check Contention resolution timer (put in a function later) - if (UE_mac_inst[Mod_id].RA_contention_resolution_timer_active == 1) { - - if (UE_mac_inst[Mod_id].radioResourceConfigCommon) - rach_ConfigCommon = &UE_mac_inst[Mod_id].radioResourceConfigCommon->rach_ConfigCommon; - else { - LOG_E(MAC,"FATAL: radioResourceConfigCommon is NULL!!!\n"); - mac_xface->macphy_exit(""); - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); - return(RRC_OK); - } + if (UE_mac_inst[module_idP].RA_contention_resolution_timer_active == 1) { - LOG_I(MAC,"Frame %d: Contention resolution timer %d/%d\n",frame,UE_mac_inst[Mod_id].RA_contention_resolution_cnt, - ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)); + if (UE_mac_inst[module_idP].radioResourceConfigCommon) + rach_ConfigCommon = &UE_mac_inst[module_idP].radioResourceConfigCommon->rach_ConfigCommon; + else { + LOG_E(MAC,"FATAL: radioResourceConfigCommon is NULL!!!\n"); + mac_xface->macphy_exit(""); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + return(RRC_OK); + } - UE_mac_inst[Mod_id].RA_contention_resolution_cnt++; - if (UE_mac_inst[Mod_id].RA_contention_resolution_cnt == - ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)) { - UE_mac_inst[Mod_id].RA_active = 0; - // Signal PHY to quit RA procedure - LOG_E(MAC,"Contention resolution timer expired, RA failed\n"); - mac_xface->ra_failed(Mod_id,eNB_index); - } + LOG_I(MAC,"Frame %d: Contention resolution timer %d/%d\n",frame,UE_mac_inst[module_idP].RA_contention_resolution_cnt, + ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)); + + UE_mac_inst[module_idP].RA_contention_resolution_cnt++; + if (UE_mac_inst[module_idP].RA_contention_resolution_cnt == + ((1+rach_ConfigCommon->ra_SupervisionInfo.mac_ContentionResolutionTimer)<<3)) { + UE_mac_inst[module_idP].RA_active = 0; + // Signal PHY to quit RA procedure + LOG_E(MAC,"Contention resolution timer expired, RA failed\n"); + mac_xface->ra_failed(module_idP,eNB_indexP); + } } @@ -1418,77 +1420,77 @@ UE_L2_STATE_t ue_scheduler(u8 Mod_id,u32 frame, u8 subframe, lte_subframe_t dire // outlined in Sections 5.4.4 an 5.4.5 of 36.321 // Put this in another function - // Get RLC status info and update Bj for all lcids that are active + // Get RLC status info and update Bj for all lcids that are active for (lcid=DCCH; lcid <= DTCH; lcid++ ) { - 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)){ - if (UE_mac_inst[Mod_id].logicalChannelConfig[lcid]->ul_SpecificParameters) { - bucketsizeduration = UE_mac_inst[Mod_id].logicalChannelConfig[lcid]->ul_SpecificParameters->prioritisedBitRate * TTI; - bucketsizeduration_max = get_ms_bucketsizeduration(UE_mac_inst[Mod_id].logicalChannelConfig[lcid]->ul_SpecificParameters->bucketSizeDuration); - } - else { - LOG_E(MAC,"[UE %d] lcid %d, NULL ul_SpecificParameters\n",Mod_id,lcid); - mac_xface->macphy_exit(""); - } - if ( UE_mac_inst[Mod_id].scheduling_info.Bj[lcid] > bucketsizeduration_max ) - UE_mac_inst[Mod_id].scheduling_info.Bj[lcid] = bucketsizeduration_max; - else - UE_mac_inst[Mod_id].scheduling_info.Bj[lcid] = bucketsizeduration; - } - if (update_bsr(Mod_id,frame, lcid, UE_mac_inst[Mod_id].scheduling_info.LCGID[lcid])) { - UE_mac_inst[Mod_id].scheduling_info.SR_pending= 1; - LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", - Mod_id, frame,subframe,UE_mac_inst[Mod_id].scheduling_info.LCGID[lcid], - UE_mac_inst[Mod_id].scheduling_info.BSR[UE_mac_inst[Mod_id].scheduling_info.LCGID[lcid]], - UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[UE_mac_inst[Mod_id].scheduling_info.LCGID[lcid]]); + if ((lcid == 0) ||(UE_mac_inst[module_idP].logicalChannelConfig[lcid])) { + // meausre the Bj + if ((directionP == SF_UL)&& (UE_mac_inst[module_idP].scheduling_info.Bj[lcid] >= 0)){ + if (UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters) { + bucketsizeduration = UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->prioritisedBitRate * TTI; + bucketsizeduration_max = get_ms_bucketsizeduration(UE_mac_inst[module_idP].logicalChannelConfig[lcid]->ul_SpecificParameters->bucketSizeDuration); + } + else { + LOG_E(MAC,"[UE %d] lcid %d, NULL ul_SpecificParameters\n",module_idP,lcid); + mac_xface->macphy_exit(""); + } + if ( UE_mac_inst[module_idP].scheduling_info.Bj[lcid] > bucketsizeduration_max ) + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration_max; + else + UE_mac_inst[module_idP].scheduling_info.Bj[lcid] = bucketsizeduration; + } + if (update_bsr(module_idP,frame, lcid, UE_mac_inst[module_idP].scheduling_info.LCGID[lcid])) { + UE_mac_inst[module_idP].scheduling_info.SR_pending= 1; + LOG_D(MAC,"[UE %d][SR] Frame %d subframe %d SR for PUSCH is pending for LCGID %d with BSR level %d (%d bytes in RLC)\n", + module_idP, frameP,subframeP,UE_mac_inst[module_idP].scheduling_info.LCGID[lcid], + UE_mac_inst[module_idP].scheduling_info.BSR[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]], + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[UE_mac_inst[module_idP].scheduling_info.LCGID[lcid]]); + } } - } } // UE has no valid phy config dedicated || no valid/released SR - if ((UE_mac_inst[Mod_id].physicalConfigDedicated == NULL)) { - // cancel all pending SRs - UE_mac_inst[Mod_id].scheduling_info.SR_pending=0; - UE_mac_inst[Mod_id].ul_active=0; - LOG_T(MAC,"[UE %d] Release all SRs \n", Mod_id); - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); - return(CONNECTION_OK); + if ((UE_mac_inst[module_idP].physicalConfigDedicated == NULL)) { + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending=0; + UE_mac_inst[module_idP].ul_active=0; + LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); + return(CONNECTION_OK); } - if ((UE_mac_inst[Mod_id].physicalConfigDedicated->schedulingRequestConfig == NULL) || - (UE_mac_inst[Mod_id].physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_release)){ + if ((UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig == NULL) || + (UE_mac_inst[module_idP].physicalConfigDedicated->schedulingRequestConfig->present == SchedulingRequestConfig_PR_release)){ - // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 + // initiate RA with CRNTI included in msg3 (no contention) as descibed in 36.321 sec 5.1.5 - // cancel all pending SRs - UE_mac_inst[Mod_id].scheduling_info.SR_pending=0; - UE_mac_inst[Mod_id].ul_active=0; - LOG_T(MAC,"[UE %d] Release all SRs \n", Mod_id); + // cancel all pending SRs + UE_mac_inst[module_idP].scheduling_info.SR_pending=0; + UE_mac_inst[module_idP].ul_active=0; + LOG_T(MAC,"[UE %d] Release all SRs \n", module_idP); } // Put this in a function // Call PHR procedure as described in Section 5.4.6 in 36.321 - if (UE_mac_inst[Mod_id].PHR_state == MAC_MainConfig__phr_Config_PR_setup){ // normal operation - if (UE_mac_inst[Mod_id].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers - UE_mac_inst[Mod_id].PHR_reporting_active = 1; - UE_mac_inst[Mod_id].PHR_reconfigured = 0; - } else { - //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF, UE_mac_inst[Mod_id].PHR_reporting_active); - if ((UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF <= 0) && - ((mac_xface->get_PL(Mod_id,eNB_index) < UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db) || - (UE_mac_inst[Mod_id].power_backoff_db[eNB_index] > UE_mac_inst[Mod_id].scheduling_info.PathlossChange_db))) + if (UE_mac_inst[module_idP].PHR_state == MAC_MainConfig__phr_Config_PR_setup){ // normal operation + if (UE_mac_inst[module_idP].PHR_reconfigured == 1) { // upon (re)configuration of the power headroom reporting functionality by upper layers + UE_mac_inst[module_idP].PHR_reporting_active = 1; + UE_mac_inst[module_idP].PHR_reconfigured = 0; + } else { + //LOG_D(MAC,"PHR normal operation %d active %d \n", UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].PHR_reporting_active); + if ((UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF <= 0) && + ((mac_xface->get_PL(module_idP,eNB_indexP) < UE_mac_inst[module_idP].scheduling_info.PathlossChange_db) || + (UE_mac_inst[module_idP].power_backoff_db[eNB_indexP] > UE_mac_inst[module_idP].scheduling_info.PathlossChange_db))) // trigger PHR and reset the timer later when the PHR report is sent - UE_mac_inst[Mod_id].PHR_reporting_active = 1; - else if (UE_mac_inst[Mod_id].PHR_reporting_active ==0 ) - UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF--; - if (UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF <= 0 ) + UE_mac_inst[module_idP].PHR_reporting_active = 1; + else if (UE_mac_inst[module_idP].PHR_reporting_active ==0 ) + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF--; + if (UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF <= 0 ) // trigger PHR and reset the timer later when the PHR report is sent - UE_mac_inst[Mod_id].PHR_reporting_active = 1; - else if (UE_mac_inst[Mod_id].PHR_reporting_active == 0 ) - UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF--; - } + UE_mac_inst[module_idP].PHR_reporting_active = 1; + else if (UE_mac_inst[module_idP].PHR_reporting_active == 0 ) + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF--; + } } else { // release / nothing - UE_mac_inst[Mod_id].PHR_reporting_active = 0; // release PHR + UE_mac_inst[module_idP].PHR_reporting_active = 0; // release PHR } //If the UE has UL resources allocated for new transmission for this TTI here: vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SCHEDULER, VCD_FUNCTION_OUT); @@ -1502,89 +1504,89 @@ double uniform_rngen(int min, int max) { return (max - min) * random + min; } -int use_cba_access(u8 Mod_id,u32 frame,u8 subframe, u8 eNB_index){ - - if (( ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1]<64)) || - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2]<64)) || - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3]<64)) ) - // && (UE_mac_inst[Mod_id].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[Mod_id].cba_last_access[0] <= 0) ) { // backoff - // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", Mod_id, frame, subframe, - // UE_mac_inst[Mod_id].cba_last_access[0] ); - - UE_mac_inst[Mod_id].cba_last_access[0]= round(uniform_rngen(1,10)); - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", Mod_id, frame, subframe, - UE_mac_inst[Mod_id].cba_last_access[0], UE_mac_inst[Mod_id].ul_active); - - return 1; - } else if (( ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1]> 0 )) || - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2]> 0 )) || - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3]> 0 )) ) - // && (UE_mac_inst[Mod_id].ul_active == 0) // check if the ul is acrtive - && (UE_mac_inst[Mod_id].cba_last_access[0]> 0) ){ - - UE_mac_inst[Mod_id].cba_last_access[0]-=1; - LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", - Mod_id, frame, subframe, - UE_mac_inst[Mod_id].cba_last_access[0], UE_mac_inst[Mod_id].ul_active); - - } /*else if (( ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID1] == 0 )) && - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID2] == 0 )) && - ((UE_mac_inst[Mod_id].scheduling_info.BSR[LCGID3] == 0 )) ) - && (UE_mac_inst[Mod_id].cba_last_access[0]> 0) ){ - UE_mac_inst[Mod_id].cba_last_access[0]-=1; +int use_cba_access(module_id_t module_idP,frame_t frameP,u8 subframe, u8 eNB_index){ + + if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]<64)) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]>0)&&(UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]<64)) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0] <= 0) ) { // backoff + // LOG_D(MAC,"[UE %d] Frame %d Subframe %d: the current CBA backoff is %d \n", module_idP, frame, subframe, + // UE_mac_inst[module_idP].cba_last_access[0] ); + + UE_mac_inst[module_idP].cba_last_access[0]= round(uniform_rngen(1,10)); + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: start a new CBA backoff %d UL active state %d \n", module_idP, frame, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + return 1; + } else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2]> 0 )) || + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3]> 0 )) ) + // && (UE_mac_inst[module_idP].ul_active == 0) // check if the ul is acrtive + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + + UE_mac_inst[module_idP].cba_last_access[0]-=1; + LOG_D(MAC,"[UE %d] Frame %d Subframe %d: CBA backoff is decreased by one to %d UL active state %d \n", + module_idP, frame, subframe, + UE_mac_inst[module_idP].cba_last_access[0], UE_mac_inst[module_idP].ul_active); + + } /*else if (( ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID1] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID2] == 0 )) && + ((UE_mac_inst[module_idP].scheduling_info.BSR[LCGID3] == 0 )) ) + && (UE_mac_inst[module_idP].cba_last_access[0]> 0) ){ + UE_mac_inst[module_idP].cba_last_access[0]-=1; }*/ - + return 0; - + } #endif -int get_bsr_lcgid (u8 Mod_id){ +int get_bsr_lcgid (module_id_t module_idP){ int lcgid, lcgid_tmp=-1; int num_active_lcgid = 0; - + for (lcgid = 0 ; lcgid < MAX_NUM_LCGID; lcgid++){ - if (UE_mac_inst[Mod_id].scheduling_info.BSR[lcgid] > 0 ){ - lcgid_tmp = lcgid; - num_active_lcgid+=1; - } + if (UE_mac_inst[module_idP].scheduling_info.BSR[lcgid] > 0 ){ + lcgid_tmp = lcgid; + num_active_lcgid+=1; + } } if (num_active_lcgid == 0) - return -1; + return -1; else if (num_active_lcgid == 1) - return lcgid_tmp; + return lcgid_tmp; else - return MAX_NUM_LCGID; + return MAX_NUM_LCGID; } -u8 get_bsr_len (u8 Mod_id, u16 buflen) { +u8 get_bsr_len (module_id_t module_idP, u16 buflen) { int lcgid=0; u8 bsr_len=0, num_lcgid=0; int pdu = 0; for (lcgid=0; lcgid < MAX_NUM_LCGID; lcgid++ ) { - if (UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcgid] > 0 ) - pdu += (UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) - if (UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcgid] > 128 ) // long header size: adjust the header size - pdu += 1; - // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid - - if ( (pdu > buflen) && (UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcgid] > 0 ) ){ - num_lcgid +=1; - bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; - } - LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) + pdu += (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] + bsr_len + 2); //2 = sizeof(SCH_SUBHEADER_SHORT) + if (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 128 ) // long header size: adjust the header size + pdu += 1; + // current phy buff can not transport all sdu for this lcgid -> transmit a bsr for this lcgid + + if ( (pdu > buflen) && (UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid] > 0 ) ){ + num_lcgid +=1; + bsr_len = (num_lcgid >= 2 ) ? sizeof(BSR_LONG) : sizeof(BSR_SHORT) ; + } + LOG_D(MAC,"BSR Bytes %d for lcgid %d bsr len %d num lcgid %d\n", UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcgid], lcgid, bsr_len, num_lcgid); } if ( bsr_len > 0 ) LOG_D(MAC,"[UE %d] Prepare a %s (Transport Block Size %d, MAC pdu Size %d) \n", - Mod_id, map_int_to_str(BSR_names, bsr_len), buflen, pdu); + module_idP, map_int_to_str(BSR_names, bsr_len), buflen, pdu); return bsr_len; } -int update_bsr(u8 Mod_id, u32 frame, u8 lcid, u8 lcg_id){ +int update_bsr(module_id_t module_idP, frame_t frameP, u8 lcid, u8 lcg_id){ mac_rlc_status_resp_t rlc_status; u8 sr_pending = 0; @@ -1592,25 +1594,25 @@ int update_bsr(u8 Mod_id, u32 frame, u8 lcid, u8 lcg_id){ return sr_pending; // 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; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id]=0; + UE_mac_inst[module_idP].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, - lcid, - 0); - if (rlc_status.bytes_in_buffer > 0 ) { - sr_pending = 1; - UE_mac_inst[Mod_id].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; - 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 - LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", - Mod_id, UE_mac_inst[Mod_id].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[Mod_id].scheduling_info.BSR_bytes[lcg_id]); - } - else - UE_mac_inst[Mod_id].scheduling_info.LCID_status[lcid]=LCID_EMPTY; + if (UE_mac_inst[module_idP].scheduling_info.LCGID[lcid] == lcg_id) { + rlc_status = mac_rlc_status_ind(0, module_idP,frame,0,RLC_MBMS_NO, + lcid, + 0); + if (rlc_status.bytes_in_buffer > 0 ) { + sr_pending = 1; + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid] = LCID_NOT_EMPTY; + UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id] += locate (BSR_TABLE,BSR_TABLE_SIZE, rlc_status.bytes_in_buffer); + UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id] += rlc_status.bytes_in_buffer; + // UE_mac_inst[module_idP].scheduling_info.BSR_short_lcid = lcid; // only applicable to short bsr + LOG_D(MAC,"[UE %d] BSR level %d (LCGID %d, rlc buffer %d byte)\n", + module_idP, UE_mac_inst[module_idP].scheduling_info.BSR[lcg_id],lcg_id, UE_mac_inst[module_idP].scheduling_info.BSR_bytes[lcg_id]); + } + else + UE_mac_inst[module_idP].scheduling_info.LCID_status[lcid]=LCID_EMPTY; } //} return sr_pending; @@ -1628,12 +1630,12 @@ u8 locate (const u32 *table, int size, int value){ ascend = (table[ju] >= table[jl]) ? 1 : 0; // determine the order of the the table: 1 if ascending order of table, 0 otherwise while (ju-jl > 1) { //If we are not yet done, - jm = (ju+jl) >> 1; //compute a midpoint, - if ((value >= table[jm]) == ascend) - jl=jm; // replace the lower limit - else - ju=jm; //replace the upper limit - LOG_T(MAC,"[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", jm, table[jm], value); + jm = (ju+jl) >> 1; //compute a midpoint, + if ((value >= table[jm]) == ascend) + jl=jm; // replace the lower limit + else + ju=jm; //replace the upper limit + LOG_T(MAC,"[UE] searching BSR index %d for (BSR TABLE %d < value %d)\n", jm, table[jm], value); } if (value == table[jl]) return jl; else return jl+1; //equally ju @@ -1745,24 +1747,24 @@ int get_ms_bucketsizeduration(u8 bucketsizeduration){ } } -void update_phr(u8 Mod_id){ - - UE_mac_inst[Mod_id].PHR_reporting_active =0; - 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); - // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[Mod_id].scheduling_info.periodicPHR_SF, UE_mac_inst[Mod_id].scheduling_info.prohibitPHR_SF); +void update_phr(module_id_t module_idP){ + + UE_mac_inst[module_idP].PHR_reporting_active =0; + UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF = get_sf_perioidicPHR_Timer(UE_mac_inst[module_idP].scheduling_info.periodicPHR_Timer); + UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF = get_sf_prohibitPHR_Timer(UE_mac_inst[module_idP].scheduling_info.prohibitPHR_Timer); + // LOG_D(MAC,"phr %d %d\n ",UE_mac_inst[module_idP].scheduling_info.periodicPHR_SF, UE_mac_inst[module_idP].scheduling_info.prohibitPHR_SF); } -u8 get_phr_mapping (u8 Mod_id, u8 eNB_index){ +u8 get_phr_mapping (module_id_t module_idP, u8 eNB_index){ -//power headroom reporting range is from -23 ...+40 dB, as described in 36313 -//note: mac_xface->get_Po_NOMINAL_PUSCH(Mod_id) is float - if (mac_xface->get_PHR(Mod_id,eNB_index) < -23) + //power headroom reporting range is from -23 ...+40 dB, as described in 36313 + //note: mac_xface->get_Po_NOMINAL_PUSCH(module_idP) is float + if (mac_xface->get_PHR(module_idP,eNB_index) < -23) return 0; - else if (mac_xface->get_PHR(Mod_id,eNB_index) >= 40) + else if (mac_xface->get_PHR(module_idP,eNB_index) >= 40) return 63; - else // -23 to 40 - return (u8) mac_xface->get_PHR(Mod_id,eNB_index) + PHR_MAPPING_OFFSET; - + else // -23 to 40 + return (u8) mac_xface->get_PHR(module_idP,eNB_index) + PHR_MAPPING_OFFSET; + } int get_sf_perioidicPHR_Timer(u8 perioidicPHR_Timer){ return (perioidicPHR_Timer+1)*10; diff --git a/openair2/LAYER2/PDCP/pdcp_fifo.c b/openair2/LAYER2/PDCP/pdcp_fifo.c index 2ac7305ecfcc95765576922b3b5d56c225ac5fcd..cbd2fc60845b972b458bed0e34c50c6245dcf91e 100755 --- a/openair2/LAYER2/PDCP/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP/pdcp_fifo.c @@ -259,9 +259,6 @@ pdcp_fifo_read_input_sdus_remaining_bytes () { //----------------------------------------------------------------------------- sdu_size_t bytes_read=0; - // if remaining bytes to read - - if (pdcp_input_sdu_remaining_size_to_read > 0) { diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index ccdf4e9f2049bcd8a948a28904ece9c727c00bd6..40b2a43f9815e739feb0f2d9931e169559b2d2f9 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -25,7 +25,7 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file pdcp.c * \brief pdcp interface with RLC @@ -61,9 +61,6 @@ # include "intertask_interface.h" #endif -#define PDCP_DATA_REQ_DEBUG 0 -#define PDCP_DATA_IND_DEBUG 0 - #ifndef OAI_EMU extern int otg_enabled; #endif @@ -79,176 +76,180 @@ extern int otg_rx_pkt( int src, int dst, int ctime, char *buffer_tx, unsigned in * this mem_block_t to be dissected for testing purposes. For further details see test * code at targets/TEST/PDCP/test_pdcp.c:test_pdcp_data_req() */ -#ifdef PDCP_UNIT_TEST -BOOL pdcp_data_req(module_id_t module_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_id, sdu_size_t sdu_buffer_size, \ - unsigned char* sdu_buffer, pdcp_t* test_pdcp_entity, list_t* test_list) -#else -BOOL pdcp_data_req(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_id, u32 muiP, u32 confirmP, - sdu_size_t sdu_buffer_size, unsigned char* sdu_buffer, u8 mode) -#endif +BOOL pdcp_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, rb_id_t rb_idP, mui_t muiP, u32 confirmP, + sdu_size_t sdu_buffer_sizeP, unsigned char* sdu_buffer_pP, u8 modeP) { //----------------------------------------------------------------------------- - pdcp_t* pdcp; - u8 i; - u8 pdcp_header_len=0, pdcp_tailer_len=0; - u16 pdcp_pdu_size=0, current_sn; - mem_block_t* pdcp_pdu = NULL; - rlc_op_status_t rlc_status; - module_id_t module_id; - rb_id_t rb_id_rlc = 0; - - AssertError (eNB_id < NUMBER_OF_eNB_MAX, return FALSE, "eNB id is too high (%u/%d) %u %u!\n", eNB_id, NUMBER_OF_eNB_MAX, UE_id, rb_id); - AssertError (UE_id < NUMBER_OF_UE_MAX, return FALSE, "UE id is too high (%u/%d) %u %u!\n", UE_id, NUMBER_OF_UE_MAX, eNB_id, rb_id); - AssertError (rb_id < NB_RB_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_id, NB_RB_MAX, UE_id, eNB_id); - -#ifdef PDCP_UNIT_TEST - pdcp = test_pdcp_entity; -#else - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][rb_id]; - module_id = NB_eNB_INST + UE_id; - rb_id_rlc = rb_id; + pdcp_t *pdcp_p = NULL; + u8 i = 0; + u8 pdcp_header_len = 0; + u8 pdcp_tailer_len = 0; + u16 pdcp_pdu_size = 0; + u16 current_sn = 0; + mem_block_t *pdcp_pdu_p = NULL; + rlc_op_status_t rlc_status; + rb_id_t rb_id_rlc = 0; + + AssertError (enb_mod_idP < NUMBER_OF_eNB_MAX, return FALSE, "eNB id is too high (%u/%d) %u %u!\n", enb_mod_idP, NUMBER_OF_eNB_MAX, ue_mod_idP, rb_idP); + AssertError (ue_mod_idP < NUMBER_OF_UE_MAX, return FALSE, "UE id is too high (%u/%d) %u %u!\n", ue_mod_idP, NUMBER_OF_UE_MAX, enb_mod_idP, rb_idP); + AssertError (rb_idP < NB_RB_MAX, return FALSE, "RB id is too high (%u/%d) %u %u!\n", rb_idP, NB_RB_MAX, ue_mod_idP, enb_mod_idP); + + if (enb_flagP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_idP]; } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; - module_id = eNB_id; - rb_id_rlc = rb_id + (NB_RB_MAX * UE_id); + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP]; } -#endif - if ((pdcp->instanciated_instance == 0) && (mode != PDCP_TM)) { - if (eNB_flag == 0) { - LOG_W(PDCP, "[UE %d] Instance is not configured for eNB %d, rb_id %d Ignoring SDU...\n", - UE_id, eNB_id, rb_id); - } else { - LOG_W(PDCP, "[eNB %d] Instance is not configured for UE %d, rb_id %d Ignoring SDU...\n", - eNB_id, UE_id, rb_id); - } - return FALSE; + if ((pdcp_p->instanciated_instance == 0) && (modeP != PDCP_TM)) { + if (enb_flagP == 0) { + LOG_W(PDCP, "[UE %d] Instance is not configured for eNB %d, rb_id %d Ignoring SDU...\n", + ue_mod_idP, enb_mod_idP, rb_idP); + } else { + LOG_W(PDCP, "[eNB %d] Instance is not configured for UE %d, rb_id %d Ignoring SDU...\n", + enb_mod_idP, ue_mod_idP, rb_idP); + } + return FALSE; } - if (sdu_buffer_size == 0) { - LOG_W(PDCP, "Handed SDU is of size 0! Ignoring...\n"); - return FALSE; + if (sdu_buffer_sizeP == 0) { + LOG_W(PDCP, "Handed SDU is of size 0! Ignoring...\n"); + return FALSE; } /* * XXX MAX_IP_PACKET_SIZE is 4096, shouldn't this be MAX SDU size, which is 8188 bytes? */ - if (sdu_buffer_size > MAX_IP_PACKET_SIZE) { - LOG_E(PDCP, "Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n", - sdu_buffer_size, MAX_IP_PACKET_SIZE); - // XXX What does following call do? - mac_xface->macphy_exit("PDCP sdu buffer size > MAX_IP_PACKET_SIZE"); + if (sdu_buffer_sizeP > MAX_IP_PACKET_SIZE) { + LOG_E(PDCP, "Requested SDU size (%d) is bigger than that can be handled by PDCP (%u)!\n", + sdu_buffer_sizeP, MAX_IP_PACKET_SIZE); + // XXX What does following call do? + mac_xface->macphy_exit("PDCP sdu buffer size > MAX_IP_PACKET_SIZE"); } // PDCP transparent mode for MBMS traffic - if (mode == PDCP_TM) { - LOG_D(PDCP, " [TM] Asking for a new mem_block of size %d\n",sdu_buffer_size); - pdcp_pdu = get_free_mem_block(sdu_buffer_size); - if (pdcp_pdu != NULL) { - memcpy(&pdcp_pdu->data[0], sdu_buffer, sdu_buffer_size); - rlc_status = rlc_data_req(module_id, frame, eNB_flag, RLC_MBMS_YES, rb_id_rlc, muiP, confirmP, sdu_buffer_size, pdcp_pdu); - } else - rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; + if (modeP == PDCP_TM) { + LOG_D(PDCP, " [TM] Asking for a new mem_block of size %d\n",sdu_buffer_sizeP); + pdcp_pdu_p = get_free_mem_block(sdu_buffer_sizeP); + if (pdcp_pdu_p != NULL) { + memcpy(&pdcp_pdu_p->data[0], sdu_buffer_pP, sdu_buffer_sizeP); + rlc_status = rlc_data_req(enb_mod_idP, ue_mod_idP, frameP, enb_flagP, RLC_MBMS_YES, rb_idP, muiP, confirmP, sdu_buffer_sizeP, pdcp_pdu_p); + } else { + rlc_status = RLC_OP_STATUS_OUT_OF_RESSOURCES; +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + frameP, + (enb_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); +#endif + } } else { - // calculate the pdcp header and trailer size - if ((rb_id % NB_RB_MAX) < DTCH) { - pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE; - pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE; - } else { - pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; - pdcp_tailer_len = 0; - } - pdcp_pdu_size= sdu_buffer_size + pdcp_header_len + pdcp_tailer_len; - - LOG_I(PDCP, "Data request notification for PDCP entity with module ID %d and radio bearer ID %d pdu size %d (header%d, trailer%d)\n", module_id, rb_id,pdcp_pdu_size, pdcp_header_len,pdcp_tailer_len); - - /* - * Allocate a new block for the new PDU (i.e. PDU header and SDU payload) - */ - LOG_D(PDCP, "Asking for a new mem_block of size %d\n", pdcp_pdu_size); - pdcp_pdu = get_free_mem_block(pdcp_pdu_size); - - if (pdcp_pdu != NULL) { - /* - * Create a Data PDU with header and append data - * - * Place User Plane PDCP Data PDU header first - */ - - if ((rb_id % NB_RB_MAX) < DTCH) { // this Control plane PDCP Data PDU - pdcp_control_plane_data_pdu_header pdu_header; - pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp); - current_sn = pdu_header.sn; - memset(&pdu_header.mac_i[0],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE); - if (pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer((unsigned char*)pdcp_pdu->data, &pdu_header) == FALSE) { - LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); - return FALSE; - } + // calculate the pdcp header and trailer size + if (rb_idP < DTCH) { + pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE; + pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE; } else { - pdcp_user_plane_data_pdu_header_with_long_sn pdu_header; - pdu_header.dc = (mode == 1) ? PDCP_DATA_PDU : PDCP_CONTROL_PDU; - pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp); - current_sn = pdu_header.sn ; - if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu->data, &pdu_header) == FALSE) { - LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); - return FALSE; - } + pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; + pdcp_tailer_len = 0; } + pdcp_pdu_size = sdu_buffer_sizeP + pdcp_header_len + pdcp_tailer_len; + + LOG_I(PDCP, "Data request notification for PDCP entity %s enb id %u ue_id %u and radio bearer ID %d pdu size %d (header%d, trailer%d)\n", + (enb_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + pdcp_pdu_size, + pdcp_header_len, + pdcp_tailer_len); + /* - * Validate incoming sequence number, there might be a problem with PDCP initialization + * Allocate a new block for the new PDU (i.e. PDU header and SDU payload) */ - if (current_sn > pdcp_calculate_max_seq_num_for_given_size(pdcp->seq_num_size)) { - LOG_E(PDCP, "Generated sequence number (%lu) is greater than a sequence number could ever be!\n", current_sn); - LOG_E(PDCP, "There must be a problem with PDCP initialization, ignoring this PDU...\n"); - - free_mem_block(pdcp_pdu); - return FALSE; - } + LOG_D(PDCP, "Asking for a new mem_block of size %d\n", pdcp_pdu_size); + pdcp_pdu_p = get_free_mem_block(pdcp_pdu_size); + + if (pdcp_pdu_p != NULL) { + /* + * Create a Data PDU with header and append data + * + * Place User Plane PDCP Data PDU header first + */ + + if ((rb_idP % NB_RB_MAX) < DTCH) { // this Control plane PDCP Data PDU + pdcp_control_plane_data_pdu_header pdu_header; + pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p); + current_sn = pdu_header.sn; + memset(&pdu_header.mac_i[0],0,PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE); + if (pdcp_serialize_control_plane_data_pdu_with_SRB_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { + LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); + return FALSE; + } + } else { + pdcp_user_plane_data_pdu_header_with_long_sn pdu_header; + pdu_header.dc = (modeP == 1) ? PDCP_DATA_PDU : PDCP_CONTROL_PDU; + pdu_header.sn = pdcp_get_next_tx_seq_number(pdcp_p); + current_sn = pdu_header.sn ; + if (pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer((unsigned char*)pdcp_pdu_p->data, &pdu_header) == FALSE) { + LOG_E(PDCP, "Cannot fill PDU buffer with relevant header fields!\n"); + return FALSE; + } + } + /* + * Validate incoming sequence number, there might be a problem with PDCP initialization + */ + if (current_sn > pdcp_calculate_max_seq_num_for_given_size(pdcp_p->seq_num_size)) { + LOG_E(PDCP, "Generated sequence number (%lu) is greater than a sequence number could ever be!\n", current_sn); + LOG_E(PDCP, "There must be a problem with PDCP initialization, ignoring this PDU...\n"); + + free_mem_block(pdcp_pdu_p); + return FALSE; + } - LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn); + LOG_D(PDCP, "Sequence number %d is assigned to current PDU\n", current_sn); - /* Then append data... */ - memcpy(&pdcp_pdu->data[pdcp_header_len], sdu_buffer, sdu_buffer_size); + /* Then append data... */ + memcpy(&pdcp_pdu_p->data[pdcp_header_len], sdu_buffer_pP, sdu_buffer_sizeP); - //For control plane data that are not integrity protected, - // the MAC-I field is still present and should be padded with padding bits set to 0. - // NOTE: user-plane data are never integrity protected - for (i=0;i<pdcp_tailer_len;i++) - pdcp_pdu->data[pdcp_header_len + sdu_buffer_size + i] = 0x00;// pdu_header.mac_i[i]; + //For control plane data that are not integrity protected, + // the MAC-I field is still present and should be padded with padding bits set to 0. + // NOTE: user-plane data are never integrity protected + for (i=0;i<pdcp_tailer_len;i++) + pdcp_pdu_p->data[pdcp_header_len + sdu_buffer_sizeP + i] = 0x00;// pdu_header.mac_i[i]; #if defined(ENABLE_SECURITY) - if ((pdcp->security_activated != 0) && - ((pdcp->cipheringAlgorithm) != 0) && - ((pdcp->integrityProtAlgorithm) != 0)) { - pdcp_apply_security(pdcp, rb_id % NB_RB_MAX, - pdcp_header_len, current_sn, pdcp_pdu->data, - sdu_buffer_size); - } + if ((pdcp->security_activated != 0) && + ((pdcp->cipheringAlgorithm) != 0) && + ((pdcp->integrityProtAlgorithm) != 0)) { + pdcp_apply_security(pdcp, rb_id % NB_RB_MAX, + pdcp_header_len, current_sn, pdcp_pdu->data, + sdu_buffer_size); + } #endif - /* Print octets of outgoing data in hexadecimal form */ - LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n", - pdcp_pdu_size); - util_print_hex_octets(PDCP, (unsigned char*)pdcp_pdu->data, pdcp_pdu_size); - //util_flush_hex_octets(PDCP, (unsigned char*)pdcp_pdu->data, pdcp_pdu_size); - } else { - LOG_E(PDCP, "Cannot create a mem_block for a PDU!\n"); - return FALSE; - } -#ifdef PDCP_UNIT_TEST - /* - * Here we add PDU to the list and return to test code without - * handing it off to RLC - */ - list_add_tail_eurecom(pdcp_pdu, test_list); - return TRUE; -#else - /* - * Ask sublayer to transmit data and check return value - * to see if RLC succeeded - */ - rlc_status = rlc_data_req(module_id, frame, eNB_flag, 0, rb_id_rlc, muiP, confirmP, pdcp_pdu_size, pdcp_pdu); + /* Print octets of outgoing data in hexadecimal form */ + LOG_D(PDCP, "Following content with size %d will be sent over RLC (PDCP PDU header is the first two bytes)\n", + pdcp_pdu_size); + //util_print_hex_octets(PDCP, (unsigned char*)pdcp_pdu_p->data, pdcp_pdu_size); + //util_flush_hex_octets(PDCP, (unsigned char*)pdcp_pdu->data, pdcp_pdu_size); + } else { + LOG_E(PDCP, "Cannot create a mem_block for a PDU!\n"); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_REQ SDU DROPPED, OUT OF MEMORY \n", + frameP, + (enb_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); +#endif + return FALSE; + } + /* + * Ask sublayer to transmit data and check return value + * to see if RLC succeeded + */ + rlc_status = rlc_data_req(enb_mod_idP, ue_mod_idP, frameP, enb_flagP, 0, rb_idP, muiP, confirmP, pdcp_pdu_size, pdcp_pdu_p); } switch (rlc_status) { case RLC_OP_STATUS_OK: @@ -287,238 +288,241 @@ BOOL pdcp_data_req(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_i } }*/ return TRUE; -#endif // PDCP_UNIT_TEST } -//----------------------------------------------------------------------------- -#ifdef PDCP_UNIT_TEST -BOOL pdcp_data_ind(module_id_t module_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_id, sdu_size_t sdu_buffer_size, \ - mem_block_t* sdu_buffer, pdcp_t* pdcp_test_entity, list_t* test_list) -#else -BOOL pdcp_data_ind(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, rb_id_t rb_id, sdu_size_t sdu_buffer_size, \ - mem_block_t* sdu_buffer, u8 is_data_plane) -#endif + +BOOL pdcp_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, u8_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_buffer_sizeP, \ + mem_block_t* sdu_buffer_pP, u8 is_data_planeP) { //----------------------------------------------------------------------------- -#ifdef PDCP_UNIT_TEST - pdcp_t* pdcp; - list_t* sdu_list; -#else - pdcp_t* pdcp; - list_t* sdu_list; -#endif - mem_block_t *new_sdu = NULL; - u8 pdcp_header_len=0, pdcp_tailer_len=0; - u16 sequence_number; - u8 payload_offset = 0; - module_id_t module_id; - -#ifdef PDCP_UNIT_TEST - pdcp = pdcp_test_entity; - sdu_list = test_list; - - LOG_I(PDCP, "Data indication notification for PDCP entity for module" - "ID %d and radio bearer ID %d rlc sdu size %d eNB_flag %d\n", - module_id, rb_id, sdu_buffer_size, eNB_flag); -#else - DevCheck4(UE_id < NUMBER_OF_UE_MAX, UE_id, NUMBER_OF_UE_MAX, eNB_id, rb_id); - DevCheck4(eNB_id < NUMBER_OF_eNB_MAX, eNB_id, NUMBER_OF_eNB_MAX, UE_id, rb_id); - DevCheck4(rb_id < NB_RB_MAX, rb_id, NB_RB_MAX, eNB_id, UE_id); - - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][rb_id]; - module_id = NB_eNB_INST + UE_id; - - LOG_I(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u " + pdcp_t *pdcp_p = NULL; + list_t *sdu_list_p = NULL; + mem_block_t *new_sdu_p = NULL; + u8 pdcp_header_len = 0; + u8 pdcp_tailer_len = 0; + u16 sequence_number = 0; + u8 payload_offset = 0; + + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB inst is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB inst is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE inst is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE inst is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + DevCheck4(rb_idP < NB_RB_MAX, rb_idP, NB_RB_MAX, enb_mod_idP, ue_mod_idP); + + if (enb_flagP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_idP]; + + LOG_I(PDCP, "Data indication notification for PDCP entity from eNB %u to UE %u " "and radio bearer ID %d rlc sdu size %d eNB_flag %d\n", - UE_id, eNB_id, rb_id, sdu_buffer_size, eNB_flag); + ue_mod_idP, enb_mod_idP, rb_idP, sdu_buffer_sizeP, enb_flagP); } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; - module_id = eNB_id; + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP]; - LOG_I(PDCP, "Data indication notification for PDCP entity from eNB %u to UE %u " + LOG_I(PDCP, "Data indication notification for PDCP entity from UE %u to eNB %u " "and radio bearer ID %d rlc sdu size %d eNB_flag %d eNB_id %d\n", - eNB_id, UE_id, rb_id, sdu_buffer_size, eNB_flag, eNB_id); + enb_mod_idP, ue_mod_idP, rb_idP, sdu_buffer_sizeP, enb_flagP, enb_mod_idP); } - sdu_list = &pdcp_sdu_list; -#endif + sdu_list_p = &pdcp_sdu_list; +# - if (sdu_buffer_size == 0) { - LOG_W(PDCP, "SDU buffer size is zero! Ignoring this chunk!\n"); - return FALSE; + if (sdu_buffer_sizeP == 0) { + LOG_W(PDCP, "SDU buffer size is zero! Ignoring this chunk!\n"); + return FALSE; } /* - * Check if incoming SDU is long enough to carry a PDU header - */ + * Check if incoming SDU is long enough to carry a PDU header + */ if (MBMS_flagP == 0 ) { - if ((rb_id % NB_RB_MAX) < DTCH) { - pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE; - pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE; - } else { - pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; - pdcp_tailer_len = 0; - } + if ((rb_idP % NB_RB_MAX) < DTCH) { + pdcp_header_len = PDCP_CONTROL_PLANE_DATA_PDU_SN_SIZE; + pdcp_tailer_len = PDCP_CONTROL_PLANE_DATA_PDU_MAC_I_SIZE; + } else { + pdcp_header_len = PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; + pdcp_tailer_len = 0; + } - if (sdu_buffer_size < pdcp_header_len + pdcp_tailer_len ) { - LOG_W(PDCP, "Incoming (from RLC) SDU is short of size (size:%d)! Ignoring...\n", sdu_buffer_size); -#ifndef PDCP_UNIT_TEST - free_mem_block(sdu_buffer); -#endif - return FALSE; - } + if (sdu_buffer_sizeP < pdcp_header_len + pdcp_tailer_len ) { + LOG_W(PDCP, "Incoming (from RLC) SDU is short of size (size:%d)! Ignoring...\n", sdu_buffer_sizeP); + free_mem_block(sdu_buffer_pP); + return FALSE; + } - /* + /* * Parse the PDU placed at the beginning of SDU to check * if incoming SN is in line with RX window */ - if (pdcp_header_len == PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE) { // DRB - sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char*)sdu_buffer->data); -// u8 dc = pdcp_get_dc_filed((unsigned char*)sdu_buffer->data); - } else { //SRB1/2 - sequence_number = pdcp_get_sequence_number_of_pdu_with_SRB_sn((unsigned char*)sdu_buffer->data); - } - if (pdcp_is_rx_seq_number_valid(sequence_number, pdcp) == TRUE) { - LOG_D(PDCP, "Incoming PDU has a sequence number (%d) in accordance with RX window, yay!\n", sequence_number); - /* if (dc == PDCP_DATA_PDU ) + if (pdcp_header_len == PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE) { // DRB + sequence_number = pdcp_get_sequence_number_of_pdu_with_long_sn((unsigned char*)sdu_buffer_pP->data); + // u8 dc = pdcp_get_dc_filed((unsigned char*)sdu_buffer->data); + } else { //SRB1/2 + sequence_number = pdcp_get_sequence_number_of_pdu_with_SRB_sn((unsigned char*)sdu_buffer_pP->data); + } + if (pdcp_is_rx_seq_number_valid(sequence_number, pdcp_p) == TRUE) { + LOG_D(PDCP, "Incoming PDU has a sequence number (%d) in accordance with RX window\n", sequence_number); + /* if (dc == PDCP_DATA_PDU ) LOG_D(PDCP, "Passing piggybacked SDU to NAS driver...\n"); else LOG_D(PDCP, "Passing piggybacked SDU to RRC ...\n");*/ - } else { - LOG_W(PDCP, "Incoming PDU has an unexpected sequence number (%d), RX window snychronisation have probably been lost!\n", sequence_number); - /* - * XXX Till we implement in-sequence delivery and duplicate discarding - * mechanism all out-of-order packets will be delivered to RRC/IP - */ + } else { + LOG_W(PDCP, "Incoming PDU has an unexpected sequence number (%d), RX window snychronisation have probably been lost!\n", sequence_number); + /* + * XXX Till we implement in-sequence delivery and duplicate discarding + * mechanism all out-of-order packets will be delivered to RRC/IP + */ #if 0 - LOG_D(PDCP, "Ignoring PDU...\n"); - free_mem_block(sdu_buffer); - return FALSE; + LOG_D(PDCP, "Ignoring PDU...\n"); + free_mem_block(sdu_buffer); + return FALSE; #else - LOG_W(PDCP, "Delivering out-of-order SDU to upper layer...\n"); + LOG_W(PDCP, "Delivering out-of-order SDU to upper layer...\n"); #endif - } - // SRB1/2: control-plane data - if ( (rb_id % NB_RB_MAX) < DTCH ){ -#if defined(ENABLE_SECURITY) - if (pdcp->security_activated == 1) { - pdcp_validate_security(pdcp, rb_id, pdcp_header_len, - sequence_number, sdu_buffer->data, - sdu_buffer_size - pdcp_tailer_len); } + // SRB1/2: control-plane data + if ( (rb_idP % NB_RB_MAX) < DTCH ){ +#if defined(ENABLE_SECURITY) + if (pdcp->security_activated == 1) { + pdcp_validate_security(pdcp, rb_id, pdcp_header_len, + sequence_number, sdu_buffer->data, + sdu_buffer_size - pdcp_tailer_len); + } #endif - //rrc_lite_data_ind(module_id, //Modified MW - L2 Interface - pdcp_rrc_data_ind(eNB_id, - UE_id, - frame, - eNB_flag, - rb_id, - sdu_buffer_size - pdcp_header_len - pdcp_tailer_len, - (u8*)&sdu_buffer->data[pdcp_header_len]); - free_mem_block(sdu_buffer); - // free_mem_block(new_sdu); - return TRUE; - } - payload_offset=PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; +//rrc_lite_data_ind(module_id, //Modified MW - L2 Interface + pdcp_rrc_data_ind(enb_mod_idP, + ue_mod_idP, + frameP, + enb_flagP, + rb_idP, + sdu_buffer_sizeP - pdcp_header_len - pdcp_tailer_len, + (u8*)&sdu_buffer_pP->data[pdcp_header_len]); + free_mem_block(sdu_buffer_pP); + // free_mem_block(new_sdu); + return TRUE; + } + payload_offset=PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE; #if defined(ENABLE_SECURITY) - if (pdcp->security_activated == 1) { - pdcp_validate_security(pdcp, rb_id % NB_RB_MAX, pdcp_header_len, - sequence_number, sdu_buffer->data, - sdu_buffer_size - pdcp_tailer_len); - } + if (pdcp->security_activated == 1) { + pdcp_validate_security(pdcp_p, rb_idP % NB_RB_MAX, pdcp_header_len, + sequence_number, sdu_buffer->data, + sdu_buffer_size - pdcp_tailer_len); + } #endif } else { - payload_offset=0; + payload_offset=0; } #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled == 1) { - int src_id, dst_id, ctime; - - src_id = (eNB_flag != 0) ? UE_id + NB_eNB_INST : eNB_id; - dst_id = (eNB_flag == 0) ? UE_id + NB_eNB_INST : eNB_id; - ctime = oai_emulation.info.time_ms; // avg current simulation time in ms : we may get the exact time through OCG? - LOG_D(PDCP, "Check received buffer : enb_flag %d mod id %d, rab id %d (src %d, dst %d)\n", - eNB_flag, module_id, rb_id, src_id, dst_id); - - if (otg_rx_pkt(src_id, dst_id,ctime,&sdu_buffer->data[payload_offset], - sdu_buffer_size - payload_offset ) == 0 ) { - free_mem_block(sdu_buffer); - return TRUE; - } + module_id_t src_id, dst_id; + int ctime; + + src_id = (enb_flagP != 0) ? ue_mod_idP : enb_mod_idP; + dst_id = (enb_flagP == 0) ? ue_mod_idP : enb_mod_idP; + ctime = oai_emulation.info.time_ms; // avg current simulation time in ms : we may get the exact time through OCG? + LOG_D(PDCP, "Check received buffer : enb_flag %d rab id %d (src %d, dst %d)\n", + enb_flagP, rb_idP, src_id, dst_id); + + if (otg_rx_pkt(src_id, dst_id,ctime,&sdu_buffer_pP->data[payload_offset], + sdu_buffer_sizeP - payload_offset ) == 0 ) { + free_mem_block(sdu_buffer_pP); + return TRUE; + } } #else if (otg_enabled==1) { - LOG_D(OTG,"Discarding received packed\n"); - free_mem_block(sdu_buffer); - return TRUE; + LOG_D(OTG,"Discarding received packed\n"); + free_mem_block(sdu_buffer_pP); + return TRUE; } #endif - new_sdu = get_free_mem_block(sdu_buffer_size - payload_offset + sizeof (pdcp_data_ind_header_t)); + new_sdu_p = get_free_mem_block(sdu_buffer_sizeP - payload_offset + sizeof (pdcp_data_ind_header_t)); - if (new_sdu) { - /* + if (new_sdu_p) { + /* * Prepend PDCP indication header which is going to be removed at pdcp_fifo_flush_sdus() */ - memset(new_sdu->data, 0, sizeof (pdcp_data_ind_header_t)); - if (eNB_flag == 0) { - ((pdcp_data_ind_header_t *) new_sdu->data)->rb_id = rb_id; - } else { - /* RB id for an UE on eNB is instantiated */ - ((pdcp_data_ind_header_t *) new_sdu->data)->rb_id = rb_id + (UE_id * NB_RB_MAX); - } - ((pdcp_data_ind_header_t *) new_sdu->data)->data_size = sdu_buffer_size - payload_offset; - - // Here there is no virtualization possible -#ifdef IDROMEL_NEMO - if (eNB_flag == 0) - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = rb_id / NB_RB_MAX; - else - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = 0; -#else - ((pdcp_data_ind_header_t *) new_sdu->data)->inst = module_id; + memset(new_sdu_p->data, 0, sizeof (pdcp_data_ind_header_t)); + ((pdcp_data_ind_header_t *) new_sdu_p->data)->data_size = sdu_buffer_sizeP - payload_offset; + + // Here there is no virtualization possible + // set ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst for IP layer here + if (enb_flagP == 0) { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_idP; +#if defined(OAI_EMU) + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = ue_mod_idP + oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local; +#endif + } else { + ((pdcp_data_ind_header_t *) new_sdu_p->data)->rb_id = rb_idP + (ue_mod_idP * NB_RB_MAX); +#if defined(OAI_EMU) + ((pdcp_data_ind_header_t *) new_sdu_p->data)->inst = enb_mod_idP - oai_emulation.info.first_enb_local; #endif - - // XXX Decompression would be done at this point + } + - /* + // XXX Decompression would be done at this point + + /* * After checking incoming sequence number PDCP header * has to be stripped off so here we copy SDU buffer starting * from its second byte (skipping 0th and 1st octets, i.e. * PDCP header) */ - memcpy(&new_sdu->data[sizeof (pdcp_data_ind_header_t)], \ - &sdu_buffer->data[payload_offset], \ - sdu_buffer_size - payload_offset); - list_add_tail_eurecom (new_sdu, sdu_list); - - /* Print octets of incoming data in hexadecimal form */ - LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", sdu_buffer_size - payload_offset + sizeof(pdcp_data_ind_header_t), - sdu_buffer_size - payload_offset); - //util_print_hex_octets(PDCP, (unsigned char*)new_sdu->data, sdu_buffer_size - PDCP_USER_PLANE_DATA_PDU_LONG_SN_HEADER_SIZE + sizeof(pdcp_data_ind_header_t)); - util_flush_hex_octets(PDCP, (unsigned char*)new_sdu->data, sdu_buffer_size - payload_offset + sizeof(pdcp_data_ind_header_t)); - - /* + memcpy(&new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], \ + &sdu_buffer_pP->data[payload_offset], \ + sdu_buffer_sizeP - payload_offset); + list_add_tail_eurecom (new_sdu_p, sdu_list_p); + + /* Print octets of incoming data in hexadecimal form */ + LOG_D(PDCP, "Following content has been received from RLC (%d,%d)(PDCP header has already been removed):\n", + sdu_buffer_sizeP - payload_offset + sizeof(pdcp_data_ind_header_t), + sdu_buffer_sizeP - payload_offset); + //util_print_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + //util_flush_hex_octets(PDCP, &new_sdu_p->data[sizeof (pdcp_data_ind_header_t)], sdu_buffer_sizeP - payload_offset); + + /* * Update PDCP statistics * XXX Following two actions are identical, is there a merge error? */ - if (eNB_flag == 1) { - Pdcp_stats_rx[module_id][(rb_id & RAB_OFFSET2) >> RAB_SHIFT2][(rb_id & RAB_OFFSET) - DTCH]++; - Pdcp_stats_rx_bytes[module_id][(rb_id & RAB_OFFSET2) >> RAB_SHIFT2][(rb_id & RAB_OFFSET) - DTCH] += sdu_buffer_size; + + /*if (enb_flagP == 1) { + Pdcp_stats_rx[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH]++; + Pdcp_stats_rx_bytes[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH] += sdu_buffer_sizeP; } else { - Pdcp_stats_rx[module_id][(rb_id & RAB_OFFSET2) >> RAB_SHIFT2][(rb_id & RAB_OFFSET) - DTCH]++; - Pdcp_stats_rx_bytes[module_id][(rb_id & RAB_OFFSET2) >> RAB_SHIFT2][(rb_id & RAB_OFFSET) - DTCH] += sdu_buffer_size; - } + Pdcp_stats_rx[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH]++; + Pdcp_stats_rx_bytes[module_id][(rb_idP & RAB_OFFSET2) >> RAB_SHIFT2][(rb_idP & RAB_OFFSET) - DTCH] += sdu_buffer_sizeP; + }*/ + } +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + else { + AssertFatal(0, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u] PDCP_DATA_IND SDU DROPPED, OUT OF MEMORY \n", + frameP, + (enb_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); } +#endif - free_mem_block(sdu_buffer); + free_mem_block(sdu_buffer_pP); return TRUE; } //----------------------------------------------------------------------------- -void pdcp_run (u32_t frame, u8 eNB_flag, u8 UE_index, u8 eNB_index) { +void pdcp_run (frame_t frameP, eNB_flag_t eNB_flag, module_id_t ue_mod_idP, module_id_t enb_mod_idP) { //----------------------------------------------------------------------------- #if defined(ENABLE_ITTI) MessageDef *msg_p; @@ -531,48 +535,48 @@ void pdcp_run (u32_t frame, u8 eNB_flag, u8 UE_index, u8 eNB_index) { #if defined(ENABLE_ITTI) do { - // Checks if a message has been sent to PDCP sub-task - itti_poll_msg (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p); + // Checks if a message has been sent to PDCP sub-task + itti_poll_msg (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, &msg_p); - if (msg_p != NULL) { - msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); + if (msg_p != NULL) { + msg_name = ITTI_MSG_NAME (msg_p); + instance = ITTI_MSG_INSTANCE (msg_p); - switch (ITTI_MSG_ID(msg_p)) { - case RRC_DCCH_DATA_REQ: - LOG_I(PDCP, "Received %s from %s: instance %d, frame %d, eNB_flag %d, rb_id %d, muiP %d, confirmP %d, mode %d\n", + switch (ITTI_MSG_ID(msg_p)) { + case RRC_DCCH_DATA_REQ: + LOG_I(PDCP, "Received %s from %s: instance %d, frame %d, eNB_flag %d, rb_id %d, muiP %d, confirmP %d, mode %d\n", msg_name, ITTI_MSG_ORIGIN_NAME(msg_p), instance, RRC_DCCH_DATA_REQ (msg_p).frame, RRC_DCCH_DATA_REQ (msg_p).enb_flag, RRC_DCCH_DATA_REQ (msg_p).rb_id, RRC_DCCH_DATA_REQ (msg_p).muip, RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).mode); - result = pdcp_data_req (RRC_DCCH_DATA_REQ (msg_p).eNB_index, RRC_DCCH_DATA_REQ (msg_p).ue_index, RRC_DCCH_DATA_REQ (msg_p).frame, RRC_DCCH_DATA_REQ (msg_p).enb_flag, - RRC_DCCH_DATA_REQ (msg_p).rb_id, RRC_DCCH_DATA_REQ (msg_p).muip, - RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).sdu_size, - RRC_DCCH_DATA_REQ (msg_p).sdu_p, RRC_DCCH_DATA_REQ (msg_p).mode); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); + result = pdcp_data_req (RRC_DCCH_DATA_REQ (msg_p).eNB_index, RRC_DCCH_DATA_REQ (msg_p).ue_index, RRC_DCCH_DATA_REQ (msg_p).frame, RRC_DCCH_DATA_REQ (msg_p).enb_flag, + RRC_DCCH_DATA_REQ (msg_p).rb_id, RRC_DCCH_DATA_REQ (msg_p).muip, + RRC_DCCH_DATA_REQ (msg_p).confirmp, RRC_DCCH_DATA_REQ (msg_p).sdu_size, + RRC_DCCH_DATA_REQ (msg_p).sdu_p, RRC_DCCH_DATA_REQ (msg_p).mode); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); - // Message buffer has been processed, free it now. - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_REQ (msg_p).sdu_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - break; + // Message buffer has been processed, free it now. + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_REQ (msg_p).sdu_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + break; - default: - LOG_E(PDCP, "Received unexpected message %s\n", msg_name); - break; - } + default: + LOG_E(PDCP, "Received unexpected message %s\n", msg_name); + break; + } - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } } while(msg_p != NULL); # if 0 { - MessageDef *msg_resp_p; + MessageDef *msg_resp_p; - msg_resp_p = itti_alloc_new_message(TASK_PDCP_ENB, MESSAGE_TEST); + msg_resp_p = itti_alloc_new_message(TASK_PDCP_ENB, MESSAGE_TEST); - itti_send_msg_to_task(TASK_RRC_ENB, 1, msg_resp_p); + itti_send_msg_to_task(TASK_RRC_ENB, 1, msg_resp_p); } { MessageDef *msg_resp_p; @@ -591,29 +595,32 @@ void pdcp_run (u32_t frame, u8 eNB_flag, u8 UE_index, u8 eNB_index) { # endif #endif - pdcp_fifo_read_input_sdus_from_otg(frame, eNB_flag, UE_index, eNB_index); + pdcp_fifo_read_input_sdus_from_otg(frameP, eNB_flag, ue_mod_idP, enb_mod_idP); // IP/NAS -> PDCP traffic : TX, read the pkt from the upper layer buffer - pdcp_fifo_read_input_sdus(frame, eNB_flag, UE_index, eNB_index); + pdcp_fifo_read_input_sdus(frameP, eNB_flag, ue_mod_idP, enb_mod_idP); // PDCP -> NAS/IP traffic: RX - pdcp_fifo_flush_sdus(frame, eNB_flag, eNB_index, UE_index); + pdcp_fifo_flush_sdus(frameP, eNB_flag, enb_mod_idP, ue_mod_idP); vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_RUN, VCD_FUNCTION_OUT); } -BOOL rrc_pdcp_config_asn1_req (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, - SRB_ToAddModList_t* srb2add_list, - DRB_ToAddModList_t* drb2add_list, - DRB_ToReleaseList_t* drb2release_list, - u8 security_mode, - u8 *kRRCenc, - u8 *kRRCint, - u8 *kUPenc +BOOL rrc_pdcp_config_asn1_req (module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t enb_flagP, + SRB_ToAddModList_t *srb2add_list_pP, + DRB_ToAddModList_t *drb2add_list_pP, + DRB_ToReleaseList_t *drb2release_list_pP, + u8 security_modeP, + u8 *kRRCenc_pP, + u8 *kRRCint_pP, + u8 *kUPenc_pP #ifdef Rel10 - ,PMCH_InfoList_r9_t* pmch_InfoList_r9 +,PMCH_InfoList_r9_t* pmch_InfoList_r9_pP #endif - ) +) { long int rb_id = 0; long int lc_id = 0; @@ -621,261 +628,259 @@ BOOL rrc_pdcp_config_asn1_req (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, long int mch_id = 0; rlc_mode_t rlc_type = RLC_NONE; DRB_Identity_t drb_id = 0; - DRB_Identity_t* pdrb_id = NULL; + DRB_Identity_t *pdrb_id_p = NULL; u8 drb_sn = 0; u8 srb_sn = 5; // fixed sn for SRBs u8 drb_report = 0; long int cnt = 0; u16 header_compression_profile = 0; u32 action = ACTION_ADD; - SRB_ToAddMod_t* srb_toaddmod = NULL; - DRB_ToAddMod_t* drb_toaddmod = NULL; - pdcp_t *pdcp; - module_id_t module_id; + SRB_ToAddMod_t *srb_toaddmod_p = NULL; + DRB_ToAddMod_t *drb_toaddmod_p = NULL; + pdcp_t *pdcp_p = NULL; + module_id_t module_id = -1; #ifdef Rel10 int i,j; - MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9; - MBMS_SessionInfo_r9_t *MBMS_SessionInfo= NULL; + MBMS_SessionInfoList_r9_t *mbms_SessionInfoList_r9_p = NULL; + MBMS_SessionInfo_r9_t *MBMS_SessionInfo_p = NULL; #endif - if (eNB_flag == 0) { - module_id = NB_eNB_INST + UE_id; - LOG_D(PDCP, "[UE %d] CONFIG REQ ASN1 for eNB %d (Mod_id %u)\n", UE_id, eNB_id, module_id); + if (enb_flagP == 0) { + LOG_D(PDCP, "[UE %d] CONFIG REQ ASN1 for eNB %d\n", ue_mod_idP, enb_mod_idP); } else { - module_id = eNB_id; - LOG_D(PDCP, "[eNB %d] CONFIG REQ ASN1 for UE %d (Mod_id %u)\n", eNB_id, UE_id, module_id); + LOG_D(PDCP, "[eNB %d] CONFIG REQ ASN1 for UE %d\n", enb_mod_idP, ue_mod_idP); } // srb2add_list does not define pdcp config, we use rlc info to setup the pdcp dcch0 and dcch1 channels - if (srb2add_list != NULL) { - for (cnt=0;cnt<srb2add_list->list.count;cnt++) { - srb_id = srb2add_list->list.array[cnt]->srb_Identity; - srb_toaddmod = srb2add_list->list.array[cnt]; - rlc_type = RLC_MODE_AM; - rb_id = srb_id; - lc_id = srb_id; - - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][srb_id]; - } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][srb_id]; - } + if (srb2add_list_pP != NULL) { + for (cnt=0;cnt<srb2add_list_pP->list.count;cnt++) { + srb_id = srb2add_list_pP->list.array[cnt]->srb_Identity; + srb_toaddmod_p = srb2add_list_pP->list.array[cnt]; + rlc_type = RLC_MODE_AM; + rb_id = srb_id; + lc_id = srb_id; + + if (enb_flagP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][srb_id]; + } else { + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][srb_id]; + } - if (pdcp->instanciated_instance == 1) { - action = ACTION_MODIFY; - } else { - action = ACTION_ADD; - } + if (pdcp_p->instanciated_instance == 1) { + action = ACTION_MODIFY; + } else { + action = ACTION_ADD; + } - if (srb_toaddmod->rlc_Config) { - switch (srb_toaddmod->rlc_Config->present) { - case SRB_ToAddMod__rlc_Config_PR_NOTHING: - break; - case SRB_ToAddMod__rlc_Config_PR_explicitValue: - switch (srb_toaddmod->rlc_Config->choice.explicitValue.present) { - case RLC_Config_PR_NOTHING: - break; - default: - pdcp_config_req_asn1 (pdcp, - eNB_id, - UE_id, - frame, - eNB_flag, // not really required - rlc_type, - action, - lc_id, - mch_id, - rb_id, - srb_sn, - 0, // drb_report - 0, // header compression - security_mode, - kRRCenc, - kRRCint, - kUPenc); - break; - } - break; - case SRB_ToAddMod__rlc_Config_PR_defaultValue: - // already the default values - break; - default: - DevParam(srb_toaddmod->rlc_Config->present, UE_id, eNB_id); - break; - } + if (srb_toaddmod_p->rlc_Config) { + switch (srb_toaddmod_p->rlc_Config->present) { + case SRB_ToAddMod__rlc_Config_PR_NOTHING: + break; + case SRB_ToAddMod__rlc_Config_PR_explicitValue: + switch (srb_toaddmod_p->rlc_Config->choice.explicitValue.present) { + case RLC_Config_PR_NOTHING: + break; + default: + pdcp_config_req_asn1 (pdcp_p, + enb_mod_idP, + ue_mod_idP, + frameP, + enb_flagP, // not really required + rlc_type, + action, + lc_id, + mch_id, + rb_id, + srb_sn, + 0, // drb_report + 0, // header compression + security_modeP, + kRRCenc_pP, + kRRCint_pP, + kUPenc_pP); + break; + } + break; + case SRB_ToAddMod__rlc_Config_PR_defaultValue: + // already the default values + break; + default: + DevParam(srb_toaddmod_p->rlc_Config->present, ue_mod_idP, enb_mod_idP); + break; + } + } } - } } // reset the action - if (drb2add_list != NULL) { - for (cnt=0;cnt<drb2add_list->list.count;cnt++) { + if (drb2add_list_pP != NULL) { + for (cnt=0;cnt<drb2add_list_pP->list.count;cnt++) { - drb_toaddmod = drb2add_list->list.array[cnt]; + drb_toaddmod_p = drb2add_list_pP->list.array[cnt]; - drb_id = drb_toaddmod->drb_Identity; + drb_id = drb_toaddmod_p->drb_Identity; - if (drb_toaddmod->logicalChannelIdentity != null) { - lc_id = *drb_toaddmod->logicalChannelIdentity; - } else { - lc_id = -1; - } - rb_id = lc_id; + if (drb_toaddmod_p->logicalChannelIdentity != null) { + lc_id = *drb_toaddmod_p->logicalChannelIdentity; + } else { + lc_id = -1; + } + rb_id = lc_id; - DevCheck4(rb_id < NB_RB_MAX, rb_id, NB_RB_MAX, UE_id, eNB_id); + DevCheck4(rb_id < NB_RB_MAX, rb_id, NB_RB_MAX, ue_mod_idP, enb_mod_idP); - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][rb_id]; - } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; - } + if (enb_flagP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_id]; + } else { + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_id]; + } - if (pdcp->instanciated_instance == 1) - action = ACTION_MODIFY; - else - action = ACTION_ADD; - - if (drb_toaddmod->pdcp_Config){ - if (drb_toaddmod->pdcp_Config->discardTimer) { - // set the value of the timer - } - if (drb_toaddmod->pdcp_Config->rlc_AM) { - drb_report = drb_toaddmod->pdcp_Config->rlc_AM->statusReportRequired; - rlc_type =RLC_MODE_AM; - } - if (drb_toaddmod->pdcp_Config->rlc_UM){ - drb_sn = drb_toaddmod->pdcp_Config->rlc_UM->pdcp_SN_Size; - rlc_type =RLC_MODE_UM; - } - switch (drb_toaddmod->pdcp_Config->headerCompression.present) { - case PDCP_Config__headerCompression_PR_NOTHING: - case PDCP_Config__headerCompression_PR_notUsed: - header_compression_profile=0x0; - break; - case PDCP_Config__headerCompression_PR_rohc: - // parse the struc and get the rohc profile - if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) - header_compression_profile=0x0001; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) - header_compression_profile=0x0002; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) - header_compression_profile=0x0003; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) - header_compression_profile=0x0004; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) - header_compression_profile=0x0006; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) - header_compression_profile=0x0101; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) - header_compression_profile=0x0102; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) - header_compression_profile=0x0103; - else if(drb_toaddmod->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) - header_compression_profile=0x0104; - else { - header_compression_profile=0x0; - LOG_W(PDCP,"unknown header compresion profile\n"); + if (pdcp_p->instanciated_instance == 1) + action = ACTION_MODIFY; + else + action = ACTION_ADD; + + if (drb_toaddmod_p->pdcp_Config){ + if (drb_toaddmod_p->pdcp_Config->discardTimer) { + // set the value of the timer + } + if (drb_toaddmod_p->pdcp_Config->rlc_AM) { + drb_report = drb_toaddmod_p->pdcp_Config->rlc_AM->statusReportRequired; + rlc_type =RLC_MODE_AM; + } + if (drb_toaddmod_p->pdcp_Config->rlc_UM){ + drb_sn = drb_toaddmod_p->pdcp_Config->rlc_UM->pdcp_SN_Size; + rlc_type =RLC_MODE_UM; + } + switch (drb_toaddmod_p->pdcp_Config->headerCompression.present) { + case PDCP_Config__headerCompression_PR_NOTHING: + case PDCP_Config__headerCompression_PR_notUsed: + header_compression_profile=0x0; + break; + case PDCP_Config__headerCompression_PR_rohc: + // parse the struc and get the rohc profile + if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0001) + header_compression_profile=0x0001; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0002) + header_compression_profile=0x0002; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0003) + header_compression_profile=0x0003; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0004) + header_compression_profile=0x0004; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0006) + header_compression_profile=0x0006; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0101) + header_compression_profile=0x0101; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0102) + header_compression_profile=0x0102; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0103) + header_compression_profile=0x0103; + else if(drb_toaddmod_p->pdcp_Config->headerCompression.choice.rohc.profiles.profile0x0104) + header_compression_profile=0x0104; + else { + header_compression_profile=0x0; + LOG_W(PDCP,"unknown header compresion profile\n"); + } + // set the applicable profile + break; + default: + LOG_W(PDCP,"[MOD_id %d][RB %d] unknown drb_toaddmod->PDCP_Config->headerCompression->present \n", + module_id, drb_id); + break; + } + pdcp_config_req_asn1 (pdcp_p, + enb_mod_idP, + ue_mod_idP, + frameP, + enb_flagP, // not really required + rlc_type, + action, + lc_id, + mch_id, + rb_id, + drb_sn, + drb_report, + header_compression_profile, + security_modeP, + kRRCenc_pP, + kRRCint_pP, + kUPenc_pP); } - // set the applicable profile - break; - default: - LOG_W(PDCP,"[MOD_id %d][RB %d] unknown drb_toaddmod->PDCP_Config->headerCompression->present \n", - module_id, drb_id); - break; - } - pdcp_config_req_asn1 (pdcp, - eNB_id, - UE_id, - frame, - eNB_flag, // not really required - rlc_type, - action, - lc_id, - mch_id, - rb_id, - drb_sn, - drb_report, - header_compression_profile, - security_mode, - kRRCenc, - kRRCint, - kUPenc); } - } } - if (drb2release_list != NULL) { - for (cnt=0;cnt<drb2release_list->list.count;cnt++) { - pdrb_id = drb2release_list->list.array[cnt]; - rb_id = *pdrb_id; - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][rb_id]; - } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; + if (drb2release_list_pP != NULL) { + for (cnt=0;cnt<drb2release_list_pP->list.count;cnt++) { + pdrb_id_p = drb2release_list_pP->list.array[cnt]; + rb_id = *pdrb_id_p; + if (enb_flagP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_id]; + } else { + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_id]; + } + action = ACTION_REMOVE; + pdcp_config_req_asn1 (pdcp_p, + enb_mod_idP, + ue_mod_idP, + frameP, + enb_flagP, // not really required + rlc_type, + action, + lc_id, + mch_id, + rb_id, + 0, + 0, + 0, + security_modeP, + kRRCenc_pP, + kRRCint_pP, + kUPenc_pP); } - action = ACTION_REMOVE; - pdcp_config_req_asn1 (pdcp, - eNB_id, - UE_id, - frame, - eNB_flag, // not really required - rlc_type, - action, - lc_id, - mch_id, - rb_id, - 0, - 0, - 0, - security_mode, - kRRCenc, - kRRCint, - kUPenc); - } } #ifdef Rel10 if (pmch_InfoList_r9 != NULL) { - for (i=0;i<pmch_InfoList_r9->list.count;i++) { - mbms_SessionInfoList_r9 = &(pmch_InfoList_r9->list.array[i]->mbms_SessionInfoList_r9); - for (j=0;j<mbms_SessionInfoList_r9->list.count;j++) { - MBMS_SessionInfo = mbms_SessionInfoList_r9->list.array[j]; - //lc_id = MBMS_SessionInfo->logicalChannelIdentity_r9; // lcid - lc_id = MBMS_SessionInfo->sessionId_r9->buf[0]; - mch_id = MBMS_SessionInfo->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string - - // can set the mch_id = i - if (eNB_flag) - rb_id = (mch_id * maxSessionPerPMCH ) + lc_id; - else - rb_id = (mch_id * maxSessionPerPMCH ) + lc_id + (maxDRB + 3); - - if (pdcp_mbms_array[module_id][rb_id].instanciated_instance == module_id + 1) - action = ACTION_MBMS_MODIFY; - else - action = ACTION_MBMS_ADD; - - rlc_type = RLC_MODE_UM; - pdcp_config_req_asn1 (NULL, - eNB_id, - UE_id, - frame, - eNB_flag, - rlc_type, - action, - lc_id, - mch_id, - rb_id, - 0, // set to deafult - 0, - 0, - security_mode, - kRRCenc, - kRRCint, - kUPenc); + for (i=0;i<pmch_InfoList_r9->list.count;i++) { + mbms_SessionInfoList_r9 = &(pmch_InfoList_r9->list.array[i]->mbms_SessionInfoList_r9); + for (j=0;j<mbms_SessionInfoList_r9->list.count;j++) { + MBMS_SessionInfo = mbms_SessionInfoList_r9->list.array[j]; + //lc_id = MBMS_SessionInfo->logicalChannelIdentity_r9; // lcid + lc_id = MBMS_SessionInfo->sessionId_r9->buf[0]; + mch_id = MBMS_SessionInfo->tmgi_r9.serviceId_r9.buf[2]; //serviceId is 3-octet string + + // can set the mch_id = i + if (eNB_flag) + rb_id = (mch_id * maxSessionPerPMCH ) + lc_id; + else + rb_id = (mch_id * maxSessionPerPMCH ) + lc_id + (maxDRB + 3); + + if (pdcp_mbms_array[module_id][rb_id].instanciated_instance == module_id + 1) + action = ACTION_MBMS_MODIFY; + else + action = ACTION_MBMS_ADD; + + rlc_type = RLC_MODE_UM; + pdcp_config_req_asn1 (NULL, + enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flag, + rlc_type, + action, + lc_id, + mch_id, + rb_id, + 0, // set to deafult + 0, + 0, + security_mode, + kRRCenc, + kRRCint, + kUPenc); + } } - } } #endif @@ -883,258 +888,275 @@ BOOL rrc_pdcp_config_asn1_req (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, } -BOOL pdcp_config_req_asn1 (pdcp_t *pdcp, u8 eNB_id, u8 UE_id, u32 frame, u8_t eNB_flag, - rlc_mode_t rlc_mode, u32 action, u16 lc_id,u16 mch_id, rb_id_t rb_id, - u8 rb_sn, u8 rb_report, u16 header_compression_profile, - u8 security_mode, - u8 *kRRCenc, - u8 *kRRCint, - u8 *kUPenc) +BOOL pdcp_config_req_asn1 (pdcp_t *pdcp_pP, + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t enb_flagP, + rlc_mode_t rlc_modeP, + u32 actionP, + u16 lc_idP, + u16 mch_idP, + rb_id_t rb_idP, + u8 rb_snP, + u8 rb_reportP, + u16 header_compression_profileP, + u8 security_modeP, + u8 *kRRCenc_pP, + u8 *kRRCint_pP, + u8 *kUPenc_pP) { - module_id_t module_id = 0; - - switch (action) { - case ACTION_ADD: - DevAssert(pdcp != NULL); - pdcp->instanciated_instance = 1; - pdcp->is_ue = (eNB_flag == 0) ? 1 : 0; - pdcp->lcid = lc_id; - pdcp->header_compression_profile = header_compression_profile; - pdcp->status_report = rb_report; - - if (rb_sn == PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { - pdcp->seq_num_size = 7; - } else if (rb_sn == PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) { - pdcp->seq_num_size=12; - } else { - pdcp->seq_num_size=5; - } - pdcp->rlc_mode = rlc_mode; - pdcp->next_pdcp_tx_sn = 0; - pdcp->next_pdcp_rx_sn = 0; - pdcp->tx_hfn = 0; - pdcp->rx_hfn = 0; - pdcp->last_submitted_pdcp_rx_sn = 4095; - pdcp->first_missing_pdu = -1; + switch (actionP) { + case ACTION_ADD: + DevAssert(pdcp_pP != NULL); + pdcp_pP->instanciated_instance = 1; + pdcp_pP->is_ue = (enb_flagP == 0) ? 1 : 0; + pdcp_pP->lcid = lc_idP; + pdcp_pP->header_compression_profile = header_compression_profileP; + pdcp_pP->status_report = rb_reportP; + + if (rb_snP == PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { + pdcp_pP->seq_num_size = 7; + } else if (rb_snP == PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) { + pdcp_pP->seq_num_size=12; + } else { + pdcp_pP->seq_num_size=5; + } - if (eNB_flag == 0) { + pdcp_pP->rlc_mode = rlc_modeP; + pdcp_pP->next_pdcp_tx_sn = 0; + pdcp_pP->next_pdcp_rx_sn = 0; + pdcp_pP->tx_hfn = 0; + pdcp_pP->rx_hfn = 0; + pdcp_pP->last_submitted_pdcp_rx_sn = 4095; + pdcp_pP->first_missing_pdu = -1; + + if (enb_flagP == 0) { LOG_I(PDCP, "[UE %d] Config request : Action ADD for eNB %d: Frame %d LCID %d (rb id %d) " - "configured with SN size %d bits and RLC %s\n", - UE_id, eNB_id, frame, lc_id, rb_id, pdcp->seq_num_size, - (rlc_mode == 1) ? "AM" : (rlc_mode == 2) ? "TM" : "UM"); - } else { + "configured with SN size %d bits and RLC %s\n", + ue_mod_idP, enb_mod_idP, frameP, lc_idP, rb_idP, pdcp_pP->seq_num_size, + (rlc_modeP == 1) ? "AM" : (rlc_modeP == 2) ? "TM" : "UM"); + } else { LOG_I(PDCP, "[eNB %d] Config request : Action ADD for UE %d: Frame %d LCID %d (rb id %d) " - "configured with SN size %d bits and RLC %s\n", - eNB_id, UE_id, frame, lc_id, rb_id, pdcp->seq_num_size, - (rlc_mode == 1) ? "AM" : (rlc_mode == 2) ? "TM" : "UM"); - } + "configured with SN size %d bits and RLC %s\n", + enb_mod_idP, ue_mod_idP, frameP, lc_idP, rb_idP, pdcp_pP->seq_num_size, + (rlc_modeP == 1) ? "AM" : (rlc_modeP == 2) ? "TM" : "UM"); + } - /* Setup security */ - if (security_mode != 0xff) { - pdcp_config_set_security(pdcp, eNB_id, UE_id, frame, eNB_flag, rb_id, lc_id, security_mode, kRRCenc, kRRCint, kUPenc); - } + /* Setup security */ + if (security_modeP != 0xff) { + pdcp_config_set_security(pdcp_pP, enb_mod_idP, ue_mod_idP, frameP, enb_flagP, rb_idP, lc_idP, security_modeP, kRRCenc_pP, kRRCint_pP, kUPenc_pP); + } - LOG_D(PDCP, "[MSC_NEW][FRAME %05d][PDCP][MOD %02d][RB %02d]\n", frame, (eNB_flag == 0) ? NB_eNB_INST + UE_id : eNB_id, rb_id); - break; + LOG_D(PDCP, "[FRAME %5u][%s][PDCP][MOD %u/%u][RB %u]\n", frameP, (enb_flagP == 0) ? "UE" : "eNB", enb_mod_idP, ue_mod_idP, rb_idP); + break; - case ACTION_MODIFY: - DevAssert(pdcp != NULL); - pdcp->header_compression_profile=header_compression_profile; - pdcp->status_report = rb_report; - pdcp->rlc_mode = rlc_mode; + case ACTION_MODIFY: + DevAssert(pdcp_pP != NULL); + pdcp_pP->header_compression_profile=header_compression_profileP; + pdcp_pP->status_report = rb_reportP; + pdcp_pP->rlc_mode = rlc_modeP; - /* Setup security */ - if (security_mode != 0xff) { - pdcp_config_set_security(pdcp, eNB_id, UE_id, frame, eNB_flag, rb_id, lc_id, security_mode, kRRCenc, kRRCint, kUPenc); - } + /* Setup security */ + if (security_modeP != 0xff) { + pdcp_config_set_security(pdcp_pP, enb_mod_idP, ue_mod_idP, frameP, enb_flagP, rb_idP, lc_idP, security_modeP, kRRCenc_pP, kRRCint_pP, kUPenc_pP); + } - if (rb_sn == PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { - pdcp->seq_num_size = 7; - } else if (rb_sn == PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) { - pdcp->seq_num_size = 12; - } else { - pdcp->seq_num_size=5; - } + if (rb_snP == PDCP_Config__rlc_UM__pdcp_SN_Size_len7bits) { + pdcp_pP->seq_num_size = 7; + } else if (rb_snP == PDCP_Config__rlc_UM__pdcp_SN_Size_len12bits) { + pdcp_pP->seq_num_size = 12; + } else { + pdcp_pP->seq_num_size=5; + } - if (eNB_flag == 0) { + if (enb_flagP == 0) { LOG_I(PDCP,"[UE %d] Config request : Action MODIFY for eNB %d: Frame %d LCID %d " - "RB id %d configured with SN size %d and RLC %s \n", - UE_id, eNB_id, frame, lc_id, rb_id, rb_sn, - (rlc_mode == 1) ? "AM" : (rlc_mode == 2) ? "TM" : "UM"); - } else { + "RB id %d configured with SN size %d and RLC %s \n", + ue_mod_idP, enb_mod_idP, frameP, lc_idP, rb_idP, rb_snP, + (rlc_modeP == 1) ? "AM" : (rlc_modeP == 2) ? "TM" : "UM"); + } else { LOG_I(PDCP,"[eNB %d] Config request : Action MODIFY for UE %d: Frame %d LCID %d " - "RB id %d configured with SN size %d and RLC %s \n", - eNB_id, UE_id, frame, lc_id, rb_id, rb_sn, - (rlc_mode == 1) ? "AM" : (rlc_mode == 2) ? "TM" : "UM"); - } - break; - case ACTION_REMOVE: - DevAssert(pdcp != NULL); - pdcp->instanciated_instance = 0; - pdcp->lcid = 0; - pdcp->header_compression_profile = 0x0; - pdcp->cipheringAlgorithm = 0xff; - pdcp->integrityProtAlgorithm = 0xff; - pdcp->status_report = 0; - pdcp->rlc_mode = RLC_NONE; - pdcp->next_pdcp_tx_sn = 0; - pdcp->next_pdcp_rx_sn = 0; - pdcp->tx_hfn = 0; - pdcp->rx_hfn = 0; - pdcp->last_submitted_pdcp_rx_sn = 4095; - pdcp->seq_num_size = 0; - pdcp->first_missing_pdu = -1; - pdcp->security_activated = 0; - - if (eNB_flag == 0) { + "RB id %d configured with SN size %d and RLC %s \n", + enb_mod_idP, ue_mod_idP, frameP, lc_idP, rb_idP, rb_snP, + (rlc_modeP == 1) ? "AM" : (rlc_modeP == 2) ? "TM" : "UM"); + } + break; + case ACTION_REMOVE: + DevAssert(pdcp_pP != NULL); + pdcp_pP->instanciated_instance = 0; + pdcp_pP->lcid = 0; + pdcp_pP->header_compression_profile = 0x0; + pdcp_pP->cipheringAlgorithm = 0xff; + pdcp_pP->integrityProtAlgorithm = 0xff; + pdcp_pP->status_report = 0; + pdcp_pP->rlc_mode = RLC_NONE; + pdcp_pP->next_pdcp_tx_sn = 0; + pdcp_pP->next_pdcp_rx_sn = 0; + pdcp_pP->tx_hfn = 0; + pdcp_pP->rx_hfn = 0; + pdcp_pP->last_submitted_pdcp_rx_sn = 4095; + pdcp_pP->seq_num_size = 0; + pdcp_pP->first_missing_pdu = -1; + pdcp_pP->security_activated = 0; + + if (enb_flagP == 0) { LOG_I(PDCP, "[UE %d] Config request : ACTION_REMOVE for eNB %d: Frame %d LCID %d RBID %d configured\n", - UE_id, eNB_id, frame, lc_id, rb_id); - } else { + ue_mod_idP, enb_mod_idP, frameP, lc_idP, rb_idP); + } else { LOG_I(PDCP, "[eNB %d] Config request : ACTION_REMOVE for UE %d: Frame %d LCID %d RBID %d configured\n", - eNB_id, UE_id, frame, lc_id, rb_id); - } - /* Security keys */ - if (pdcp->kUPenc != NULL) { - free(pdcp->kUPenc); - } - if (pdcp->kRRCint != NULL) { - free(pdcp->kRRCint); - } - if (pdcp->kRRCenc != NULL) { - free(pdcp->kRRCenc); - } - break; - case ACTION_MBMS_ADD: - case ACTION_MBMS_MODIFY: - if (eNB_flag == 0) { - module_id = UE_id + NB_eNB_INST; + enb_mod_idP, ue_mod_idP, frameP, lc_idP, rb_idP); + } + /* Security keys */ + if (pdcp_pP->kUPenc != NULL) { + free(pdcp_pP->kUPenc); + } + if (pdcp_pP->kRRCint != NULL) { + free(pdcp_pP->kRRCint); + } + if (pdcp_pP->kRRCenc != NULL) { + free(pdcp_pP->kRRCenc); + } + break; + case ACTION_MBMS_ADD: + case ACTION_MBMS_MODIFY: + if (enb_flagP == 0) { LOG_I(PDCP,"[UE %d] Config request for eNB %d: %s: Frame %d service_id/mch index %d, session_id/lcid %d, rbid %d configured\n", - UE_id, eNB_id, action == ACTION_MBMS_ADD ? "ACTION_MBMS_ADD" : "ACTION_MBMS_MODIFY", frame, mch_id, lc_id, rb_id); - } else { - module_id = eNB_id; + ue_mod_idP, enb_mod_idP, actionP == ACTION_MBMS_ADD ? "ACTION_MBMS_ADD" : "ACTION_MBMS_MODIFY", frameP, mch_idP, lc_idP, rb_idP); + } else { LOG_I(PDCP,"[eNB %d] Config request for UE %d: %s: Frame %d service_id/mch index %d, session_id/lcid %d, rbid %d configured\n", - eNB_id, UE_id, action == ACTION_MBMS_ADD ? "ACTION_MBMS_ADD" : "ACTION_MBMS_MODIFY", frame, mch_id, lc_id, rb_id); - } - pdcp_mbms_array[module_id][rb_id].instanciated_instance = module_id + 1 ; - pdcp_mbms_array[module_id][rb_id].service_id = mch_id; - pdcp_mbms_array[module_id][rb_id].session_id = lc_id; - pdcp_mbms_array[module_id][rb_id].rb_id = rb_id; - break; - case ACTION_SET_SECURITY_MODE: - pdcp_config_set_security(pdcp, eNB_id, UE_id, frame, eNB_flag, rb_id, lc_id, security_mode, kRRCenc, kRRCint, kUPenc); - break; - default: - DevParam(action, eNB_id, UE_id); - break; + enb_mod_idP, ue_mod_idP, actionP == ACTION_MBMS_ADD ? "ACTION_MBMS_ADD" : "ACTION_MBMS_MODIFY", frameP, mch_idP, lc_idP, rb_idP); + } + if (enb_flagP == 1) { + pdcp_mbms_array_eNB[enb_mod_idP][rb_idP].instanciated_instance = 1 ; + pdcp_mbms_array_eNB[enb_mod_idP][rb_idP].service_id = mch_idP; + pdcp_mbms_array_eNB[enb_mod_idP][rb_idP].session_id = lc_idP; + pdcp_mbms_array_eNB[enb_mod_idP][rb_idP].rb_id = rb_idP; + } else { + pdcp_mbms_array_eNB[ue_mod_idP][rb_idP].instanciated_instance = 1 ; + pdcp_mbms_array_eNB[ue_mod_idP][rb_idP].service_id = mch_idP; + pdcp_mbms_array_eNB[ue_mod_idP][rb_idP].session_id = lc_idP; + pdcp_mbms_array_eNB[ue_mod_idP][rb_idP].rb_id = rb_idP; + } + break; + case ACTION_SET_SECURITY_MODE: + pdcp_config_set_security(pdcp_pP, enb_mod_idP, ue_mod_idP, frameP, enb_flagP, rb_idP, lc_idP, security_modeP, kRRCenc_pP, kRRCint_pP, kUPenc_pP); + break; + default: + DevParam(actionP, enb_mod_idP, ue_mod_idP); + break; } return 0; } -void pdcp_config_set_security(pdcp_t *pdcp, u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, rb_id_t rb_id, - u16 lc_id, u8 security_mode, u8 *kRRCenc, u8 *kRRCint, u8 *kUPenc) +void pdcp_config_set_security(pdcp_t *pdcp_pP, + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flag, + rb_id_t rb_idP, + u16 lc_idP, + u8 security_modeP, + u8 *kRRCenc, + u8 *kRRCint, + u8 *kUPenc) { - DevAssert(pdcp != NULL); + DevAssert(pdcp_pP != NULL); - if ((security_mode >= 0) && (security_mode <= 0x77)) { - pdcp->cipheringAlgorithm = security_mode & 0x0f; - pdcp->integrityProtAlgorithm = (security_mode>>4) & 0xf; + if ((security_modeP >= 0) && (security_modeP <= 0x77)) { + pdcp_pP->cipheringAlgorithm = security_modeP & 0x0f; + pdcp_pP->integrityProtAlgorithm = (security_modeP>>4) & 0xf; - if (eNB_flag == 0) { - LOG_D(PDCP,"[UE %d][RB %02d] Set security mode : ACTION_SET_SECURITY_MODE: " - "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - UE_id, rb_id, frame, pdcp->cipheringAlgorithm, pdcp->integrityProtAlgorithm); - } else { - LOG_D(PDCP,"[eNB %d][UE %d][RB %02d] Set security mode : ACTION_SET_SECURITY_MODE: " - "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - eNB_id, UE_id, rb_id, frame, pdcp->cipheringAlgorithm, pdcp->integrityProtAlgorithm); - } - pdcp->kRRCenc = kRRCenc; - pdcp->kRRCint = kRRCint; - pdcp->kUPenc = kUPenc; + if (eNB_flag == 0) { + LOG_D(PDCP,"[UE %d][RB %02d] Set security mode : ACTION_SET_SECURITY_MODE: " + "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", + ue_mod_idP, rb_idP, frameP, pdcp_pP->cipheringAlgorithm, pdcp_pP->integrityProtAlgorithm); + } else { + LOG_D(PDCP,"[eNB %d][UE %d][RB %02d] Set security mode : ACTION_SET_SECURITY_MODE: " + "Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", + enb_mod_idP, ue_mod_idP, rb_idP, frameP, pdcp_pP->cipheringAlgorithm, pdcp_pP->integrityProtAlgorithm); + } + pdcp_pP->kRRCenc = kRRCenc; + pdcp_pP->kRRCint = kRRCint; + pdcp_pP->kUPenc = kUPenc; - /* Activate security */ - pdcp->security_activated = 1; + /* Activate security */ + pdcp_pP->security_activated = 1; } else { - LOG_E(PDCP,"[%s %d] bad security mode %d", security_mode); + LOG_E(PDCP,"[%s %d] bad security mode %d", security_modeP); } } -void rrc_pdcp_config_req (u8 eNB_id, u8 UE_id, u32 frame, u8_t eNB_flag, u32 action, rb_id_t rb_id, u8 security_mode) +void rrc_pdcp_config_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t enb_flagP, u32 actionP, rb_id_t rb_idP, u8 security_modeP) { - pdcp_t *pdcp; - module_id_t module_id; + pdcp_t *pdcp_p = NULL; - if (eNB_flag == 0) { - pdcp = &pdcp_array_ue[UE_id][rb_id]; - module_id = NB_eNB_INST + UE_id; + if (enb_mod_idP == 0) { + pdcp_p = &pdcp_array_ue[ue_mod_idP][rb_idP]; } else { - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; - module_id = eNB_id; + pdcp_p = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP]; } /* - * Initialize sequence number state variables of relevant PDCP entity - */ - switch (action) { - case ACTION_ADD: - pdcp->instanciated_instance = 1; - - pdcp->next_pdcp_tx_sn = 0; - pdcp->next_pdcp_rx_sn = 0; - pdcp->tx_hfn = 0; - pdcp->rx_hfn = 0; - /* SN of the last PDCP SDU delivered to upper layers */ - pdcp->last_submitted_pdcp_rx_sn = 4095; - - if (rb_id < DTCH) { // SRB - pdcp->seq_num_size = 5; - } else { // DRB - pdcp->seq_num_size = 12; - } - pdcp->first_missing_pdu = -1; - LOG_D(PDCP,"[%s %d] Config request : Action ADD: Frame %d radio bearer id %d configured\n", - (eNB_flag) ? "eNB" : "UE", module_id, frame, rb_id); - LOG_D(PDCP, "[MSC_NEW][FRAME %05d][PDCP][MOD %02d][RB %02d]\n", frame, module_id,rb_id); - break; - case ACTION_MODIFY: - break; - case ACTION_REMOVE: - pdcp->instanciated_instance = 0; - pdcp->next_pdcp_tx_sn = 0; - pdcp->next_pdcp_rx_sn = 0; - pdcp->tx_hfn = 0; - pdcp->rx_hfn = 0; - pdcp->last_submitted_pdcp_rx_sn = 4095; - pdcp->seq_num_size = 0; - pdcp->first_missing_pdu = -1; - pdcp->security_activated = 0; - LOG_D(PDCP,"[%s %d] Config request : ACTION_REMOVE: Frame %d radio bearer id %d configured\n", - (eNB_flag) ? "eNB" : "UE", module_id, frame, rb_id); - - break; - case ACTION_SET_SECURITY_MODE: - if ((security_mode >= 0) && (security_mode <= 0x77)) { - pdcp->cipheringAlgorithm= security_mode & 0x0f; - pdcp->integrityProtAlgorithm = (security_mode>>4) & 0xf; + * Initialize sequence number state variables of relevant PDCP entity + */ + switch (actionP) { + case ACTION_ADD: + pdcp_p->instanciated_instance = 1; + + pdcp_p->next_pdcp_tx_sn = 0; + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->tx_hfn = 0; + pdcp_p->rx_hfn = 0; + /* SN of the last PDCP SDU delivered to upper layers */ + pdcp_p->last_submitted_pdcp_rx_sn = 4095; + + if (rb_idP < DTCH) { // SRB + pdcp_p->seq_num_size = 5; + } else { // DRB + pdcp_p->seq_num_size = 12; + } + pdcp_p->first_missing_pdu = -1; + LOG_D(PDCP,"[%s %d] Config request : Action ADD: Frame %d radio bearer id %d configured\n", + (enb_flagP) ? "eNB" : "UE", (enb_flagP) ? enb_mod_idP : ue_mod_idP, frameP, rb_idP); + break; + case ACTION_MODIFY: + break; + case ACTION_REMOVE: + pdcp_p->instanciated_instance = 0; + pdcp_p->next_pdcp_tx_sn = 0; + pdcp_p->next_pdcp_rx_sn = 0; + pdcp_p->tx_hfn = 0; + pdcp_p->rx_hfn = 0; + pdcp_p->last_submitted_pdcp_rx_sn = 4095; + pdcp_p->seq_num_size = 0; + pdcp_p->first_missing_pdu = -1; + pdcp_p->security_activated = 0; + LOG_D(PDCP,"[%s %d] Config request : ACTION_REMOVE: Frame %d radio bearer id %d configured\n", + (enb_flagP) ? "eNB" : "UE", (enb_flagP) ? enb_mod_idP : ue_mod_idP, frameP, rb_idP); + + break; + case ACTION_SET_SECURITY_MODE: + if ((security_modeP >= 0) && (security_modeP <= 0x77)) { + pdcp_p->cipheringAlgorithm= security_modeP & 0x0f; + pdcp_p->integrityProtAlgorithm = (security_modeP>>4) & 0xf; LOG_D(PDCP,"[%s %d]Set security mode : ACTION_SET_SECURITY_MODE: Frame %d cipheringAlgorithm %d integrityProtAlgorithm %d\n", - (eNB_flag) ? "eNB" : "UE", module_id, frame, - pdcp->cipheringAlgorithm, - pdcp->integrityProtAlgorithm ); - } else { - LOG_D(PDCP,"[%s %d] bad security mode %d", security_mode); - } - break; - default: - DevParam(action, UE_id, eNB_id); - break; + (enb_flagP) ? "eNB" : "UE", (enb_flagP) ? enb_mod_idP : ue_mod_idP, frameP, + pdcp_p->cipheringAlgorithm, + pdcp_p->integrityProtAlgorithm ); + } else { + LOG_D(PDCP,"[%s %d] bad security mode %d", security_modeP); + } + break; + default: + DevParam(actionP, ue_mod_idP, enb_mod_idP); + break; } } // TODO PDCP module initialization code might be removed -int - pdcp_module_init () -{ +int pdcp_module_init (void) { //----------------------------------------------------------------------------- #ifdef NAS_FIFO int ret; @@ -1142,23 +1164,23 @@ int ret=rtf_create(PDCP2NAS_FIFO,32768); if (ret < 0) { - LOG_E(PDCP, "Cannot create PDCP2NAS fifo %d (ERROR %d)\n", PDCP2NAS_FIFO, ret); + LOG_E(PDCP, "Cannot create PDCP2NAS fifo %d (ERROR %d)\n", PDCP2NAS_FIFO, ret); - return -1; + return -1; } else { - LOG_D(PDCP, "Created PDCP2NAS fifo %d\n", PDCP2NAS_FIFO); - rtf_reset(PDCP2NAS_FIFO); + LOG_D(PDCP, "Created PDCP2NAS fifo %d\n", PDCP2NAS_FIFO); + rtf_reset(PDCP2NAS_FIFO); } ret=rtf_create(NAS2PDCP_FIFO,32768); if (ret < 0) { - LOG_E(PDCP, "Cannot create NAS2PDCP fifo %d (ERROR %d)\n", NAS2PDCP_FIFO, ret); + LOG_E(PDCP, "Cannot create NAS2PDCP fifo %d (ERROR %d)\n", NAS2PDCP_FIFO, ret); - return -1; + return -1; } else { - LOG_D(PDCP, "Created NAS2PDCP fifo %d\n", NAS2PDCP_FIFO); - rtf_reset(NAS2PDCP_FIFO); + LOG_D(PDCP, "Created NAS2PDCP fifo %d\n", NAS2PDCP_FIFO); + rtf_reset(NAS2PDCP_FIFO); } pdcp_2_nas_irq = 0; @@ -1171,9 +1193,8 @@ int } //----------------------------------------------------------------------------- -void - pdcp_module_cleanup () - //----------------------------------------------------------------------------- +void pdcp_module_cleanup (void) +//----------------------------------------------------------------------------- { #ifdef NAS_FIFO rtf_destroy(NAS2PDCP_FIFO); @@ -1184,17 +1205,33 @@ void //----------------------------------------------------------------------------- void pdcp_layer_init(void) { -//----------------------------------------------------------------------------- - + //----------------------------------------------------------------------------- + module_id_t instance, instance2; + rb_id_t rb_id; + int j; /* - * Initialize SDU list - */ + * Initialize SDU list + */ list_init(&pdcp_sdu_list, NULL); - memset(pdcp_array_ue, 0, sizeof(pdcp_array_ue)); - memset(pdcp_array_eNB, 0, sizeof(pdcp_array_eNB)); - - memset((void*)&pdcp_mbms_array, 0, sizeof(pdcp_mbms_array)); + for (instance = 0; instance < NUMBER_OF_UE_MAX; instance++) { + for (rb_id = 0; rb_id < NB_RB_MAX; rb_id++) { + memset(&pdcp_array_ue[instance][rb_id], 0, sizeof(pdcp_t)); + } + for (j = 0; j < 16*29; j++) { + memset(&pdcp_mbms_array_ue[instance][j], 0, sizeof(pdcp_mbms_t)); + } + } + for (instance = 0; instance < NUMBER_OF_eNB_MAX; instance++) { + for (instance2 = 0; instance2 < NUMBER_OF_UE_MAX; instance2++) { + for (rb_id = 0; rb_id < NB_RB_MAX; rb_id++) { + memset(&pdcp_array_eNB[instance][instance2][rb_id], 0, sizeof(pdcp_t)); + } + } + for (j = 0; j < 16*29; j++) { + memset(&pdcp_mbms_array_eNB[instance][j], 0, sizeof(pdcp_mbms_t)); + } + } LOG_I(PDCP, "PDCP layer has been initialized\n"); @@ -1202,26 +1239,6 @@ void pdcp_layer_init(void) pdcp_output_header_bytes_to_write=0; pdcp_input_sdu_remaining_size_to_read=0; - /* - * Initialize PDCP entities (see pdcp_t at pdcp.h) - */ - // set RB for eNB : this is now down by RRC for each mod id and rab id when needed. - /* for (i=0;i < NB_eNB_INST; i++) { - for (j=NB_eNB_INST; j < NB_eNB_INST+NB_UE_INST; j++ ) { - pdcp_config_req(i, (j-NB_eNB_INST) * NB_RB_MAX + DCCH, DCCH ); // default DRB - pdcp_config_req(i, (j-NB_eNB_INST) * NB_RB_MAX + DCCH1, DCCH1 ); // default DRB - pdcp_config_req(i, (j-NB_eNB_INST) * NB_RB_MAX + DTCH, DTCH ); // default DRB - } - } - // set RB for UE - for (i=NB_eNB_INST;i<NB_eNB_INST+NB_UE_INST; i++) { - for (j=0;j<NB_eNB_INST; j++) { - pdcp_config_req(i, j * NB_RB_MAX + DCCH, DCCH ); // default DRB - pdcp_config_req(i, j * NB_RB_MAX + DCCH1, DCCH1 ); // default DRB - pdcp_config_req(i, j * NB_RB_MAX + DTCH, DTCH ); // default DRB - } - }*/ - memset(Pdcp_stats_tx, 0, sizeof(Pdcp_stats_tx)); memset(Pdcp_stats_tx_bytes, 0, sizeof(Pdcp_stats_tx_bytes)); memset(Pdcp_stats_tx_bytes_last, 0, sizeof(Pdcp_stats_tx_bytes_last)); @@ -1234,9 +1251,8 @@ void pdcp_layer_init(void) } //----------------------------------------------------------------------------- -void - pdcp_layer_cleanup (void) - //----------------------------------------------------------------------------- +void pdcp_layer_cleanup (void) +//----------------------------------------------------------------------------- { list_free (&pdcp_sdu_list); } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h index 4e15e1a0c865506d4922912758786fef34eb2e88..54d9e13255b2bb2f422566e2e838bf3ee8672b3c 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.h @@ -185,43 +185,7 @@ typedef struct pdcp_mbms_t { * XXX And later this should be configured through the Makefile * under targets/TEST/PDCP/ */ -#undef PDCP_UNIT_TEST -#ifdef PDCP_UNIT_TEST -/*! \fn BOOL pdcp_data_req(module_id_t, u32_t, u8_t, rb_id_t, sdu_size_t, unsigned char*, pdcp_t*, list_t*) -* \brief This functions handles data transfer requests coming from test code (see below for actual code) -* \param[in] module_id Module ID -* \param[in] frame Frame number -* \param[in] Shows if relevant PDCP entity is part of an eNB or a UE -* \param[in] rab_id Radio Bearer ID -* \param[in] sdu_buffer_size Size of incoming SDU in bytes -* \param[in] sdu_buffer Buffer carrying SDU -* \param[in] test_pdcp_entity PDCP entity used for testing purposes -* \param[in] test_list list_t used for testing purposes -* \param[out] test_list Newly created PDU is enqueued into the list -* \param[out] test_pdcp PDCP sequence numbering state is updated -* \return TRUE on success, FALSE otherwise -* \note None -* @ingroup _pdcp -*/ -public_pdcp(BOOL pdcp_data_req (module_id_t module_id, u32_t frame, u8_t eNB_flag, rb_id_t rab_id, sdu_size_t sdu_buffer_size, unsigned char* sdu_buffer, pdcp_t* test_pdcp_entity, list_t* test_list);) -/*! \fn BOOL pdcp_data_ind(module_id_t, u32_t, u8_t, rb_id_t, sdu_size_t, unsigned char*) -* \brief This functions handles data transfer indications coming from test code (see below for actual code) -* \param[in] module_id Module ID -* \param[in] frame Frame number -* \param[in] Shows if relevant PDCP entity is part of an eNB or a UE -* \param[in] rab_id Radio Bearer ID -* \param[in] sdu_buffer_size Size of incoming SDU in bytes -* \param[in] sdu_buffer Buffer carrying SDU -* \param[in] test_list Incoming PDU is received/dequeued from this list -* \param[in] test_pdcp_entity PDCP entity used for testing purposes -* \return TRUE on success, FALSE otherwise -* \note None -* @ingroup _pdcp -*/ -public_pdcp(BOOL pdcp_data_ind (module_id_t module_id, u32_t frame, u8_t eNB_flag, rb_id_t rab_id, sdu_size_t sdu_buffer_size, \ - mem_block_t* sdu_buffer, pdcp_t* test_pdcp_entity, list_t* test_list);) -#else /*! \fn BOOL pdcp_data_req(module_id_t, u32_t, u8_t, rb_id_t, sdu_size_t, unsigned char*) * \brief This functions handles data transfer requests coming either from RRC or from IP * \param[in] module_id Module ID @@ -237,10 +201,10 @@ public_pdcp(BOOL pdcp_data_ind (module_id_t module_id, u32_t frame, u8_t eNB_fla * \note None * @ingroup _pdcp */ -public_pdcp(BOOL pdcp_data_req(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_id, u32 muiP, u32 confirmP, \ +public_pdcp(BOOL pdcp_data_req(module_id_t eNB_id, module_id_t UE_id, frame_t frame, eNB_flag_t eNB_flag, rb_id_t rb_id, mui_t muiP, u32 confirmP, \ sdu_size_t sdu_buffer_size, unsigned char* sdu_buffer, u8 mode)); -/*! \fn BOOL pdcp_data_ind(module_id_t, u32_t, u8_t, u8_t, rb_id_t, sdu_size_t, unsigned char*) +/*! \fn BOOL pdcp_data_ind(module_id_t, module_id_t, u32_t, u8_t, u8_t, rb_id_t, sdu_size_t, unsigned char*) * \brief This functions handles data transfer indications coming from RLC * \param[in] module_id Module ID * \param[in] frame Frame number @@ -254,9 +218,8 @@ public_pdcp(BOOL pdcp_data_req(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, * \note None * @ingroup _pdcp */ -public_pdcp(BOOL pdcp_data_ind(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, rb_id_t rb_id, sdu_size_t sdu_buffer_size, +public_pdcp(BOOL pdcp_data_ind(module_id_t eNB_id, module_id_t UE_id, frame_t frame, eNB_flag_t eNB_flag, u8_t MBMS_flagP, rb_id_t rb_id, sdu_size_t sdu_buffer_size, mem_block_t* sdu_buffer, u8 is_data_plane)); -#endif // PDCP_UNIT_TEST /*! \fn void rrc_pdcp_config_req(module_id_t, rb_id_t,u8) * \brief This functions initializes relevant PDCP entity @@ -269,9 +232,15 @@ public_pdcp(BOOL pdcp_data_ind(u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, * \note None * @ingroup _pdcp */ -public_pdcp(void rrc_pdcp_config_req (u8 eNB_id, u8 UE_id, u32 frame, u8_t eNB_flag, u32 action, rb_id_t rb_id, u8 security_mode);) - -/*! \fn bool rrc_pdcp_config_asn1_req (module_id_t module_id, u32_t frame, u8_t eNB_flag, SRB_ToAddModList_t* srb2add_list, DRB_ToAddModList_t* drb2add_list, DRB_ToReleaseList_t* drb2release_list) +public_pdcp(void rrc_pdcp_config_req (module_id_t enb_idP, + module_id_t ue_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + u32 actionP, + rb_id_t rb_idP, + u8 security_modeP);) + +/*! \fn bool rrc_pdcp_config_asn1_req (module_id_t module_id, frame_t frame, eNB_flag_t eNB_flag, SRB_ToAddModList_t* srb2add_list, DRB_ToAddModList_t* drb2add_list, DRB_ToReleaseList_t* drb2release_list) * \brief Function for RRC to configure a Radio Bearer. * \param[in] module_id Virtualized module identifier. * \param[in] frame Frame index. @@ -287,20 +256,23 @@ public_pdcp(void rrc_pdcp_config_req (u8 eNB_id, u8 UE_id, u32 frame, u8_t eNB_f * \return A status about the processing, OK or error code. */ public_pdcp( -BOOL rrc_pdcp_config_asn1_req (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, - SRB_ToAddModList_t* srb2add_list, - DRB_ToAddModList_t* drb2add_list, - DRB_ToReleaseList_t* drb2release_list, - u8 security_mode, - u8 *kRRCenc, - u8 *kRRCint, - u8 *kUPenc +BOOL rrc_pdcp_config_asn1_req (module_id_t eNB_idP, + module_id_t ue_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + SRB_ToAddModList_t *srb2add_list, + DRB_ToAddModList_t *drb2add_list, + DRB_ToReleaseList_t *drb2release_list, + u8 security_modeP, + u8 *kRRCenc, + u8 *kRRCint, + u8 *kUPenc #ifdef Rel10 - ,PMCH_InfoList_r9_t* pmch_InfoList_r9 + ,PMCH_InfoList_r9_t *pmch_InfoList_r9 #endif )); -/*! \fn BOOL pdcp_config_req_asn1 (module_id_t module_id, u32 frame, u8_t eNB_flag, u32 action, rb_id_t rb_id, u8 rb_sn, u8 rb_report, u16 header_compression_profile, u8 security_mode) +/*! \fn BOOL pdcp_config_req_asn1 (module_id_t module_id, frame_t frame, eNB_flag_t eNB_flag, u32 action, rb_id_t rb_id, u8 rb_sn, u8 rb_report, u16 header_compression_profile, u8 security_mode) * \brief Function for RRC to configure a Radio Bearer. * \param[in] module_id Virtualized module identifier. * \param[in] frame Frame index. @@ -316,13 +288,23 @@ BOOL rrc_pdcp_config_asn1_req (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, * \param[in] kUPenc User-Plane encryption key * \return A status about the processing, OK or error code. */ -public_pdcp(BOOL pdcp_config_req_asn1 (pdcp_t *pdcp, u8 eNB_id, u8 UE_id, u32 frame, u8_t eNB_flag, - rlc_mode_t rlc_mode, u32 action, u16 lc_id, u16 mch_id, rb_id_t rb_id, - u8 rb_sn, u8 rb_report, u16 header_compression_profile, - u8 security_mode, - u8 *kRRCenc, - u8 *kRRCint, - u8 *kUPenc)); +public_pdcp(BOOL pdcp_config_req_asn1 (pdcp_t *pdcp_pP, + module_id_t enb_idP, + module_id_t ue_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rlc_mode_t rlc_mode, + u32 action, + u16 lc_id, + u16 mch_id, + rb_id_t rb_id, + u8 rb_sn, + u8 rb_report, + u16 header_compression_profile, + u8 security_mode, + u8 *kRRCenc, + u8 *kRRCint, + u8 *kUPenc)); /*! \fn void rrc_pdcp_config_release(module_id_t, rb_id_t) * \brief This functions is unused * \param[in] module_id Module ID of relevant PDCP entity @@ -341,20 +323,20 @@ public_pdcp(BOOL pdcp_config_req_asn1 (pdcp_t *pdcp, u8 eNB_id, u8 UE_id, u32 fr * \note None * @ingroup _pdcp */ -public_pdcp(void pdcp_run (u32_t frame, u8_t eNB_flag, u8 UE_index,u8 eNB_index);) -public_pdcp(int pdcp_module_init ();) -public_pdcp(void pdcp_module_cleanup ();) -public_pdcp(void pdcp_layer_init ();) -public_pdcp(void pdcp_layer_cleanup ();) -public_pdcp(int pdcp_netlink_init(void);) +public_pdcp(void pdcp_run (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP);) +public_pdcp(int pdcp_module_init (void);) +public_pdcp(void pdcp_module_cleanup (void);) +public_pdcp(void pdcp_layer_init (void);) +public_pdcp(void pdcp_layer_cleanup (void);) +public_pdcp(int pdcp_netlink_init (void);) #define PDCP2NAS_FIFO 21 #define NAS2PDCP_FIFO 22 -protected_pdcp_fifo(int pdcp_fifo_flush_sdus(u32_t frame, u8 eNB_flag, u8 eNB_id, u8 UE_id);) -protected_pdcp_fifo(int pdcp_fifo_read_input_sdus_remaining_bytes (u32_t,u8_t);) -protected_pdcp_fifo(int pdcp_fifo_read_input_sdus (u32_t frame, u8_t eNB_flag, u8_t UE_index, u8_t eNB_index);) -protected_pdcp_fifo(void pdcp_fifo_read_input_sdus_from_otg (u32_t frame, u8_t eNB_flag, u8 UE_index, u8 eNB_index);) +protected_pdcp_fifo(int pdcp_fifo_flush_sdus (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t enb_idP, module_id_t ue_mod_idP);) +protected_pdcp_fifo(int pdcp_fifo_read_input_sdus_remaining_bytes (frame_t frameP, eNB_flag_t eNB_flagP);) +protected_pdcp_fifo(int pdcp_fifo_read_input_sdus (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP);) +protected_pdcp_fifo(void pdcp_fifo_read_input_sdus_from_otg (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP);) //----------------------------------------------------------------------------- @@ -362,20 +344,19 @@ protected_pdcp_fifo(void pdcp_fifo_read_input_sdus_from_otg (u32_t frame, u8_t e * Following two types are utilized between NAS driver and PDCP */ -typedef int traffic_type_t; typedef struct pdcp_data_req_header_s { rb_id_t rb_id; sdu_size_t data_size; - int inst; + signed int inst; traffic_type_t traffic_type; } pdcp_data_req_header_t; typedef struct pdcp_data_ind_header_s { rb_id_t rb_id; sdu_size_t data_size; - int inst; - int dummy; + signed int inst; + traffic_type_t dummy_traffic_type; } pdcp_data_ind_header_t; struct pdcp_netlink_element_s { @@ -406,7 +387,8 @@ typedef struct pdcp_missing_pdu_info_t { protected_pdcp(signed int pdcp_2_nas_irq;) protected_pdcp(pdcp_t pdcp_array_ue[NUMBER_OF_UE_MAX][NB_RB_MAX];) protected_pdcp(pdcp_t pdcp_array_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][NB_RB_MAX];) -public_pdcp(pdcp_mbms_t pdcp_mbms_array[MAX_MODULES][16*29];) // MAX_SERVICEx MAX_SESSION +public_pdcp(pdcp_mbms_t pdcp_mbms_array_ue[NUMBER_OF_UE_MAX][16*29];) // MAX_SERVICEx MAX_SESSION +public_pdcp(pdcp_mbms_t pdcp_mbms_array_eNB[NUMBER_OF_eNB_MAX][16*29];) // MAX_SERVICEx MAX_SESSION protected_pdcp(sdu_size_t pdcp_output_sdu_bytes_to_write;) protected_pdcp(sdu_size_t pdcp_output_header_bytes_to_write;) protected_pdcp(list_t pdcp_sdu_list;) diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index c97f3c85373083c26bc1008eb374f1bf02214bf5..19171b653bb66e1d2563f135d09dbe086955e635 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -12,7 +12,6 @@ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. @@ -25,16 +24,16 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file pdcp_fifo.c -* \brief pdcp interface with linux IP interface, have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink -* \author Lionel GAUTHIER and Navid Nikaein -* \date 2009 -* \version 0.5 -* \warning This component can be runned only in user-space -* @ingroup pdcp -*/ + * \brief pdcp interface with linux IP interface, have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink + * \author Lionel GAUTHIER and Navid Nikaein + * \date 2009 + * \version 0.5 + * \warning This component can be runned only in user-space + * @ingroup pdcp + */ #define PDCP_FIFO_C #define PDCP_DEBUG 1 @@ -87,174 +86,173 @@ extern struct msghdr nas_msg_rx; #define MAX_PAYLOAD 1600 -unsigned char pdcp_read_state = 0; +unsigned char pdcp_read_state_g = 0; //unsigned char pdcp_read_payload[MAX_PAYLOAD]; #endif extern Packet_OTG_List *otg_pdcp_buffer; -pdcp_data_req_header_t pdcp_read_header; +pdcp_data_req_header_t pdcp_read_header_g; //----------------------------------------------------------------------------- -int pdcp_fifo_flush_sdus(u32_t frame, u8 eNB_flag, u8 eNB_id, u8 UE_id) +int pdcp_fifo_flush_sdus(frame_t frameP, eNB_flag_t eNB_flagP, module_id_t enb_mod_idP, module_id_t ue_mod_idP) { //----------------------------------------------------------------------------- - mem_block_t *sdu = list_get_head (&pdcp_sdu_list); - int bytes_wrote = 0; - int pdcp_nb_sdu_sent = 0; - u8 cont = 1; - int mcs_inst; + mem_block_t *sdu_p = list_get_head (&pdcp_sdu_list); + int bytes_wrote = 0; + int pdcp_nb_sdu_sent = 0; + u8 cont = 1; #if defined(NAS_NETLINK) && defined(LINUX) int ret = 0; #endif - while (sdu && cont) { + while (sdu_p && cont) { #if defined(OAI_EMU) - mcs_inst = ((pdcp_data_ind_header_t *)(sdu->data))->inst; - // asjust the instance id when passing sdu to IP - ((pdcp_data_ind_header_t *)(sdu->data))->inst = (((pdcp_data_ind_header_t *)(sdu->data))->inst >= NB_eNB_INST) ? - ((pdcp_data_ind_header_t *)(sdu->data))->inst - NB_eNB_INST +oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local :// UE - ((pdcp_data_ind_header_t *)(sdu->data))->inst - oai_emulation.info.first_ue_local; // ENB + //LGmcs_inst = ((pdcp_data_ind_header_t *)(sdu->data))->inst; + // asjust the instance id when passing sdu to IP + //((pdcp_data_ind_header_t *)(sdu->data))->inst = (((pdcp_data_ind_header_t *)(sdu->data))->inst >= NB_eNB_INST) ? + // ((pdcp_data_ind_header_t *)(sdu->data))->inst - NB_eNB_INST +oai_emulation.info.nb_enb_local - oai_emulation.info.first_ue_local :// UE + // ((pdcp_data_ind_header_t *)(sdu->data))->inst - oai_emulation.info.first_ue_local; // ENB #else - ((pdcp_data_ind_header_t *)(sdu->data))->inst = 0; + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0; #endif #ifdef PDCP_DEBUG - LOG_I(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", - frame, ((pdcp_data_ind_header_t *)(sdu->data))->inst, - ((pdcp_data_ind_header_t *)(sdu->data))->data_size, ((pdcp_data_ind_header_t *)(sdu->data))->rb_id); + LOG_I(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n", + frameP, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); #endif //PDCP_DEBUG - cont = 0; + cont = 0; - if (!pdcp_output_sdu_bytes_to_write) { - if (!pdcp_output_header_bytes_to_write) { - pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); - } + if (!pdcp_output_sdu_bytes_to_write) { + if (!pdcp_output_header_bytes_to_write) { + pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t); + } #ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, - &(((u8 *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); + bytes_wrote = rtf_put (PDCP2NAS_FIFO, + &(((u8 *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + pdcp_output_header_bytes_to_write); #else #ifdef NAS_NETLINK #ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh_tx), &(((u8 *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), - pdcp_output_header_bytes_to_write); - nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; + memcpy(NLMSG_DATA(nas_nlh_tx), &(((u8 *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]), + pdcp_output_header_bytes_to_write); + nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write; #endif //LINUX #endif //NAS_NETLINK - bytes_wrote = pdcp_output_header_bytes_to_write; + bytes_wrote = pdcp_output_header_bytes_to_write; #endif //NAS_FIFO #ifdef PDCP_DEBUG - LOG_I(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", - frame, - bytes_wrote); + LOG_I(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n", + frameP, + bytes_wrote); #endif //PDCP_DEBUG - if (bytes_wrote > 0) { - pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; + if (bytes_wrote > 0) { + pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote; - if (!pdcp_output_header_bytes_to_write) { // continue with sdu - pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu->data)->data_size; + if (!pdcp_output_header_bytes_to_write) { // continue with sdu + pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size; #ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); + bytes_wrote = rtf_put (PDCP2NAS_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); #else #ifdef NAS_NETLINK #ifdef LINUX - memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); - nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; - ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); - if (ret<0) { - LOG_D(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno); - mac_xface->macphy_exit("sendmsg failed for nas_sock_fd\n"); - break; - } + memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); + nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; + ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); + if (ret<0) { + LOG_D(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno); + mac_xface->macphy_exit("sendmsg failed for nas_sock_fd\n"); + break; + } #endif // LINUX #endif //NAS_NETLINK - bytes_wrote= pdcp_output_sdu_bytes_to_write; + bytes_wrote= pdcp_output_sdu_bytes_to_write; #endif // NAS_FIFO #ifdef PDCP_DEBUG - LOG_I(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to Nas_mesh\n", - frame, - ((pdcp_data_ind_header_t *)(sdu->data))->inst, - bytes_wrote, - ((pdcp_data_ind_header_t *)(sdu->data))->rb_id); + LOG_I(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to Nas_mesh\n", + frameP, + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + bytes_wrote, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); #endif //PDCP_DEBUG - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP); - LOG_D(PDCP, - "[MSC_MSG][FRAME %05d][PDCP][MOD %02d][RB %02d][--- PDCP_DATA_IND / %d Bytes --->][IP][MOD %02d][]\n", - frame, - mcs_inst, //((pdcp_data_ind_header_t *)(sdu->data))->inst, - ((pdcp_data_ind_header_t *)(sdu->data))->rb_id, - ((pdcp_data_ind_header_t *)(sdu->data))->data_size, - mcs_inst); //((pdcp_data_ind_header_t *)(sdu->data))->inst - - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu = list_get_head (&pdcp_sdu_list); - } - } else { - LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n"); + if (bytes_wrote > 0) { + pdcp_output_sdu_bytes_to_write -= bytes_wrote; + + if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU + // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP); + LOG_D(PDCP, + "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n", + frameP, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id%NB_RB_MAX, + ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, + ((pdcp_data_ind_header_t *)(sdu_p->data))->inst, + ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id); + + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p); + cont = 1; + pdcp_nb_sdu_sent += 1; + sdu_p = list_get_head (&pdcp_sdu_list); + } + } else { + LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n"); + } + } else { + LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n"); + } } - } else { - LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n"); - } - } - } else { - // continue writing sdu + } else { + // continue writing sdu #ifdef NAS_FIFO - bytes_wrote = rtf_put (PDCP2NAS_FIFO, - (u8 *) (&(sdu->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu->data)->data_size - pdcp_output_sdu_bytes_to_write])), - pdcp_output_sdu_bytes_to_write); + bytes_wrote = rtf_put (PDCP2NAS_FIFO, + (u8 *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])), + pdcp_output_sdu_bytes_to_write); #else // NAS_FIFO - bytes_wrote = pdcp_output_sdu_bytes_to_write; + bytes_wrote = pdcp_output_sdu_bytes_to_write; #endif // NAS_FIFO - if (bytes_wrote > 0) { - pdcp_output_sdu_bytes_to_write -= bytes_wrote; - - if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU - //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n"); - list_remove_head (&pdcp_sdu_list); - free_mem_block (sdu); - cont = 1; - pdcp_nb_sdu_sent += 1; - sdu = list_get_head (&pdcp_sdu_list); - // LOG_D(PDCP, "rb sent a sdu from rab\n"); - } + if (bytes_wrote > 0) { + pdcp_output_sdu_bytes_to_write -= bytes_wrote; + + if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU + //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n"); + list_remove_head (&pdcp_sdu_list); + free_mem_block (sdu_p); + cont = 1; + pdcp_nb_sdu_sent += 1; + sdu_p = list_get_head (&pdcp_sdu_list); + // LOG_D(PDCP, "rb sent a sdu from rab\n"); + } + } } - } } #ifdef NAS_FIFO if ((pdcp_nb_sdu_sent)) { - if ((pdcp_2_nas_irq > 0)) { + if ((pdcp_2_nas_irq > 0)) { #ifdef PDCP_DEBUG - LOG_I(PDCP, "Frame %d : Trigger NAS RX interrupt\n", - frame); + LOG_I(PDCP, "Frame %d : Trigger NAS RX interrupt\n", + frameP); #endif //PDCP_DEBUG - rt_pend_linux_srq (pdcp_2_nas_irq); - } else { - LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", - frame, - pdcp_2_nas_irq); - } + rt_pend_linux_srq (pdcp_2_nas_irq); + } else { + LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n", + frameP, + pdcp_2_nas_irq); + } } #endif //NAS_FIFO @@ -267,330 +265,513 @@ int pdcp_fifo_flush_sdus(u32_t frame, u8 eNB_flag, u8 eNB_id, u8 UE_id) * returns zero value if whole bytes that had to be read were not read at all * returns a negative value if an error was encountered while reading the rt fifo */ -int pdcp_fifo_read_input_sdus_remaining_bytes (u32_t frame, u8_t eNB_flag) +int pdcp_fifo_read_input_sdus_remaining_bytes (frame_t frameP, eNB_flag_t eNB_flagP) { //----------------------------------------------------------------------------- sdu_size_t bytes_read = 0; - rb_id_t rab_id = 0; - pdcp_t *pdcp; - u8 UE_id = 0; - u8 eNB_id; - u8 rb_id; - int result; + rb_id_t rab_id = 0; + pdcp_t *pdcp_p = NULL; + module_id_t ue_inst = 0; + module_id_t enb_inst = 0; + rb_id_t rb_id = 0; + int result = -1; // if remaining bytes to read if (pdcp_input_sdu_remaining_size_to_read > 0) { - bytes_read = rtf_get (NAS2PDCP_FIFO, - &(pdcp_input_sdu_buffer[pdcp_input_sdu_size_read]), - pdcp_input_sdu_remaining_size_to_read); + bytes_read = rtf_get (NAS2PDCP_FIFO, + &(pdcp_input_sdu_buffer[pdcp_input_sdu_size_read]), + pdcp_input_sdu_remaining_size_to_read); - if (bytes_read > 0) { - LOG_D(PDCP, "[PDCP_FIFOS] Read %d remaining bytes of data from Nas_mesh\n", bytes_read); + if (bytes_read > 0) { + LOG_D(PDCP, "[PDCP_FIFOS] Read %d remaining bytes of data from Nas_mesh\n", bytes_read); - pdcp_input_sdu_remaining_size_to_read = pdcp_input_sdu_remaining_size_to_read - bytes_read; - pdcp_input_sdu_size_read = pdcp_input_sdu_size_read + bytes_read; + pdcp_input_sdu_remaining_size_to_read = pdcp_input_sdu_remaining_size_to_read - bytes_read; + pdcp_input_sdu_size_read = pdcp_input_sdu_size_read + bytes_read; - if (pdcp_input_sdu_remaining_size_to_read != 0) { - return 0; - } else { + if (pdcp_input_sdu_remaining_size_to_read != 0) { + return 0; + } else { #ifdef PDCP_DEBUG - LOG_I(PDCP, "Frame %d: IP->RADIO RECEIVED COMPLETE SDU size %d inst %d rb %d\n", - frame, - pdcp_input_sdu_size_read, - pdcp_input_header.inst, - pdcp_input_header.rb_id); + LOG_I(PDCP, "Frame %d: IP->RADIO RECEIVED COMPLETE SDU size %d inst %d rb %d\n", + frameP, + pdcp_input_sdu_size_read, + pdcp_input_header.inst, + pdcp_input_header.rb_id); #endif //PDCP_DEBUG - pdcp_input_sdu_size_read = 0; + pdcp_input_sdu_size_read = 0; #ifdef IDROMEL_NEMO - pdcp_read_header.inst = 0; + pdcp_read_header_g.inst = 0; #endif - if (eNB_flag == 0) { - UE_id = pdcp_read_header.inst; - rb_id = pdcp_read_header.rb_id % NB_RB_MAX; - eNB_id = 0; - - DevCheck4(UE_id < NB_UE_INST, UE_id, NB_UE_INST, pdcp_read_header.rb_id, NB_RB_MAX); - DevCheck4(eNB_id < NB_eNB_INST, eNB_id, NB_eNB_INST, pdcp_read_header.rb_id, NB_RB_MAX); - - pdcp = &pdcp_array_ue[UE_id][rb_id]; - } else { - UE_id = pdcp_read_header.rb_id / NB_RB_MAX; - rb_id = pdcp_read_header.rb_id % NB_RB_MAX; - eNB_id = pdcp_read_header.inst; - - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rb_id]; - } - - if (pdcp_input_header.rb_id != 0) { - LOG_D(PDCP, "[MSC_MSG][FRAME %05d][IP][MOD %02d][][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %02d][RB %02d]\n", - frame, pdcp_read_header.inst, pdcp_read_header.data_size, pdcp_read_header.inst, pdcp_read_header.rb_id); - - if (pdcp->instanciated_instance) { - result = pdcp_data_req (eNB_id, UE_id, - frame, eNB_flag, - pdcp_input_header.rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_DATA_PDU); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - - } else if ((pdcp_input_header.traffic_type == OAI_NW_DRV_IPV6_ADDR_TYPE_MULTICAST) || (pdcp_input_header.traffic_type == OAI_NW_DRV_IPV4_ADDR_TYPE_MULTICAST)) { - LOG_D(PDCP, "[MSC_MSG][FRAME %05d][IP][MOD %02d][][--- PDCP_DATA_REQ on MBMS bearer/ %d Bytes --->][PDCP][MOD %02d][RB %02d]\n", - frame, pdcp_read_header.inst, pdcp_read_header.data_size, pdcp_read_header.inst, pdcp_read_header.rb_id); - - if (pdcp->instanciated_instance) { - result = pdcp_data_req (eNB_id, - UE_id, - frame, - eNB_flag, - pdcp_input_header.rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_TM); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - - } else if (eNB_flag) { - // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs - LOG_D(PDCP, "Checking if could sent on default rabs\n"); -#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (rab_id = DEFAULT_RAB_ID; rab_id < MAX_RB; rab_id = rab_id + NB_RB_MAX) { - LOG_D(PDCP, "Checking if could sent on default rab id %d\n", rab_id); - pdcp = &pdcp_array_eNB[eNB_id][UE_id][rab_id]; - if (pdcp->instanciated_instance == (pdcp_input_header.inst + 1)) { - result = pdcp_data_req (eNB_id, - UE_id, - frame, eNB_flag, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_DATA_PDU); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - result = pdcp_data_req (eNB_id, - UE_id, - frame, eNB_flag, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_input_header.data_size, - pdcp_input_sdu_buffer, - PDCP_DATA_PDU); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - // not necessary - //memset(pdcp_input_sdu_buffer, 0, MAX_IP_PACKET_SIZE); - return 1; + if (eNB_flagP == 0) { + ue_inst = pdcp_read_header_g.inst; + rb_id = pdcp_read_header_g.rb_id % NB_RB_MAX; + enb_inst = 0; + pdcp_p = &pdcp_array_ue[ue_inst][rb_id]; + } else { + ue_inst = pdcp_read_header_g.rb_id / NB_RB_MAX; + rb_id = pdcp_read_header_g.rb_id % NB_RB_MAX; + enb_inst = pdcp_read_header_g.inst; + pdcp_p = &pdcp_array_eNB[enb_inst][ue_inst][rb_id]; + } + AssertFatal (enb_inst < NB_eNB_INST, "eNB module id is too high (%u/%d)!\n", enb_inst, NB_eNB_INST); + AssertFatal (ue_inst >= NB_eNB_INST, + "UE module id is too low (%u/%d)!\n", + ue_inst, + NB_eNB_INST); + AssertFatal (ue_inst < (NB_eNB_INST + NB_UE_INST), + "UE module id is too high (%u/%d)!\n", + ue_inst, + NB_eNB_INST + NB_UE_INST); + AssertFatal (rab_id < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rab_id, NB_RB_MAX); + + if (pdcp_input_header.rb_id != 0) { + LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_inst, + ue_inst, + rb_id); + + if (pdcp_p->instanciated_instance) { + result = pdcp_data_req (enb_inst, + ue_inst, + frameP, + eNB_flagP, + rb_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_input_header.data_size, + pdcp_input_sdu_buffer, + PDCP_DATA_PDU); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + + } else if ((pdcp_input_header.traffic_type == OAI_NW_DRV_IPV6_ADDR_TYPE_MULTICAST) || (pdcp_input_header.traffic_type == OAI_NW_DRV_IPV4_ADDR_TYPE_MULTICAST)) { + LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ on MBMS bearer/ %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_inst, + ue_inst, + rb_id); + + if (pdcp_p->instanciated_instance) { + result = pdcp_data_req ( + enb_inst, + ue_inst, + frameP, + eNB_flagP, + rb_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_input_header.data_size, + pdcp_input_sdu_buffer, + PDCP_TM); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + + } else if (eNB_flagP) { + // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs + LOG_D(PDCP, "Checking if could sent on default rabs\n"); + for (ue_inst = 0; ue_inst < NUMBER_OF_UE_MAX; ue_inst++) { + LOG_D(PDCP, "Checking if could sent on default rab id %d\n", DEFAULT_RAB_ID); + pdcp_p = &pdcp_array_eNB[enb_inst][ue_inst][DEFAULT_RAB_ID]; + if (pdcp_p->instanciated_instance) { + LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_inst, + ue_inst, + DEFAULT_RAB_ID); + result = pdcp_data_req ( + enb_inst, + ue_inst, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_input_header.data_size, + pdcp_input_sdu_buffer, + PDCP_DATA_PDU); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_inst, + ue_inst, + DEFAULT_RAB_ID); + result = pdcp_data_req ( + enb_inst, + ue_inst, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_input_header.data_size, + pdcp_input_sdu_buffer, + PDCP_DATA_PDU); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + // not necessary + //memset(pdcp_input_sdu_buffer, 0, MAX_IP_PACKET_SIZE); + return 1; + } + } else { + return bytes_read; } - } else { - return bytes_read; - } } return 1; } //----------------------------------------------------------------------------- -int pdcp_fifo_read_input_sdus (u32_t frame, u8_t eNB_flag, u8_t UE_index, u8_t eNB_index) +int pdcp_fifo_read_input_sdus (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP) { #ifdef NAS_NETLINK # if defined(ENABLE_PDCP_NETLINK_FIFO) - rb_id_t rab_id; - pdcp_t *pdcp; - u8 pdcp_mode = 0; - struct pdcp_netlink_element_s *data = NULL; - - while (pdcp_netlink_dequeue_element(eNB_flag, UE_index, eNB_index, &data) != 0) { - DevAssert(data != NULL); - if (eNB_flag == 0) { - rab_id = data->pdcp_read_header.rb_id; - pdcp = &pdcp_array_ue[UE_index][rab_id]; - } else { + module_id_t ue_id = 0; + rb_id_t rab_id = 0; + pdcp_t *pdcp = NULL; + u8 pdcp_mode = 0; + struct pdcp_netlink_element_s *data = NULL; + + while (pdcp_netlink_dequeue_element(enb_mod_idP, ue_mod_idP, eNB_flagP, &data) != 0) { + DevAssert(data != NULL); + if (eNB_flagP == 0) { + rab_id = data->pdcp_read_header.rb_id % NB_RB_MAX; + pdcp = &pdcp_array_ue[ue_mod_idP][rab_id]; + } else { rab_id = data->pdcp_read_header.rb_id % NB_RB_MAX; - UE_index = data->pdcp_read_header.rb_id / NB_RB_MAX; - pdcp = &pdcp_array_eNB[eNB_index][UE_index][rab_id]; - } - - if (data->pdcp_read_header.rb_id != 0) { - if (pdcp->instanciated_instance) { - LOG_D(PDCP, "[FRAME %05d][IP][MOD %02d][][--- PDCP_DATA_REQ " - "/ %d Bytes --->][PDCP][MOD %02d][RB %02d]\n", - frame, data->pdcp_read_header.inst, data->pdcp_read_header.data_size, - data->pdcp_read_header.inst, data->pdcp_read_header.rb_id); + ue_mod_idP = data->pdcp_read_header.rb_id / NB_RB_MAX; + pdcp = &pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rab_id]; + } + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB inst is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB inst is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE inst is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE inst is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + AssertFatal (rab_id < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rab_id, NB_RB_MAX); + + if (rab_id != 0) { + if (pdcp->instanciated_instance) { + LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ " + "/ %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + data->pdcp_read_header.inst, + data->pdcp_read_header.rb_id, + data->pdcp_read_header.data_size, + enb_mod_idP, + ue_mod_idP, + rab_id); #ifdef OAI_NW_DRIVER_TYPE_ETHERNET - - if ((data->pdcp_read_header.traffic_type == 2) /*OAI_NW_DRV_IPV6_ADDR_TYPE_MULTICAST */ || - (data->pdcp_read_header.traffic_type == 6) /*OAI_NW_DRV_IPV4_ADDR_TYPE_MULTICAST */ || - (data->pdcp_read_header.traffic_type == 7) /*OAI_NW_DRV_IPV4_ADDR_TYPE_BROADCAST */ ) - pdcp_mode = PDCP_TM; - else if ((data->pdcp_read_header.traffic_type == 1) /* OAI_NW_DRV_IPV6_ADDR_TYPE_UNICAST */ || - (data->pdcp_read_header.traffic_type == 5) /*OAI_NW_DRV_IPV4_ADDR_TYPE_UNICAST*/ ) - pdcp_mode= PDCP_DATA_PDU; - else { - pdcp_mode= PDCP_DATA_PDU; - LOG_W(PDCP,"unknown IP traffic type \n"); - } + if ((data->pdcp_read_header.traffic_type == 2) /*OAI_NW_DRV_IPV6_ADDR_TYPE_MULTICAST */ || + (data->pdcp_read_header.traffic_type == 6) /*OAI_NW_DRV_IPV4_ADDR_TYPE_MULTICAST */ || + (data->pdcp_read_header.traffic_type == 7) /*OAI_NW_DRV_IPV4_ADDR_TYPE_BROADCAST */ ) + pdcp_mode = PDCP_TM; + else if ((data->pdcp_read_header.traffic_type == 1) /* OAI_NW_DRV_IPV6_ADDR_TYPE_UNICAST */ || + (data->pdcp_read_header.traffic_type == 5) /*OAI_NW_DRV_IPV4_ADDR_TYPE_UNICAST*/ ) + pdcp_mode= PDCP_DATA_PDU; + else { + pdcp_mode= PDCP_DATA_PDU; + LOG_W(PDCP,"unknown IP traffic type \n"); + } #else // NASMESH driver does not curreenlty support multicast traffic - pdcp_mode = PDCP_DATA_PDU; + pdcp_mode = PDCP_DATA_PDU; #endif - pdcp_data_req(eNB_index, - UE_index, - frame, - eNB_flag, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, - pdcp_mode); - } else { - LOG_E(PDCP, "Received packet for non-instanciated instance %u with rb_id %u, UE_index %d, eNB_flag %d eNB_index %d\n", - data->pdcp_read_header.inst, data->pdcp_read_header.rb_id, UE_index, eNB_flag,eNB_index); - } - } else if (eNB_flag) { // eNB - /* rb_id = 0, thus interpreated as broadcast and transported as - * multiple unicast is a broadcast packet, we have to send this - * packet on all default RABS of all connected UEs - */ -#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (rab_id = DEFAULT_RAB_ID; rab_id < MAX_RB; rab_id = rab_id + NB_RB_MAX) { - pdcp = &pdcp_array_eNB[eNB_index][UE_index][rab_id]; - if (pdcp->instanciated_instance) { - pdcp_data_req(eNB_index, - UE_index, - frame, - eNB_flag, - rab_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, - PDCP_DATA_PDU); - } - } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - pdcp_data_req(eNB_index, - UE_index, - frame, eNB_flag, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - data->pdcp_read_header.data_size, - data->data, - PDCP_DATA_PDU); - } - - free(data->data); - free(data); - data = NULL; - } - return 0; -# else + pdcp_data_req(enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flagP, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data->pdcp_read_header.data_size, + data->data, + pdcp_mode); + } else { + LOG_E(PDCP, "Received packet for non-instanciated instance %u with rb_id %u, UE_index %d, eNB_flagP %d eNB_index %d\n", + data->pdcp_read_header.inst, data->pdcp_read_header.rb_id, ue_mod_idP, eNB_flagP,enb_mod_idP); + } + } else if (eNB_flagP) { + /* rb_id = 0, thus interpreated as broadcast and transported as + * multiple unicast is a broadcast packet, we have to send this + * packet on all default RABS of all connected UEs + */ + for (ue_id = oai_emulation.info.first_ue_local; ue_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); ue_id++) { + pdcp = &pdcp_array_eNB[enb_mod_idP][ue_id][DEFAULT_RAB_ID]; + if (pdcp->instanciated_instance) { + pdcp_data_req( + enb_mod_idP, + ue_id, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data->pdcp_read_header.data_size, + data->data, + PDCP_DATA_PDU); + } + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + pdcp_data_req( + enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + data->pdcp_read_header.data_size, + data->data, + PDCP_DATA_PDU); + } + free(data->data); + free(data); + data = NULL; + } + return 0; +# else /* ENABLE_PDCP_NETLINK_FIFO*/ int len = 1; rb_id_t rab_id = 0; - while (len > 0) { - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); - - if (len<=0) { - // nothing in pdcp NAS socket - //LOG_I(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); - } else { - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK (nas_nlh_rx, len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { + len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); + if (len<=0) { + // nothing in pdcp NAS socket + //LOG_I(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len); + } else { + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + NLMSG_OK (nas_nlh_rx, len); + nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { - if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { - LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n"); - //return; - } + if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) { + LOG_I(PDCP, "[PDCP][FIFO] RX NLMSG_DONE\n"); + //return; + } - if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { - LOG_I(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n"); - } - if (pdcp_read_state == 0) { - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_read_state = 1; //get - memcpy((void *)&pdcp_read_header, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_I(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n", pdcp_read_header.inst, pdcp_read_header.rb_id, pdcp_read_header.data_size); - } else { - LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", nas_nlh_rx->nlmsg_len); - } + if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) { + LOG_I(PDCP, "[PDCP][FIFO] RX NLMSG_ERROR\n"); + } + if (pdcp_read_state_g == 0) { + if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { + pdcp_read_state_g = 1; //get + memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); + LOG_I(PDCP, "[PDCP][FIFO] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n", + pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size); } else { - pdcp_read_state = 0; - // print_active_requests() + LOG_E(PDCP, "[PDCP][FIFO] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n", + nas_nlh_rx->nlmsg_len); + } + } else { + pdcp_read_state_g = 0; + // print_active_requests() #ifdef PDCP_DEBUG - LOG_I(PDCP, "[PDCP][NETLINK] Something in socket, length %d \n", nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); + LOG_I(PDCP, "[PDCP][FIFO] Something in socket, length %d \n", + nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); #endif - //memcpy(pdcp_read_payload, (unsigned char *)NLMSG_DATA(nas_nlh_rx), nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); - - #ifdef OAI_EMU - pdcp_read_header.inst = (pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) ? \ - pdcp_read_header.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : - pdcp_read_header.inst + oai_emulation.info.first_enb_local; - #else - pdcp_read_header.inst = 0; - #endif - - if (pdcp_read_header.rb_id != 0) { - if (pdcp_array[pdcp_read_header.inst][pdcp_read_header.rb_id%NB_RB_MAX].instanciated_instance) { + //memcpy(pdcp_read_payload, (unsigned char *)NLMSG_DATA(nas_nlh_rx), nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr)); + + // overwrite function input parameters, because only one netlink socket for all instances + if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) { + eNB_flagP = 1; + ue_mod_idP = pdcp_read_header_g.rb_id / NB_RB_MAX + oai_emulation.info.first_ue_local; + enb_mod_idP = pdcp_read_header_g.inst + oai_emulation.info.first_enb_local; + rab_id = pdcp_read_header_g.rb_id % NB_RB_MAX; + } else { + eNB_flagP = 0; + ue_mod_idP = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local; + enb_mod_idP = 0; + rab_id = pdcp_read_header_g.rb_id; + } + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB inst is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB inst is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE inst is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE inst is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + AssertFatal (rab_id < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rab_id, NB_RB_MAX); +#ifdef OAI_EMU + /*LGpdcp_read_header.inst = (pdcp_read_header_g.inst >= oai_emulation.info.nb_enb_local) ? \ + pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local : + pdcp_read_header_g.inst + oai_emulation.info.first_enb_local;*/ +#else + pdcp_read_header_g.inst = 0; +#endif + + if (eNB_flagP) { + if (rab_id != 0) { + if (pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rab_id].instanciated_instance) { #ifdef PDCP_DEBUG - LOG_I(PDCP, "[PDCP][NETLINK][IP->PDCP] TTI %d, INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", - frame, pdcp_read_header.inst, len, nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), pdcp_read_header.rb_id); - LOG_D(PDCP, "[MSC_MSG][FRAME %05d][IP][MOD %02d][][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %02d][RB %02d]\n", - frame, pdcp_read_header.inst, pdcp_read_header.data_size, pdcp_read_header.inst, pdcp_read_header.rb_id); + LOG_I(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", + frameP, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); #endif - pdcp_data_req(eNB_index,UE_index,frame, eNB_flag, - pdcp_read_header.rb_id, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_DATA_PDU); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + rab_id); + + pdcp_data_req(enb_mod_idP,ue_mod_idP,frameP, eNB_flagP, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_DATA_PDU); } else { - LOG_E(PDCP, "Received packet for non-instanciated instance %u with rb_id %u\n", - pdcp_read_header.inst, pdcp_read_header.rb_id); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u/%u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + rab_id); } - } else if (eNB_flag) { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast + } else { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs - #warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES - for (rab_id = DEFAULT_RAB_ID; rab_id < MAX_RB; rab_id = rab_id + NB_RB_MAX) { - if (pdcp_array[pdcp_input_header.inst][rab_id%NB_RB_MAX].instanciated_instance == (pdcp_input_header.inst + 1)) { - pdcp_data_req (eNB_index,UE_index,frame, eNB_flag, - rab_id, RLC_MUI_UNDEFINED,RLC_SDU_CONFIRM_NO, - pdcp_read_header.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_DATA_PDU); +#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES + for (ue_mod_idP = oai_emulation.info.first_ue_local; ue_mod_idP < oai_emulation.info.nb_ue_local; ue_mod_idP++) { + if (pdcp_array_eNB[enb_mod_idP][ue_mod_idP][rab_id].instanciated_instance > 0) { + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + DEFAULT_RAB_ID); + pdcp_data_req ( + enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_DATA_PDU); } } - } else { - LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); - pdcp_data_req (eNB_index, - UE_index, - frame, eNB_flag, - DEFAULT_RAB_ID, - RLC_MUI_UNDEFINED, - RLC_SDU_CONFIRM_NO, - pdcp_read_header.data_size, - (unsigned char *)NLMSG_DATA(nas_nlh_rx), - PDCP_DATA_PDU); + } + } else { + if (rab_id != 0) { + if (pdcp_array_ue[ue_mod_idP][rab_id].instanciated_instance) { +#ifdef PDCP_DEBUG + LOG_I(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n", + frameP, + pdcp_read_header_g.inst, + len, + nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr), + pdcp_read_header_g.rb_id); + + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + rab_id); +#endif + pdcp_data_req( + enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flagP, + rab_id, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_DATA_PDU); + } else { + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u/%u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + rab_id); + } + } else { + LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n"); + LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u/%u][RB DEFAULT_RAB_ID %u]\n", + frameP, + pdcp_read_header_g.inst, + pdcp_read_header_g.rb_id, + pdcp_read_header_g.data_size, + enb_mod_idP, + ue_mod_idP, + DEFAULT_RAB_ID); + pdcp_data_req ( + enb_mod_idP, + ue_mod_idP, + frameP, + eNB_flagP, + DEFAULT_RAB_ID, + RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, + pdcp_read_header_g.data_size, + (unsigned char *)NLMSG_DATA(nas_nlh_rx), + PDCP_DATA_PDU); } } + } } + } } return len; # endif @@ -600,84 +781,85 @@ int pdcp_fifo_read_input_sdus (u32_t frame, u8_t eNB_flag, u8_t UE_index, u8_t e } -void pdcp_fifo_read_input_sdus_from_otg (u32_t frame, u8_t eNB_flag, u8 UE_index, u8 eNB_index) { - unsigned char *otg_pkt=NULL; - int src_id, module_id; // src for otg - int dst_id, rb_id; // dst for otg - int pkt_size=0, pkt_cnt=0; - u8 pdcp_mode, is_ue=0; - Packet_otg_elt * otg_pkt_info=NULL; - int result; +void pdcp_fifo_read_input_sdus_from_otg (frame_t frameP, eNB_flag_t eNB_flagP, module_id_t ue_mod_idP, module_id_t enb_mod_idP) { + unsigned char *otg_pkt=NULL; + module_id_t src_id, module_id; // src for otg + module_id_t dst_id; // dst for otg + rb_id_t rb_id; + int pkt_size=0, pkt_cnt=0; + u8 pdcp_mode, is_ue=0; + Packet_otg_elt *otg_pkt_info=NULL; + int result; - src_id = eNB_index; + src_id = enb_mod_idP; // we need to add conditions to avoid transmitting data when the UE is not RRC connected. #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled ==1 ){ - module_id = (eNB_flag == 1) ? eNB_index : NB_eNB_INST + UE_index ; - //rb_id = (eNB_flag == 1) ? eNB_index * MAX_NUM_RB + DTCH : (NB_eNB_INST + UE_index -1 ) * MAX_NUM_RB + DTCH ; - src_id = module_id; - while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id]))) != NULL) { - LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", - module_id,frame, otg_pkt_info, module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id])), otg_pdcp_buffer[module_id].nb_elements); - //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id])); - dst_id = (otg_pkt_info->otg_pkt).dst_id; - module_id = (otg_pkt_info->otg_pkt).module_id; - rb_id = (otg_pkt_info->otg_pkt).rb_id; - is_ue = (otg_pkt_info->otg_pkt).is_ue; - pdcp_mode = (otg_pkt_info->otg_pkt).mode; - // LOG_I(PDCP,"pdcp_fifo, pdcp mode is= %d\n",pdcp_mode); - - // generate traffic if the ue is rrc reconfigured state - // if (mac_get_rrc_status(module_id, eNB_flag, dst_id ) > 2 /*RRC_CONNECTED*/) { // not needed: this test is already done in update_otg_enb - otg_pkt = (u8*) (otg_pkt_info->otg_pkt).sdu_buffer; - pkt_size = (otg_pkt_info->otg_pkt).sdu_buffer_size; - if (otg_pkt != NULL) { - if (is_ue == 0 ) { - //rb_id = (/*NB_eNB_INST +*/ dst_id -1 ) * MAX_NUM_RB + DTCH; - LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d) pkt size %d for pdcp mode %d\n", - eNB_index, frame, pkt_cnt++, module_id, rb_id, module_id, dst_id, pkt_size, pdcp_mode); - result = pdcp_data_req(eNB_index, UE_index, frame, eNB_flag, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt,pdcp_mode); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - else { - //rb_id= eNB_index * MAX_NUM_RB + DTCH; - LOG_D(OTG,"[UE %d] sending packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", - UE_index, src_id, rb_id, src_id, dst_id, pkt_size); - result = pdcp_data_req(eNB_index, UE_index, frame, eNB_flag, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt, PDCP_DATA_PDU); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - } - free(otg_pkt); - otg_pkt = NULL; + module_id = (eNB_flagP == 1) ? enb_mod_idP : ue_mod_idP; + //rb_id = (eNB_flagP == 1) ? enb_mod_idP * MAX_NUM_RB + DTCH : (NB_eNB_INST + UE_index -1 ) * MAX_NUM_RB + DTCH ; + src_id = module_id; + while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id]))) != NULL) { + LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n", + module_id,frameP, otg_pkt_info, module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id])), otg_pdcp_buffer[module_id].nb_elements); + //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id])); + dst_id = (otg_pkt_info->otg_pkt).dst_id; + module_id = (otg_pkt_info->otg_pkt).module_id; + rb_id = (otg_pkt_info->otg_pkt).rb_id; + is_ue = (otg_pkt_info->otg_pkt).is_ue; + pdcp_mode = (otg_pkt_info->otg_pkt).mode; + // LOG_I(PDCP,"pdcp_fifo, pdcp mode is= %d\n",pdcp_mode); + + // generate traffic if the ue is rrc reconfigured state + // if (mac_get_rrc_status(module_id, eNB_flagP, dst_id ) > 2 /*RRC_CONNECTED*/) { // not needed: this test is already done in update_otg_enb + otg_pkt = (u8*) (otg_pkt_info->otg_pkt).sdu_buffer; + pkt_size = (otg_pkt_info->otg_pkt).sdu_buffer_size; + if (otg_pkt != NULL) { + if (is_ue == 0 ) { + //rb_id = (/*NB_eNB_INST +*/ dst_id -1 ) * MAX_NUM_RB + DTCH; + LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d) pkt size %d for pdcp mode %d\n", + enb_mod_idP, frameP, pkt_cnt++, module_id, rb_id, module_id, dst_id, pkt_size, pdcp_mode); + result = pdcp_data_req(enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt,pdcp_mode); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + else { + //rb_id= eNB_index * MAX_NUM_RB + DTCH; + LOG_D(OTG,"[UE %d] sending packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", + ue_mod_idP, src_id, rb_id, src_id, dst_id, pkt_size); + result = pdcp_data_req(enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, pkt_size, otg_pkt, PDCP_DATA_PDU); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + } + free(otg_pkt); + otg_pkt = NULL; + } + // } //else LOG_D(OTG,"frameP %d enb %d-> ue %d link not yet established state %d \n", frameP, eNB_index,dst_id - NB_eNB_INST, mac_get_rrc_status(module_id, eNB_flagP, dst_id - NB_eNB_INST)); + } - // } //else LOG_D(OTG,"frame %d enb %d-> ue %d link not yet established state %d \n", frame, eNB_index,dst_id - NB_eNB_INST, mac_get_rrc_status(module_id, eNB_flag, dst_id - NB_eNB_INST)); - - } } #else - if ((otg_enabled==1) && (eNB_flag == 1)) { // generate DL traffic - unsigned int ctime=0; - ctime = frame * 100; - - /*if ((mac_get_rrc_status(eNB_index, eNB_flag, 0 ) > 2) && - (mac_get_rrc_status(eNB_index, eNB_flag, 1 ) > 2)) { */ - for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { - if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { - otg_pkt=packet_gen(src_id, dst_id, 0, ctime, &pkt_size); - if (otg_pkt != NULL){ - rb_id = dst_id * NB_RB_MAX + DTCH; - pdcp_data_req(eNB_index, dst_id, frame, eNB_flag, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO,pkt_size, otg_pkt, PDCP_DATA_PDU); - LOG_I(OTG,"send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", eNB_index, rb_id, src_id, dst_id, pkt_size); - free(otg_pkt); - } - /*else { + if ((otg_enabled==1) && (eNB_flagP == 1)) { // generate DL traffic + unsigned int ctime=0; + ctime = frameP * 100; + + /*if ((mac_get_rrc_status(eNB_index, eNB_flagP, 0 ) > 2) && + (mac_get_rrc_status(eNB_index, eNB_flagP, 1 ) > 2)) { */ + for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) { + if (mac_get_rrc_status(enb_mod_idP, eNB_flagP, dst_id ) > 2) { + otg_pkt=packet_gen(src_id, dst_id, 0, ctime, &pkt_size); + if (otg_pkt != NULL){ + rb_id = dst_id * NB_RB_MAX + DTCH; + pdcp_data_req(enb_mod_idP, dst_id, frameP, eNB_flagP, rb_id, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO,pkt_size, otg_pkt, PDCP_DATA_PDU); + LOG_I(OTG,"send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n", enb_mod_idP, rb_id, src_id, dst_id, pkt_size); + free(otg_pkt); + } + /*else { LOG_I(OTG,"nothing generated (src %d, dst %d)\n",src_id, dst_id); }*/ - } - /*else { - LOG_I(OTG,"rrc_status (src %d, dst %d) = %d\n",src_id, dst_id, mac_get_rrc_status(src_id, eNB_flag, dst_id )); + } + /*else { + LOG_I(OTG,"rrc_status (src %d, dst %d) = %d\n",src_id, dst_id, mac_get_rrc_status(src_id, eNB_flagP, dst_id )); }*/ - } + } } #endif } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c index b8b131634f8e3166bc3439f0c108e9615263b116..72eebe92f6ba6cac1db798724e7615c6e826eca4 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_netlink.c @@ -25,18 +25,18 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file pdcp_netlink.c -* \brief pdcp communication with linux IP interface, -* have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink. -* Read operation from netlink should be achieved in an asynchronous way to avoid -* subframe overload, netlink congestion... -* \author Sebastien ROUX -* \date 2013 -* \version 0.1 -* @ingroup pdcp -*/ + * \brief pdcp communication with linux IP interface, + * have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink. + * Read operation from netlink should be achieved in an asynchronous way to avoid + * subframe overload, netlink congestion... + * \author Sebastien ROUX + * \date 2013 + * \version 0.1 + * @ingroup pdcp + */ #include <pthread.h> #include <stdio.h> @@ -81,163 +81,199 @@ static pthread_t pdcp_netlink_thread; * and the corresponding entity in User-space. * one queue for eNBs (index 0)/one queue for UEs (index 1) */ -static struct lfds611_queue_state **pdcp_netlink_queue = NULL; -static uint32_t *pdcp_netlink_nb_element = NULL; +static struct lfds611_queue_state **pdcp_netlink_queue_enb = NULL; +static struct lfds611_queue_state **pdcp_netlink_queue_ue = NULL; +static uint32_t *pdcp_netlink_nb_element_enb = NULL; +static uint32_t *pdcp_netlink_nb_element_ue = NULL; static void *pdcp_netlink_thread_fct(void *arg); int pdcp_netlink_init(void) { - int i, nb_modules; - pthread_attr_t attr; - struct sched_param sched_param; + int i; + int nb_inst_enb; + int nb_inst_ue; + pthread_attr_t attr; + struct sched_param sched_param; #if defined(USER_MODE) && defined(OAI_EMU) - nb_modules = NB_eNB_INST + NB_UE_INST; + nb_inst_enb = oai_emulation.info.nb_enb_local; + nb_inst_ue = oai_emulation.info.nb_ue_local; #else - nb_modules = 1; + nb_inst_enb = 1; + nb_inst_ue = 1; #endif - pdcp_netlink_queue = calloc(nb_modules, sizeof(struct lfds611_queue_state*)); - pdcp_netlink_nb_element = malloc(nb_modules * sizeof(uint32_t)); - - LOG_I(PDCP, "Creating %d queues for Netlink -> PDCP communication\n", - nb_modules); - - for (i = 0; i < nb_modules; i++) { - pdcp_netlink_nb_element[i] = 0; - if (lfds611_queue_new(&pdcp_netlink_queue[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { - LOG_E(PDCP, "Failed to create new FIFO for Netlink -> PDCP communcation instance %d\n", i); - exit(EXIT_FAILURE); - } - } - - if (pthread_attr_init(&attr) != 0) { - LOG_E(PDCP, "Failed to initialize pthread attribute for Netlink -> PDCP communication (%d:%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - sched_param.sched_priority = 10; - - pthread_attr_setschedpolicy(&attr, SCHED_RR); - pthread_attr_setschedparam(&attr, &sched_param); - - /* Create one thread that fetchs packets from the netlink. - * When the netlink fifo is full, packets are silently dropped, this behaviour - * should be avoided if we want a reliable link. - */ - if (pthread_create(&pdcp_netlink_thread, &attr, pdcp_netlink_thread_fct, NULL) != 0) { - LOG_E(PDCP, "Failed to create new thread for Netlink/PDCP communcation (%d:%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } - - return 0; + pdcp_netlink_queue_enb = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state*)); + pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t)); + + pdcp_netlink_queue_ue = calloc(nb_inst_ue, sizeof(struct lfds611_queue_state*)); + pdcp_netlink_nb_element_ue = malloc(nb_inst_ue * sizeof(uint32_t)); + + LOG_I(PDCP, "Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb); + LOG_I(PDCP, "Creating %d queues for UE Netlink -> PDCP communication\n", nb_inst_ue); + + for (i = 0; i < nb_inst_enb; i++) { + pdcp_netlink_nb_element_enb[i] = 0; + if (lfds611_queue_new(&pdcp_netlink_queue_enb[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { + LOG_E(PDCP, "Failed to create new FIFO for eNB Netlink -> PDCP communcation instance %d\n", i); + exit(EXIT_FAILURE); + } + } + for (i = 0; i < nb_inst_ue; i++) { + pdcp_netlink_nb_element_ue[i] = 0; + if (lfds611_queue_new(&pdcp_netlink_queue_ue[i], PDCP_QUEUE_NB_ELEMENTS) < 0) { + LOG_E(PDCP, "Failed to create new FIFO for UE Netlink -> PDCP communcation instance %d\n", i); + exit(EXIT_FAILURE); + } + } + + if (pthread_attr_init(&attr) != 0) { + LOG_E(PDCP, "Failed to initialize pthread attribute for Netlink -> PDCP communication (%d:%s)\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + sched_param.sched_priority = 10; + + pthread_attr_setschedpolicy(&attr, SCHED_RR); + pthread_attr_setschedparam(&attr, &sched_param); + + /* Create one thread that fetchs packets from the netlink. + * When the netlink fifo is full, packets are silently dropped, this behaviour + * should be avoided if we want a reliable link. + */ + if (pthread_create(&pdcp_netlink_thread, &attr, pdcp_netlink_thread_fct, NULL) != 0) { + LOG_E(PDCP, "Failed to create new thread for Netlink/PDCP communcation (%d:%s)\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } + + return 0; } -int pdcp_netlink_dequeue_element(uint8_t eNB_flag, uint8_t UE_index, uint8_t eNB_index, - struct pdcp_netlink_element_s **data) +int pdcp_netlink_dequeue_element( + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + eNB_flag_t eNB_flagP, + struct pdcp_netlink_element_s **data_ppP) { - int ret = 0; - module_id_t module_id; - -#if defined(USER_MODE) && defined(OAI_EMU) - module_id = (eNB_flag != 0) ? eNB_index : NB_eNB_INST + UE_index; -#else - module_id = 0; -#endif - - ret = lfds611_queue_dequeue(pdcp_netlink_queue[module_id], (void **)data); - - if (ret != 0) { - LOG_D(PDCP, "De-queueing packet for module %d\n", module_id); - } - return ret; + int ret = 0; + + if (eNB_flagP) { + ret = lfds611_queue_dequeue(pdcp_netlink_queue_enb[enb_mod_idP], (void **)data_ppP); + if (ret != 0) { + LOG_D(PDCP, "De-queueing packet for eNB instance %d\n", enb_mod_idP); + } + } else { + ret = lfds611_queue_dequeue(pdcp_netlink_queue_ue[ue_mod_idP], (void **)data_ppP); + if (ret != 0) { + LOG_D(PDCP, "De-queueing packet for UE instance %d\n", ue_mod_idP); + } + } + + return ret; } static void *pdcp_netlink_thread_fct(void *arg) { - int len; - struct pdcp_netlink_element_s *new_data = NULL; - uint8_t pdcp_read_state; - - pdcp_read_state = 0; - memset(nl_rx_buf, 0, NL_MAX_PAYLOAD); - - while (1) { - - len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); - - if (len == 0) { - /* Other peer (kernel) has performed an orderly shutdown - */ - LOG_E(PDCP, "Kernel module has closed the netlink\n"); - exit(EXIT_FAILURE); - } else if (len < 0) { - /* There was an error */ - LOG_E(PDCP, "An error occured while reading netlink (%d:%s)\n", - errno, strerror(errno)); - exit(EXIT_FAILURE); - } else { - /* Normal read. - * NOTE: netlink messages can be assembled to form a multipart message - */ - for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; - NLMSG_OK(nas_nlh_rx, len); - nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { - - /* There is no need to check for nlmsg_type because - * the header is not set in our drivers. - */ - if (pdcp_read_state == 0) { - new_data = malloc(sizeof(struct pdcp_netlink_element_s)); - - if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { - pdcp_read_state = 1; - memcpy((void *)&new_data->pdcp_read_header, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); - LOG_I(PDCP, "[NETLINK] RX pdcp_data_req_header_t inst %u, " - "rb_id %u data_size %d\n", - new_data->pdcp_read_header.inst, new_data->pdcp_read_header.rb_id, - new_data->pdcp_read_header.data_size); - } else { - LOG_E(PDCP, "[NETLINK] WRONG size %d should be sizeof " - "%d ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n", - nas_nlh_rx->nlmsg_len, sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)); - } - } else { - pdcp_read_state = 0; + int len = 0; + struct pdcp_netlink_element_s *new_data_p = NULL; + uint8_t pdcp_thread_read_state ; + eNB_flag_t eNB_flag = 0; + + pdcp_thread_read_state = 0; + memset(nl_rx_buf, 0, NL_MAX_PAYLOAD); + + while (1) { + + len = recvmsg(nas_sock_fd, &nas_msg_rx, 0); + + if (len == 0) { + /* Other peer (kernel) has performed an orderly shutdown + */ + LOG_E(PDCP, "[NETLINK_THREAD] Kernel module has closed the netlink\n"); + exit(EXIT_FAILURE); + } else if (len < 0) { + /* There was an error */ + LOG_E(PDCP, "[NETLINK_THREAD] An error occured while reading netlink (%d:%s)\n", + errno, strerror(errno)); + exit(EXIT_FAILURE); + } else { + /* Normal read. + * NOTE: netlink messages can be assembled to form a multipart message + */ + for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf; + NLMSG_OK(nas_nlh_rx, len); + nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) { + + /* There is no need to check for nlmsg_type because + * the header is not set in our drivers. + */ + if (pdcp_thread_read_state == 0) { + new_data_p = malloc(sizeof(struct pdcp_netlink_element_s)); + + if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) { + pdcp_thread_read_state = 1; + memcpy((void *)&new_data_p->pdcp_read_header, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t)); + LOG_I(PDCP, "[NETLINK_THREAD] RX pdcp_data_req_header_t inst %u, " + "rb_id %u data_size %d\n", + new_data_p->pdcp_read_header.inst, + new_data_p->pdcp_read_header.rb_id, + new_data_p->pdcp_read_header.data_size); + } else { + LOG_E(PDCP, "[NETLINK_THREAD] WRONG size %d should be sizeof " + "%d ((pdcp_data_req_header_t) + sizeof(struct nlmsghdr))\n", + nas_nlh_rx->nlmsg_len, + sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)); + } + } else { + pdcp_thread_read_state = 0; #ifdef OAI_EMU - if (new_data->pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) { - new_data->pdcp_read_header.inst = new_data->pdcp_read_header.inst - - oai_emulation.info.nb_enb_local + NB_eNB_INST - + oai_emulation.info.first_ue_local; - } else { - new_data->pdcp_read_header.inst = new_data->pdcp_read_header.inst - + oai_emulation.info.first_enb_local; - } + if (new_data_p->pdcp_read_header.inst >= oai_emulation.info.nb_enb_local) { + new_data_p->pdcp_read_header.inst = new_data_p->pdcp_read_header.inst + - oai_emulation.info.nb_enb_local + + + oai_emulation.info.first_ue_local; + eNB_flag = 0; + } else { + new_data_p->pdcp_read_header.inst = new_data_p->pdcp_read_header.inst + + oai_emulation.info.first_enb_local; + eNB_flag = 1; + } #else - new_data->pdcp_read_header.inst = 0; + new_data_p->pdcp_read_header.inst = 0; #endif - new_data->data = malloc(sizeof(uint8_t) * new_data->pdcp_read_header.data_size); - /* Copy the data */ - memcpy(new_data->data, NLMSG_DATA(nas_nlh_rx), new_data->pdcp_read_header.data_size); - - if (pdcp_netlink_nb_element[new_data->pdcp_read_header.inst] - > PDCP_QUEUE_NB_ELEMENTS) { - LOG_E(PDCP, "[Mod %02x] We reached maximum number of elements in pdcp queue (%d)\n", - new_data->pdcp_read_header.inst, pdcp_netlink_nb_element); - } - - LOG_D(PDCP, "En-queueing packet for module %d\n", new_data->pdcp_read_header.inst); - - /* Enqueue the element in the right queue */ -// lfds611_queue_enqueue(pdcp_netlink_queue[new_data->pdcp_read_header.inst], new_data); - lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue[new_data->pdcp_read_header.inst], new_data); - } - } - } - } - return NULL; + new_data_p->data = malloc(sizeof(uint8_t) * new_data_p->pdcp_read_header.data_size); + /* Copy the data */ + memcpy(new_data_p->data, NLMSG_DATA(nas_nlh_rx), new_data_p->pdcp_read_header.data_size); + + if (eNB_flag) { + if (pdcp_netlink_nb_element_enb[new_data_p->pdcp_read_header.inst] + > PDCP_QUEUE_NB_ELEMENTS) { + LOG_E(PDCP, "[NETLINK_THREAD][Inst %02x] We reached maximum number of elements in eNB pdcp queue (%d)\n", + new_data_p->pdcp_read_header.inst, pdcp_netlink_nb_element_enb); + } + + LOG_D(PDCP, "[NETLINK_THREAD] En-queueing packet for eNB instance %d\n", new_data_p->pdcp_read_header.inst); + + /* Enqueue the element in the right queue */ + lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_enb[new_data_p->pdcp_read_header.inst], new_data_p); + } else { + if (pdcp_netlink_nb_element_ue[new_data_p->pdcp_read_header.inst] + > PDCP_QUEUE_NB_ELEMENTS) { + LOG_E(PDCP, "[NETLINK_THREAD][Inst %02x] We reached maximum number of elements in UE pdcp queue (%d)\n", + new_data_p->pdcp_read_header.inst, pdcp_netlink_nb_element_ue); + } + + LOG_D(PDCP, "[NETLINK_THREAD] En-queueing packet for UE instance %d\n", new_data_p->pdcp_read_header.inst); + + /* Enqueue the element in the right queue */ + lfds611_queue_guaranteed_enqueue(pdcp_netlink_queue_ue[new_data_p->pdcp_read_header.inst], new_data_p); + } + } + } + } + } + return NULL; } diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h index 54d762ed9f9537d69823ee1472485b2b3892cafb..9d5505e20b69868b9947df1b58ecab1f9e9db4eb 100755 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_primitives.h @@ -153,11 +153,11 @@ BOOL pdcp_serialize_user_plane_data_pdu_with_long_sn_buffer(unsigned char* pdu_b BOOL pdcp_serialize_control_pdu_for_pdcp_status_report(unsigned char* pdu_buffer, \ u8 bitmap[512], pdcp_control_pdu_for_pdcp_status_report* pdu); -int pdcp_netlink_dequeue_element(uint8_t eNB_flag, uint8_t UE_index, uint8_t eNB_index, - struct pdcp_netlink_element_s **data); +int pdcp_netlink_dequeue_element(module_id_t enb_mod_idP, module_id_t ue_mod_idP, eNB_flag_t eNB_flagP, + struct pdcp_netlink_element_s **data_ppP); -void pdcp_config_set_security(pdcp_t *pdcp, u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, rb_id_t rb_id, - u16 lc_id, u8 security_mode, u8 *kRRCenc, u8 *kRRCint, u8 *kUPenc); +void pdcp_config_set_security(pdcp_t *pdcp_pP, module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, + u16 lc_idP, u8 security_modeP, u8 *kRRCenc_pP, u8 *kRRCint_pP, u8 *kUPenc_pP); #if defined(ENABLE_SECURITY) int pdcp_apply_security(pdcp_t *pdcp_entity, rb_id_t rb_id, diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c index 2dc0b924e7329a43da6821ec1ce6f88cefee3e83..2fe2960e568870acdf161e7636965b171a614831 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_util.c @@ -87,12 +87,15 @@ void util_flush_hex_octets(comp_name_t component, unsigned char* data, unsigned LOG_W(component, "Incoming buffer is NULL! Ignoring...\n"); return; } + printf("[PDCP]"); unsigned long octet_index = 0; for (octet_index = 0; octet_index < size; ++octet_index) { - LOG_T(component, "%02x.", data[octet_index]); + //LOG_T(component, "%02x.", data[octet_index]); + printf("%02x.", data[octet_index]); } - LOG_T(component, " \n"); + //LOG_T(component, " \n"); + printf(" \n"); } /* diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c index ba9d0a9a42f3b3ad9b88b60ed4f3eb84e4bc1bd1..d3d724f7738d968ffcc1d9880b37752e08dbe7ef 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.c @@ -35,6 +35,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #if defined(ENABLE_ITTI) # include "intertask_interface.h" #endif +# include "assertions.h" #include "rlc_am.h" #include "rlc_am_segment.h" #include "rlc_am_timer_poll_retransmit.h" @@ -56,7 +57,7 @@ extern rlc_am_control_pdu_info_t g_rlc_am_control_pdu_info; //----------------------------------------------------------------------------- u32_t -rlc_am_get_buffer_occupancy_in_bytes (rlc_am_entity_t *rlc_pP,u32 frameP) +rlc_am_get_buffer_occupancy_in_bytes (rlc_am_entity_t *rlc_pP,frame_t frameP) { //----------------------------------------------------------------------------- u32_t max_li_overhead; @@ -67,7 +68,7 @@ rlc_am_get_buffer_occupancy_in_bytes (rlc_am_entity_t *rlc_pP,u32 frameP) if (rlc_pP->t_status_prohibit.running == 0) { #ifdef TRACE_RLC_AM_BO if (((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3) > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] BO : CONTROL PDU %d bytes \n", frameP, rlc_pP->module_id, rlc_pP->rb_id, ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3)); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] BO : CONTROL PDU %d bytes \n", frameP, rlc_pP->module_id, rlc_pP->rb_id, ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3)); } #endif return ((15 + rlc_pP->num_nack_sn*(10+1) + rlc_pP->num_nack_so*(15+15+1) + 7) >> 3); @@ -89,9 +90,9 @@ rlc_am_get_buffer_occupancy_in_bytes (rlc_am_entity_t *rlc_pP,u32 frameP) #ifdef TRACE_RLC_AM_BO if ((rlc_pP->status_buffer_occupancy + rlc_pP->retransmission_buffer_occupancy + rlc_pP->sdu_buffer_occupancy + max_li_overhead + header_overhead) > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] BO : STATUS BUFFER %d bytes \n", frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->status_buffer_occupancy); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] BO : RETRANS BUFFER %d bytes \n", frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->retransmission_buffer_occupancy); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] BO : SDU BUFFER %d bytes + li_overhead %d bytes header_overhead %d bytes (nb sdu not segmented %d)\n", frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->sdu_buffer_occupancy, max_li_overhead, header_overhead, rlc_pP->nb_sdu_no_segmented); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] BO : STATUS BUFFER %d bytes \n", frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->status_buffer_occupancy); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] BO : RETRANS BUFFER %d bytes \n", frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->retransmission_buffer_occupancy); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] BO : SDU BUFFER %d bytes + li_overhead %d bytes header_overhead %d bytes (nb sdu not segmented %d)\n", frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->sdu_buffer_occupancy, max_li_overhead, header_overhead, rlc_pP->nb_sdu_no_segmented); } #endif return rlc_pP->status_buffer_occupancy + rlc_pP->retransmission_buffer_occupancy + rlc_pP->sdu_buffer_occupancy + max_li_overhead + header_overhead; @@ -103,31 +104,46 @@ void rlc_am_release (rlc_am_entity_t *rlc_pP) } //----------------------------------------------------------------------------- -void config_req_rlc_am (rlc_am_entity_t *rlc_pP, u32_t frameP, u8_t eNB_flagP, module_id_t module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) +void config_req_rlc_am (frame_t frameP, + eNB_flag_t eNB_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + rlc_am_info_t *config_am_pP, + rb_id_t rb_idP, + rb_type_t rb_typeP) { //----------------------------------------------------------------------------- - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_%s][MOD %02d][][--- CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %02d][RB %02d]\n", + rlc_am_entity_t *rlc = NULL; + + LOG_D(RLC, "[FRAME %5u][%s][RRC][MOD %u/%u][][--- CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %u/%u][RB %u]\n", frameP, - ( Mac_rlc_xface->Is_cluster_head[module_idP] == 1) ? "eNB":"UE", - module_idP, - config_amP->max_retx_threshold, - config_amP->poll_pdu, - config_amP->poll_byte, - config_amP->t_poll_retransmit, - config_amP->t_reordering, - config_amP->t_status_prohibit, - module_idP, + ( eNB_flagP > 0) ? "eNB":"UE", + enb_module_idP, + ue_module_idP, + config_am_pP->max_retx_threshold, + config_am_pP->poll_pdu, + config_am_pP->poll_byte, + config_am_pP->t_poll_retransmit, + config_am_pP->t_reordering, + config_am_pP->t_status_prohibit, + enb_module_idP, + ue_module_idP, rb_idP); - rlc_am_init(rlc_pP,frameP); - rlc_am_set_debug_infos(rlc_pP, frameP, eNB_flagP, module_idP, rb_idP, rb_typeP); - rlc_am_configure(rlc_pP,frameP, - config_amP->max_retx_threshold, - config_amP->poll_pdu, - config_amP->poll_byte, - config_amP->t_poll_retransmit, - config_amP->t_reordering, - config_amP->t_status_prohibit); + if (eNB_flagP) { + rlc = &rlc_array_eNB[enb_module_idP][ue_module_idP][rb_idP].rlc.am; + } else { + rlc = &rlc_array_ue[ue_module_idP][rb_idP].rlc.am; + } + rlc_am_init(rlc,frameP); + rlc_am_set_debug_infos(rlc, frameP, eNB_flagP, enb_module_idP, ue_module_idP, rb_idP, rb_typeP); + rlc_am_configure(rlc,frameP, + config_am_pP->max_retx_threshold, + config_am_pP->poll_pdu, + config_am_pP->poll_byte, + config_am_pP->t_poll_retransmit, + config_am_pP->t_reordering, + config_am_pP->t_status_prohibit); } u32_t pollPDU_tab[PollPDU_pInfinity+1]={4,8,16,32,64,128,256,1024}; // What is PollPDU_pInfinity??? 1024 for now @@ -138,54 +154,70 @@ u32_t am_t_Reordering_tab[T_Reordering_spare1]={0,5,10,15,20,25,30,35,40,45,50,5 u32_t t_StatusProhibit_tab[T_StatusProhibit_spare8]={0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,300,350,400,450,500}; //----------------------------------------------------------------------------- -void config_req_rlc_am_asn1 (rlc_am_entity_t *rlc_pP, u32_t frameP, u8_t eNB_flagP, module_id_t module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) +void config_req_rlc_am_asn1 (frame_t frameP, + eNB_flag_t eNB_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + struct RLC_Config__am *config_am_pP, + rb_id_t rb_idP, + rb_type_t rb_typeP) { //----------------------------------------------------------------------------- - if ( (config_amP->ul_AM_RLC.maxRetxThreshold <= UL_AM_RLC__maxRetxThreshold_t32) && - (config_amP->ul_AM_RLC.pollPDU<=PollPDU_pInfinity) && - (config_amP->ul_AM_RLC.pollByte<PollByte_spare1) && - (config_amP->ul_AM_RLC.t_PollRetransmit<T_PollRetransmit_spare9) && - (config_amP->dl_AM_RLC.t_Reordering<T_Reordering_spare1) && - (config_amP->dl_AM_RLC.t_StatusProhibit<T_StatusProhibit_spare8) ){ - - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_%s][MOD %02d][][--- CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %02d][RB %02d]\n", - frameP, - ( Mac_rlc_xface->Is_cluster_head[module_idP] == 1) ? "eNB":"UE", - module_idP, - maxRetxThreshold_tab[config_amP->ul_AM_RLC.maxRetxThreshold], - pollPDU_tab[config_amP->ul_AM_RLC.pollPDU], - pollByte_tab[config_amP->ul_AM_RLC.pollByte], - PollRetransmit_tab[config_amP->ul_AM_RLC.t_PollRetransmit], - am_t_Reordering_tab[config_amP->dl_AM_RLC.t_Reordering], - t_StatusProhibit_tab[config_amP->dl_AM_RLC.t_StatusProhibit], - module_idP, - rb_idP); - - rlc_am_init(rlc_pP,frameP); - rlc_am_set_debug_infos(rlc_pP, frameP, eNB_flagP, module_idP, rb_idP, rb_typeP); - rlc_am_configure(rlc_pP,frameP, - maxRetxThreshold_tab[config_amP->ul_AM_RLC.maxRetxThreshold], - pollPDU_tab[config_amP->ul_AM_RLC.pollPDU], - pollByte_tab[config_amP->ul_AM_RLC.pollByte], - PollRetransmit_tab[config_amP->ul_AM_RLC.t_PollRetransmit], - am_t_Reordering_tab[config_amP->dl_AM_RLC.t_Reordering], - t_StatusProhibit_tab[config_amP->dl_AM_RLC.t_StatusProhibit]); + rlc_am_entity_t *rlc = NULL; + + if (eNB_flagP) { + rlc = &rlc_array_eNB[enb_module_idP][ue_module_idP][rb_idP].rlc.am; + } else { + rlc = &rlc_array_ue[ue_module_idP][rb_idP].rlc.am; + } + if ((config_am_pP->ul_AM_RLC.maxRetxThreshold <= UL_AM_RLC__maxRetxThreshold_t32) && + (config_am_pP->ul_AM_RLC.pollPDU<=PollPDU_pInfinity) && + (config_am_pP->ul_AM_RLC.pollByte<PollByte_spare1) && + (config_am_pP->ul_AM_RLC.t_PollRetransmit<T_PollRetransmit_spare9) && + (config_am_pP->dl_AM_RLC.t_Reordering<T_Reordering_spare1) && + (config_am_pP->dl_AM_RLC.t_StatusProhibit<T_StatusProhibit_spare8) ){ + + LOG_D(RLC, "[FRAME %5u][%s][RRC][MOD %u/%u][][--- CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %u/%u][RB %u]\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_module_idP, + ue_module_idP, + maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], + pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], + pollByte_tab[config_am_pP->ul_AM_RLC.pollByte], + PollRetransmit_tab[config_am_pP->ul_AM_RLC.t_PollRetransmit], + am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], + t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit], + enb_module_idP, + ue_module_idP, + rb_idP); - } - else { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_%s][MOD %02d][][--- ILLEGAL CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %02d][RB %02d], RLC-AM NOT CONFIGURED\n", - frameP, - ( Mac_rlc_xface->Is_cluster_head[module_idP] == 1) ? "eNB":"UE", - module_idP, - config_amP->ul_AM_RLC.maxRetxThreshold, - config_amP->ul_AM_RLC.pollPDU, - config_amP->ul_AM_RLC.pollByte, - config_amP->ul_AM_RLC.t_PollRetransmit, - config_amP->dl_AM_RLC.t_Reordering, - config_amP->dl_AM_RLC.t_StatusProhibit, - module_idP, - rb_idP); - } + rlc_am_init(rlc,frameP); + rlc_am_set_debug_infos(rlc, frameP, eNB_flagP, enb_module_idP, ue_module_idP, rb_idP, rb_typeP); + rlc_am_configure(rlc, + frameP, + maxRetxThreshold_tab[config_am_pP->ul_AM_RLC.maxRetxThreshold], + pollPDU_tab[config_am_pP->ul_AM_RLC.pollPDU], + pollByte_tab[config_am_pP->ul_AM_RLC.pollByte], + PollRetransmit_tab[config_am_pP->ul_AM_RLC.t_PollRetransmit], + am_t_Reordering_tab[config_am_pP->dl_AM_RLC.t_Reordering], + t_StatusProhibit_tab[config_am_pP->dl_AM_RLC.t_StatusProhibit]); + } else { + LOG_D(RLC, "[FRAME %5u][%s][RRC][MOD %u/%u][][--- ILLEGAL CONFIG_REQ (max_retx_threshold=%d poll_pdu=%d poll_byte=%d t_poll_retransmit=%d t_reord=%d t_status_prohibit=%d) --->][RLC_AM][MOD %u/%u][RB %u], RLC-AM NOT CONFIGURED\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_module_idP, + ue_module_idP, + config_am_pP->ul_AM_RLC.maxRetxThreshold, + config_am_pP->ul_AM_RLC.pollPDU, + config_am_pP->ul_AM_RLC.pollByte, + config_am_pP->ul_AM_RLC.t_PollRetransmit, + config_am_pP->dl_AM_RLC.t_Reordering, + config_am_pP->dl_AM_RLC.t_StatusProhibit, + enb_module_idP, + ue_module_idP, + rb_idP); + } } //----------------------------------------------------------------------------- @@ -250,7 +282,7 @@ void rlc_am_stat_req (rlc_am_entity_t *rlc_pP, } //----------------------------------------------------------------------------- void -rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) +rlc_am_get_pdus (rlc_am_entity_t *rlc_pP, frame_t frameP) { //----------------------------------------------------------------------------- int display_flag = 0; @@ -291,7 +323,13 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) } } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] DELAYED SENT STATUS PDU BECAUSE T-STATUS-PROHIBIT RUNNING (TIME-OUT FRAME %05d)\n",frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->t_status_prohibit.frame_time_out); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] DELAYED SENT STATUS PDU BECAUSE T-STATUS-PROHIBIT RUNNING (TIME-OUT FRAME %5u)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_status_prohibit.frame_time_out); } } /*while ((rlc_pP->nb_bytes_requested_by_mac > 0) && (stay_on_this_list)) { @@ -300,7 +338,7 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) if ( ((rlc_am_tx_control_pdu_management_t*)(pdu->data))->size <= rlc_pP->nb_bytes_requested_by_mac) { pdu = list_remove_head(&rlc_pP->control_pdu_list); #ifdef TRACE_RLC_AM_TX - msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d] SEND CONTROL PDU\n", ((rlc_am_entity_t *) rlc_pP)->module_id,((rlc_am_entity_t *) rlc_pP)->rb_id, frameP); + msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] SEND CONTROL PDU\n", ((rlc_am_entity_t *) rlc_pP)->module_id,((rlc_am_entity_t *) rlc_pP)->rb_id, frameP); #endif list_add_tail_eurecom (pdu, &rlc_pP->pdus_to_mac_layer); rlc_pP->nb_bytes_requested_by_mac = rlc_pP->nb_bytes_requested_by_mac - ((rlc_am_tx_control_pdu_management_t*)(pdu->data))->size; @@ -323,7 +361,14 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) if ((tx_data_pdu_management->header_and_payload_size <= rlc_pP->nb_bytes_requested_by_mac) && (tx_data_pdu_management->retx_count >= 0) && (tx_data_pdu_management->nack_so_start == 0) && (tx_data_pdu_management->nack_so_stop == 0x7FFF)) { mem_block_t* copy = rlc_am_retransmit_get_copy(rlc_pP, frameP,rlc_pP->first_retrans_pdu_sn); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] RE-SEND DATA PDU SN %04d %d BYTES\n",frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->first_retrans_pdu_sn, tx_data_pdu_management->header_and_payload_size); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RE-SEND DATA PDU SN %04d %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn, + tx_data_pdu_management->header_and_payload_size); rlc_pP->stat_tx_data_pdu += 1; rlc_pP->stat_tx_retransmit_pdu += 1; rlc_pP->stat_tx_retransmit_pdu_by_status += 1; @@ -337,7 +382,12 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) tx_data_pdu_management->retx_count += 1; return; } else if ((tx_data_pdu_management->retx_count >= 0) && (rlc_pP->nb_bytes_requested_by_mac >= RLC_AM_MIN_SEGMENT_SIZE_REQUEST)) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] SEND SEGMENT OF DATA PDU SN %04d MAC BYTES %d SIZE %d RTX COUNT %d nack_so_start %d nack_so_stop %04X(hex)\n", frameP, rlc_pP->module_id,rlc_pP->rb_id, + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] SEND SEGMENT OF DATA PDU SN %04d MAC BYTES %d SIZE %d RTX COUNT %d nack_so_start %d nack_so_stop %04X(hex)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, rlc_pP->first_retrans_pdu_sn, rlc_pP->nb_bytes_requested_by_mac, tx_data_pdu_management->header_and_payload_size, @@ -346,7 +396,15 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) tx_data_pdu_management->nack_so_stop); mem_block_t* copy = rlc_am_retransmit_get_subsegment(rlc_pP, frameP, rlc_pP->first_retrans_pdu_sn, &rlc_pP->nb_bytes_requested_by_mac); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] SEND SEGMENT OF DATA PDU SN %04d (NEW SO %05d)\n", frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->first_retrans_pdu_sn, tx_data_pdu_management->nack_so_start); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] SEND SEGMENT OF DATA PDU SN %04d (NEW SO %05d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn, + tx_data_pdu_management->nack_so_start); + rlc_pP->stat_tx_data_pdu += 1; rlc_pP->stat_tx_retransmit_pdu += 1; rlc_pP->stat_tx_retransmit_pdu_by_status += 1; @@ -361,7 +419,13 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) while ((rlc_pP->first_retrans_pdu_sn != rlc_pP->vt_s) && (!(rlc_pP->pdu_retrans_buffer[rlc_pP->first_retrans_pdu_sn].flags.retransmit))) { rlc_pP->first_retrans_pdu_sn = (rlc_pP->first_retrans_pdu_sn+1) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] UPDATED first_retrans_pdu_sn SN %04d\n", frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->first_retrans_pdu_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] UPDATED first_retrans_pdu_sn SN %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn); }; display_flag = 1; @@ -369,17 +433,28 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) // no more pdu to be retransmited rlc_pP->first_retrans_pdu_sn = -1; display_flag = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] CLEAR first_retrans_pdu_sn\n",frameP, rlc_pP->module_id, rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] CLEAR first_retrans_pdu_sn\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } if (display_flag > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] UPDATED first_retrans_pdu_sn %04d\n", frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->first_retrans_pdu_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] UPDATED first_retrans_pdu_sn %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn); } return; /* ONLY ONE TB PER TTI if ((tx_data_pdu_management->retx_count >= 0) && (rlc_pP->nb_bytes_requested_by_mac < RLC_AM_MIN_SEGMENT_SIZE_REQUEST)) { #ifdef TRACE_RLC_AM_TX - msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d] BREAK LOOP ON RETRANSMISSION BECAUSE ONLY %d BYTES ALLOWED TO TRANSMIT BY MAC\n",frameP, ((rlc_am_entity_t *) rlc_pP)->module_id,((rlc_am_entity_t *) rlc_pP)->rb_id, rlc_pP->nb_bytes_requested_by_mac); + msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] BREAK LOOP ON RETRANSMISSION BECAUSE ONLY %d BYTES ALLOWED TO TRANSMIT BY MAC\n",frameP, ((rlc_am_entity_t *) rlc_pP)->module_id,((rlc_am_entity_t *) rlc_pP)->rb_id, rlc_pP->nb_bytes_requested_by_mac); #endif break; }*/ @@ -398,7 +473,12 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) rlc_am_retransmit_any_pdu(rlc_pP,frameP); return; } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] COULD NOT RETRANSMIT ANY PDU BECAUSE ",frameP, rlc_pP->module_id, rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] COULD NOT RETRANSMIT ANY PDU BECAUSE ", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); if (rlc_pP->pdus_to_mac_layer.head != NULL) { LOG_D(RLC, "THERE ARE SOME PDUS READY TO TRANSMIT "); } @@ -413,21 +493,27 @@ rlc_am_get_pdus (rlc_am_entity_t *rlc_pP,u32_t frameP) break; default: - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] MAC_DATA_REQ UNKNOWN PROTOCOL STATE 0x%02X\n", frameP, rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->protocol_state); + LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_DATA_REQ UNKNOWN PROTOCOL STATE 0x%02X\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->protocol_state); } } //----------------------------------------------------------------------------- void -rlc_am_rx (void *argP, u32_t frameP, u8_t eNB_flagP, struct mac_data_ind data_indP) +rlc_am_rx (void *arg_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - rlc_am_entity_t *rlc = (rlc_am_entity_t *) argP; + rlc_am_entity_t *rlc = (rlc_am_entity_t *) arg_pP; switch (rlc->protocol_state) { case RLC_NULL_STATE: - LOG_N(RLC, "[RLC_AM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", argP); + LOG_N(RLC, "[RLC_AM %p] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", arg_pP); list_free (&data_indP.data); break; @@ -442,7 +528,7 @@ rlc_am_rx (void *argP, u32_t frameP, u8_t eNB_flagP, struct mac_data_ind data_in //----------------------------------------------------------------------------- struct mac_status_resp -rlc_am_mac_status_indication (void *rlc_pP, u32 frameP, u16 tb_sizeP, struct mac_status_ind tx_statusP) +rlc_am_mac_status_indication (void *rlc_pP, frame_t frameP, u16 tb_sizeP, struct mac_status_ind tx_statusP) { //----------------------------------------------------------------------------- struct mac_status_resp status_resp; @@ -471,36 +557,43 @@ rlc_am_mac_status_indication (void *rlc_pP, u32 frameP, u16 tb_sizeP, struct mac if ((rlc->input_sdus[rlc->current_sdu_index].mem_block != NULL) && (status_resp.buffer_occupancy_in_bytes)) { - //status_resp.buffer_occupancy_in_bytes += ((rlc_am_entity_t *) rlc)->tx_header_min_length_in_bytes; - status_resp.buffer_occupancy_in_pdus = rlc->nb_sdu; - diff_time = frameP - ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_creation_time; - - status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (u32_t) diff_time : (u32_t)(0xffffffff - diff_time + frameP) ; - - sdu_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_size; - sdu_remaining_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_remaining_size; - - status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size; - if (sdu_size == sdu_remaining_size) { + //status_resp.buffer_occupancy_in_bytes += ((rlc_am_entity_t *) rlc)->tx_header_min_length_in_bytes; + status_resp.buffer_occupancy_in_pdus = rlc->nb_sdu; + diff_time = frameP - ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_creation_time; + + status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (u32_t) diff_time : (u32_t)(0xffffffff - diff_time + frameP) ; + + sdu_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_size; + sdu_remaining_size = ((rlc_am_tx_sdu_management_t *) (rlc->input_sdus[rlc->current_sdu_index].mem_block->data))->sdu_remaining_size; + + status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size; + if (sdu_size == sdu_remaining_size) { status_resp.head_sdu_is_segmented = 0; - } - else { - status_resp.head_sdu_is_segmented = 1; - } - + } + else { + status_resp.head_sdu_is_segmented = 1; + } + } else { } #ifdef TRACE_RLC_AM_TX_STATUS if (tb_sizeP > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", frameP, rlc->module_id, rlc->rb_id, tb_sizeP, status_resp.buffer_occupancy_in_bytes); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", + frameP, + (rlc->is_enb) ? "eNB" : "UE", + rlc->enb_module_id, + rlc->ue_module_id, + rlc->rb_id, + tb_sizeP, + status_resp.buffer_occupancy_in_bytes); /*if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n",rlc->module_id, + msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n",rlc->module_id, rlc->rb_id, frameP, tx_statusP.no_pdu); } if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n",rlc->module_id, rlc->rb_id, + msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n",rlc->module_id, rlc->rb_id, frameP, tx_statusP.no_pdu); }*/ } @@ -509,7 +602,7 @@ frameP, tx_statusP.no_pdu); } //----------------------------------------------------------------------------- struct mac_data_req -rlc_am_mac_data_request (void *rlc_pP,u32 frameP) +rlc_am_mac_data_request (void *rlc_pP, frame_t frameP) { //----------------------------------------------------------------------------- struct mac_data_req data_req; @@ -535,7 +628,13 @@ rlc_am_mac_data_request (void *rlc_pP,u32 frameP) list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); //((rlc_am_entity_t *) rlc_pP)->tx_pdus += data_req.data.nb_elements; if ((nb_bytes_requested_by_mac + data_req.data.nb_elements) > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] MAC_DATA_REQUEST %05d BYTES REQUESTED -> %d TBs\n", frameP, l_rlc_p->module_id,l_rlc_p->rb_id, nb_bytes_requested_by_mac, data_req.data.nb_elements); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] MAC_DATA_REQUEST %05d BYTES REQUESTED -> %d TBs\n", + frameP, + (l_rlc_p->is_enb) ? "eNB" : "UE", + l_rlc_p->enb_module_id, + l_rlc_p->ue_module_id, + nb_bytes_requested_by_mac, + data_req.data.nb_elements); } data_req.buffer_occupancy_in_bytes = rlc_am_get_buffer_occupancy_in_bytes(l_rlc_p,frameP); data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; @@ -654,7 +753,7 @@ rlc_am_mac_data_request (void *rlc_pP,u32 frameP) } //----------------------------------------------------------------------------- void -rlc_am_mac_data_indication (void *rlc_pP, u32_t frameP, u8 eNB_flagP, struct mac_data_ind data_indP) +rlc_am_mac_data_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- rlc_am_entity_t *l_rlc_p = (rlc_am_entity_t *) rlc_pP; @@ -789,7 +888,7 @@ rlc_am_mac_data_indication (void *rlc_pP, u32_t frameP, u8 eNB_flagP, struct mac //----------------------------------------------------------------------------- void -rlc_am_data_req (void *rlc_pP, u32_t frameP, mem_block_t * sdu_pP) +rlc_am_data_req (void *rlc_pP, frame_t frameP, mem_block_t * sdu_pP) { //----------------------------------------------------------------------------- rlc_am_entity_t *rlc_p = (rlc_am_entity_t *) rlc_pP; @@ -838,12 +937,44 @@ rlc_am_data_req (void *rlc_pP, u32_t frameP, mem_block_t * sdu_pP) rlc_p->input_sdus[rlc_p->next_sdu_index].flags.no_new_sdu_segmented_in_last_pdu = 0; //rlc_p->input_sdus[rlc_p->next_sdu_index].li_index_for_discard = -1; rlc_p->next_sdu_index = (rlc_p->next_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; - LOG_I(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] RLC_AM_DATA_REQ size %d Bytes, NB SDU %d current_sdu_index=%d next_sdu_index=%d conf %d mui %d\n", frameP, rlc_p->module_id, rlc_p->rb_id, data_size, rlc_p->nb_sdu, rlc_p->current_sdu_index, rlc_p->next_sdu_index, conf, mui); + LOG_I(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ size %d Bytes, NB SDU %d current_sdu_index=%d next_sdu_index=%d conf %d mui %d\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + data_size, + rlc_p->nb_sdu, + rlc_p->current_sdu_index, + rlc_p->next_sdu_index, + conf, + mui); } else { - LOG_W(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d\n", frameP, rlc_p->module_id, rlc_p->rb_id, rlc_p->nb_sdu, rlc_p->current_sdu_index, rlc_p->next_sdu_index, RLC_AM_SDU_CONTROL_BUFFER_SIZE); + LOG_W(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ BUFFER FULL, NB SDU %d current_sdu_index=%d next_sdu_index=%d size_input_sdus_buffer=%d\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + rlc_p->nb_sdu, + rlc_p->current_sdu_index, + rlc_p->next_sdu_index, + RLC_AM_SDU_CONTROL_BUFFER_SIZE); LOG_W(RLC, " input_sdus[].mem_block=%p next input_sdus[].flags.segmented=%d\n", rlc_p->input_sdus[rlc_p->next_sdu_index].mem_block, rlc_p->input_sdus[rlc_p->next_sdu_index].flags.segmented); rlc_p->stat_tx_pdcp_sdu_discarded += 1; rlc_p->stat_tx_pdcp_bytes_discarded += ((struct rlc_am_data_req *) (sdu_pP->data))->data_size; free_mem_block (sdu_pP); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_REQ size %d Bytes, SDU DROPPED, INPUT BUFFER OVERFLOW NB SDU %d current_sdu_index=%d next_sdu_index=%d \n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + data_size, + rlc_p->nb_sdu, + rlc_p->current_sdu_index, + rlc_p->next_sdu_index); +#endif } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h index 49c60fb700e1b5e5a5f3a2e0d7770d6f20064237..ceac5a9e368a61521247ef1c641c79a2cb41eb24 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am.h @@ -96,29 +96,29 @@ public_rlc_am(void rlc_am_release (rlc_am_entity_t *rlcP);) * @{ */ -/*! \fn void config_req_rlc_am (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void config_req_rlc_am (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Configure the UL and DL parameters of the RLC AM -* \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] config_amP Configuration parameters for RLC AM instance. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -public_rlc_am(void config_req_rlc_am (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_am(void config_req_rlc_am (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_am_info_t * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);) -/*! \fn void config_req_rlc_am_asn1 (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void config_req_rlc_am_asn1 (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Configure the UL and DL parameters of the RLC AM with the asn1c autogenerated pameters structs -* \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] config_amP Configuration parameters for RLC AM instance. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -public_rlc_am(void config_req_rlc_am_asn1 (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_am(void config_req_rlc_am_asn1 (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, struct RLC_Config__am * config_amP, rb_id_t rb_idP, rb_type_t rb_typeP);) /** @} */ diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h index e82a724a07a3335c08f51f468d31e43e136e4754..9c7a0e41eb565ca180dcee599c90f8491aeccb98 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_entity.h @@ -55,19 +55,21 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis * \brief Structure containing a RLC AM instance protocol variables, statistic variables, allocation variables, buffers and other miscellaneous variables. */ typedef struct rlc_am_entity { - module_id_t module_id; /*!< \brief Virtualization index for this protocol instance, means handset or eNB index. */ - u16_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ - boolean_t is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ - boolean_t is_enb; /*!< \brief To know if the RLC belongs to a eNB or UE. */ + module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */ + module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance. */ + rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ + logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ + boolean_t is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ + boolean_t is_enb; /*!< \brief To know if the RLC belongs to a eNB or UE. */ - signed int sdu_buffer_occupancy; /*!< \brief Number of bytes of unsegmented SDUs. */ - signed int retransmission_buffer_occupancy; /*!< \brief Number of bytes of PDUs in retransmission buffer waiting for a ACK. */ - signed int status_buffer_occupancy; /*!< \brief Number of bytes of control PDUs waiting for transmission. */ + signed int sdu_buffer_occupancy; /*!< \brief Number of bytes of unsegmented SDUs. */ + signed int retransmission_buffer_occupancy; /*!< \brief Number of bytes of PDUs in retransmission buffer waiting for a ACK. */ + signed int status_buffer_occupancy; /*!< \brief Number of bytes of control PDUs waiting for transmission. */ //--------------------------------------------------------------------- // TX BUFFERS //--------------------------------------------------------------------- - mem_block_t* input_sdus_alloc; /*!< \brief Allocated memory for the input SDU buffer (for SDUs coming from upper layers). */ + mem_block_t* input_sdus_alloc; /*!< \brief Allocated memory for the input SDU buffer (for SDUs coming from upper layers). */ rlc_am_tx_sdu_management_t *input_sdus; /*!< \brief Input SDU buffer (for SDUs coming from upper layers). */ signed int nb_sdu; /*!< \brief Total number of valid rlc_am_tx_sdu_management_t in input_sdus[]. */ signed int nb_sdu_no_segmented; /*!< \brief Total number of SDUs not segmented and partially segmented. */ @@ -88,7 +90,7 @@ typedef struct rlc_am_entity { //--------------------------------------------------------------------- list2_t receiver_buffer; /*!< \brief Receiver buffer implemented with a list. */ mem_block_t *output_sdu_in_construction; /*!< \brief Memory area where a complete SDU is reassemblied before being send to upper layers. */ - s32_t output_sdu_size_to_write; /*!< \brief Size of the reassemblied SDU. */ + sdu_size_t output_sdu_size_to_write; /*!< \brief Size of the reassemblied SDU. */ //--------------------------------------------------------------------- @@ -98,19 +100,19 @@ typedef struct rlc_am_entity { //----------------------------- // TX STATE VARIABLES //----------------------------- - u16_t vt_a; /*!< \brief Acknowledgement state variable. This state variable holds the value of the SN of the next AMD PDU for which a positive acknowledgment is to be received in-sequence, and it serves as the lower edge of the transmitting window. It is initially set to 0, and is updated whenever the AM RLC entity receives a positive acknowledgment for an AMD PDU with SN = VT(A).*/ - u16_t vt_ms; /*!< \brief Maximum send state variable. This state variable equals VT(A) + AM_Window_Size, and it serves as the higher edge of the transmitting window. */ - u16_t vt_s; /*!< \brief Send state variable. This state variable holds the value of the SN to be assigned for the next newly generated AMD PDU. It is initially set to 0, and is updated whenever the AM RLC entity delivers an AMD PDU with SN = VT(S).*/ - u16_t poll_sn; /*!< \brief Poll send state variable. This state variable holds the value of VT(S)-1 upon the most recent transmission of a RLC data PDU with the poll bit set to “1â€. It is initially set to 0.*/ + rlc_usn_t vt_a; /*!< \brief Acknowledgement state variable. This state variable holds the value of the SN of the next AMD PDU for which a positive acknowledgment is to be received in-sequence, and it serves as the lower edge of the transmitting window. It is initially set to 0, and is updated whenever the AM RLC entity receives a positive acknowledgment for an AMD PDU with SN = VT(A).*/ + rlc_usn_t vt_ms; /*!< \brief Maximum send state variable. This state variable equals VT(A) + AM_Window_Size, and it serves as the higher edge of the transmitting window. */ + rlc_usn_t vt_s; /*!< \brief Send state variable. This state variable holds the value of the SN to be assigned for the next newly generated AMD PDU. It is initially set to 0, and is updated whenever the AM RLC entity delivers an AMD PDU with SN = VT(S).*/ + rlc_usn_t poll_sn; /*!< \brief Poll send state variable. This state variable holds the value of VT(S)-1 upon the most recent transmission of a RLC data PDU with the poll bit set to “1â€. It is initially set to 0.*/ //----------------------------- // RX STATE VARIABLES //----------------------------- - u16_t vr_r; /*!< \brief Receive state variable. This state variable holds the value of the SN following the last in-sequence completely received AMD PDU, and it serves as the lower edge of the receiving window. It is initially set to 0, and is updated whenever the AM RLC entity receives an AMD PDU with SN = VR(R). */ - u16_t vr_mr; /*!< \brief Maximum acceptable receive state variable. This state variable equals VR(R) + AM_Window_Size, and it holds the value of the SN of the first AMD PDU that is beyond the receiving window and serves as the higher edge of the receiving window. */ - u16_t vr_x; /*!< \brief t-Reordering state variable. This state variable holds the value of the SN following the SN of the RLC data PDU which triggered t-Reordering. */ - u16_t vr_ms; /*!< \brief Maximum STATUS transmit state variable. This state variable holds the highest possible value of the SN which can be indicated by “ACK_SN†when a STATUS PDU needs to be constructed. It is initially set to 0. */ - u16_t vr_h; /*!< \brief Highest received state variable. This state variable holds the value of the SN following the SN of the RLC data PDU with the highest SN among received RLC data PDUs. It is initially set to 0. */ + rlc_usn_t vr_r; /*!< \brief Receive state variable. This state variable holds the value of the SN following the last in-sequence completely received AMD PDU, and it serves as the lower edge of the receiving window. It is initially set to 0, and is updated whenever the AM RLC entity receives an AMD PDU with SN = VR(R). */ + rlc_usn_t vr_mr; /*!< \brief Maximum acceptable receive state variable. This state variable equals VR(R) + AM_Window_Size, and it holds the value of the SN of the first AMD PDU that is beyond the receiving window and serves as the higher edge of the receiving window. */ + rlc_usn_t vr_x; /*!< \brief t-Reordering state variable. This state variable holds the value of the SN following the SN of the RLC data PDU which triggered t-Reordering. */ + rlc_usn_t vr_ms; /*!< \brief Maximum STATUS transmit state variable. This state variable holds the highest possible value of the SN which can be indicated by “ACK_SN†when a STATUS PDU needs to be constructed. It is initially set to 0. */ + rlc_usn_t vr_h; /*!< \brief Highest received state variable. This state variable holds the value of the SN following the SN of the RLC data PDU with the highest SN among received RLC data PDUs. It is initially set to 0. */ //----------------------------- // TIMERS CONFIGURED BY RRC @@ -183,12 +185,7 @@ typedef struct rlc_am_entity { // note occupancy of other buffers is deducted from nb elements in lists u32_t buffer_occupancy_retransmission_buffer; /*!< \brief Number of PDUs. */ - //************************************************************** - // new members - //************************************************************** u8_t allocation; /*!< \brief Boolean for rlc_am_entity_t struct allocation. */ - u8_t location; /*!< \brief EnodeB / UE. */ - } rlc_am_entity_t; /** @} */ # endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c index b2c088ae664645af23606fa1acd65ae3c0995f2e..7c911941c3d4ddaefa0d062a00767d6a72fe9ef5 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.c @@ -42,7 +42,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #define TRACE_RLC_AM_FREE_SDU //----------------------------------------------------------------------------- -void rlc_am_free_in_sdu(rlc_am_entity_t *rlcP, u32_t frame, unsigned int index_in_bufferP) +void rlc_am_free_in_sdu(rlc_am_entity_t *rlcP, frame_t frameP, unsigned int index_in_bufferP) //----------------------------------------------------------------------------- { if (index_in_bufferP <= RLC_AM_SDU_CONTROL_BUFFER_SIZE) { @@ -65,7 +65,16 @@ void rlc_am_free_in_sdu(rlc_am_entity_t *rlcP, u32_t frame, unsigned int index_i } } #ifdef TRACE_RLC_AM_FREE_SDU - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][FREE SDU] SDU INDEX %03d current_sdu_index=%d next_sdu_index=%d nb_sdu_no_segmented=%d\n", frame, rlcP->module_id, rlcP->rb_id, index_in_bufferP, rlcP->current_sdu_index, rlcP->next_sdu_index, rlcP->nb_sdu_no_segmented); + LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][FREE SDU] SDU INDEX %03d current_sdu_index=%d next_sdu_index=%d nb_sdu_no_segmented=%d\n", + frameP, + (rlcP->is_enb) ? "eNB" : "UE", + rlcP->enb_module_id, + rlcP->ue_module_id, + rlcP->rb_id, + index_in_bufferP, + rlcP->current_sdu_index, + rlcP->next_sdu_index, + rlcP->nb_sdu_no_segmented); #endif } // called when segmentation is done diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h index 9b3f3f8c79c5661aee9fd29e93920dff56f682db..6d7bc70b55a8f3b0974f5ce305f474b2e8354d18 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_in_sdu.h @@ -57,14 +57,14 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_am_in_sdu(x) extern x # endif # endif -/*! \fn void rlc_am_free_in_sdu (rlc_am_entity_t *rlcP, u32_t frame, unsigned int index_in_bufferP) +/*! \fn void rlc_am_free_in_sdu (rlc_am_entity_t *rlcP, frame_t frameP, unsigned int index_in_bufferP) * \brief Free a higher layer SDU stored in input_sdus[] buffer. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] index_in_bufferP Position index of the SDU. * \note Update also the RLC AM instance variables nb_sdu, current_sdu_index, nb_sdu_no_segmented. */ -protected_rlc_am_in_sdu(void rlc_am_free_in_sdu (rlc_am_entity_t *rlcP, u32_t frame, unsigned int index_in_bufferP);) +protected_rlc_am_in_sdu(void rlc_am_free_in_sdu (rlc_am_entity_t *rlcP, frame_t frameP, unsigned int index_in_bufferP);) /*! \fn void rlc_am_free_in_sdu_data (rlc_am_entity_t *rlcP, unsigned int index_in_bufferP) diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c index 35200d4967617357de89dc6c7f1e5a706df5b780..cf88f9de46f9d1f62250ba64c1efd927bf552b21 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.c @@ -36,119 +36,152 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -void rlc_am_init(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_init(rlc_am_entity_t *rlc_pP, frame_t frameP) //----------------------------------------------------------------------------- { - int saved_allocation = rlcP->allocation; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX][INIT] STATE VARIABLES, BUFFERS, LISTS\n", frame); - memset(rlcP, 0, sizeof(rlc_am_entity_t)); - rlcP->allocation = saved_allocation; - - list2_init(&rlcP->receiver_buffer, "RX BUFFER"); - list_init(&rlcP->pdus_to_mac_layer, "PDUS TO MAC"); - list_init(&rlcP->control_pdu_list, "CONTROL PDU LIST"); - list_init(&rlcP->segmentation_pdu_list, "SEGMENTATION PDU LIST"); + int saved_allocation = rlc_pP->allocation; + LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][INIT] STATE VARIABLES, BUFFERS, LISTS\n", frameP); + memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); + rlc_pP->allocation = saved_allocation; + + list2_init(&rlc_pP->receiver_buffer, "RX BUFFER"); + list_init(&rlc_pP->pdus_to_mac_layer, "PDUS TO MAC"); + list_init(&rlc_pP->control_pdu_list, "CONTROL PDU LIST"); + list_init(&rlc_pP->segmentation_pdu_list, "SEGMENTATION PDU LIST"); //LOG_D(RLC,"RLC_AM_SDU_CONTROL_BUFFER_SIZE %d sizeof(rlc_am_tx_sdu_management_t) %d \n", RLC_AM_SDU_CONTROL_BUFFER_SIZE, sizeof(rlc_am_tx_sdu_management_t)); - rlcP->input_sdus_alloc = get_free_mem_block(RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); - rlcP->input_sdus = (rlc_am_tx_sdu_management_t*)((rlcP->input_sdus_alloc)->data); - rlcP->pdu_retrans_buffer_alloc = get_free_mem_block((u16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); - rlcP->pdu_retrans_buffer = (rlc_am_tx_data_pdu_management_t*)((rlcP->pdu_retrans_buffer_alloc)->data); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX][INIT] input_sdus[] = %p element size=%d\n", frame, rlcP->input_sdus,sizeof(rlc_am_tx_sdu_management_t)); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX][INIT] pdu_retrans_buffer[] = %p element size=%d\n", frame, rlcP->pdu_retrans_buffer,sizeof(rlc_am_tx_data_pdu_management_t)); + rlc_pP->input_sdus_alloc = get_free_mem_block(RLC_AM_SDU_CONTROL_BUFFER_SIZE*sizeof(rlc_am_tx_sdu_management_t)); + rlc_pP->input_sdus = (rlc_am_tx_sdu_management_t*)((rlc_pP->input_sdus_alloc)->data); + rlc_pP->pdu_retrans_buffer_alloc = get_free_mem_block((u16_t)((unsigned int)RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE*(unsigned int)sizeof(rlc_am_tx_data_pdu_management_t))); + rlc_pP->pdu_retrans_buffer = (rlc_am_tx_data_pdu_management_t*)((rlc_pP->pdu_retrans_buffer_alloc)->data); + LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][INIT] input_sdus[] = %p element size=%d\n", frameP, rlc_pP->input_sdus,sizeof(rlc_am_tx_sdu_management_t)); + LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][INIT] pdu_retrans_buffer[] = %p element size=%d\n", frameP, rlc_pP->pdu_retrans_buffer,sizeof(rlc_am_tx_data_pdu_management_t)); // TX state variables - //rlcP->vt_a = 0; - rlcP->vt_ms = rlcP->vt_a + RLC_AM_WINDOW_SIZE; - //rlcP->vt_s = 0; - //rlcP->poll_sn = 0; + //rlc_pP->vt_a = 0; + rlc_pP->vt_ms = rlc_pP->vt_a + RLC_AM_WINDOW_SIZE; + //rlc_pP->vt_s = 0; + //rlc_pP->poll_sn = 0; // TX counters - //rlcP->c_pdu_without_poll = 0; - //rlcP->c_byte_without_poll = 0; + //rlc_pP->c_pdu_without_poll = 0; + //rlc_pP->c_byte_without_poll = 0; // RX state variables - //rlcP->vr_r = 0; - rlcP->vr_mr = rlcP->vr_r + RLC_AM_WINDOW_SIZE; - //rlcP->vr_x = 0; - //rlcP->vr_ms = 0; - //rlcP->vr_h = 0; - - rlcP->last_frame_status_indication = 123456; // any value > 1 - rlcP->first_retrans_pdu_sn = -1; + //rlc_pP->vr_r = 0; + rlc_pP->vr_mr = rlc_pP->vr_r + RLC_AM_WINDOW_SIZE; + //rlc_pP->vr_x = 0; + //rlc_pP->vr_ms = 0; + //rlc_pP->vr_h = 0; + + rlc_pP->last_frame_status_indication = 123456; // any value > 1 + rlc_pP->first_retrans_pdu_sn = -1; } //----------------------------------------------------------------------------- -void rlc_am_cleanup(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_cleanup(rlc_am_entity_t *rlc_pP, frame_t frameP) //----------------------------------------------------------------------------- { - LOG_I(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][CLEANUP]\n", frame, rlcP->module_id, rlcP->rb_id); - - list2_free(&rlcP->receiver_buffer); - list_free(&rlcP->pdus_to_mac_layer); - list_free(&rlcP->control_pdu_list); - list_free(&rlcP->segmentation_pdu_list); - - - if (rlcP->output_sdu_in_construction != NULL) { - free_mem_block(rlcP->output_sdu_in_construction); - rlcP->output_sdu_in_construction = NULL; + LOG_I(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][CLEANUP]\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + + list2_free(&rlc_pP->receiver_buffer); + list_free(&rlc_pP->pdus_to_mac_layer); + list_free(&rlc_pP->control_pdu_list); + list_free(&rlc_pP->segmentation_pdu_list); + + + if (rlc_pP->output_sdu_in_construction != NULL) { + free_mem_block(rlc_pP->output_sdu_in_construction); + rlc_pP->output_sdu_in_construction = NULL; } unsigned int i; - if (rlcP->input_sdus_alloc != NULL) { + if (rlc_pP->input_sdus_alloc != NULL) { for (i=0; i < RLC_AM_SDU_CONTROL_BUFFER_SIZE; i++) { - if (rlcP->input_sdus[i].mem_block != NULL) { - free_mem_block(rlcP->input_sdus[i].mem_block); - rlcP->input_sdus[i].mem_block = NULL; + if (rlc_pP->input_sdus[i].mem_block != NULL) { + free_mem_block(rlc_pP->input_sdus[i].mem_block); + rlc_pP->input_sdus[i].mem_block = NULL; } } - free_mem_block(rlcP->input_sdus_alloc); - rlcP->input_sdus_alloc = NULL; - rlcP->input_sdus = NULL; + free_mem_block(rlc_pP->input_sdus_alloc); + rlc_pP->input_sdus_alloc = NULL; + rlc_pP->input_sdus = NULL; } - if (rlcP->pdu_retrans_buffer_alloc != NULL) { + if (rlc_pP->pdu_retrans_buffer_alloc != NULL) { for (i=0; i < RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; i++) { - if (rlcP->pdu_retrans_buffer[i].mem_block != NULL) { - free_mem_block(rlcP->pdu_retrans_buffer[i].mem_block); - rlcP->pdu_retrans_buffer[i].mem_block = NULL; + if (rlc_pP->pdu_retrans_buffer[i].mem_block != NULL) { + free_mem_block(rlc_pP->pdu_retrans_buffer[i].mem_block); + rlc_pP->pdu_retrans_buffer[i].mem_block = NULL; } } - free_mem_block(rlcP->pdu_retrans_buffer_alloc); - rlcP->pdu_retrans_buffer_alloc = NULL; - rlcP->pdu_retrans_buffer = NULL; + free_mem_block(rlc_pP->pdu_retrans_buffer_alloc); + rlc_pP->pdu_retrans_buffer_alloc = NULL; + rlc_pP->pdu_retrans_buffer = NULL; } + memset(rlc_pP, 0, sizeof(rlc_am_entity_t)); } //----------------------------------------------------------------------------- -void rlc_am_configure(rlc_am_entity_t *rlcP, - u32_t frame, - u16_t max_retx_thresholdP, - u16_t poll_pduP, - u16_t poll_byteP, - u32_t t_poll_retransmitP, - u32_t t_reorderingP, - u32_t t_status_prohibitP) +void rlc_am_configure(rlc_am_entity_t *rlc_pP, + frame_t frameP, + u16_t max_retx_thresholdP, + u16_t poll_pduP, + u16_t poll_byteP, + u32_t t_poll_retransmitP, + u32_t t_reorderingP, + u32_t t_status_prohibitP) //----------------------------------------------------------------------------- { - LOG_I(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][CONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", frame, rlcP->module_id, rlcP->rb_id, max_retx_thresholdP, poll_pduP, poll_byteP, t_poll_retransmitP, t_reorderingP, t_status_prohibitP); - - rlcP->max_retx_threshold = max_retx_thresholdP; - rlcP->poll_pdu = poll_pduP; - rlcP->poll_byte = poll_byteP; - rlcP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - - rlc_am_init_timer_poll_retransmit(rlcP, t_poll_retransmitP); - rlc_am_init_timer_reordering (rlcP, t_reorderingP); - rlc_am_init_timer_status_prohibit(rlcP, t_status_prohibitP); + LOG_I(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][CONFIGURE] max_retx_threshold %d poll_pdu %d poll_byte %d t_poll_retransmit %d t_reordering %d t_status_prohibit %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_retx_thresholdP, + poll_pduP, + poll_byteP, + t_poll_retransmitP, + t_reorderingP, + t_status_prohibitP); + + rlc_pP->max_retx_threshold = max_retx_thresholdP; + rlc_pP->poll_pdu = poll_pduP; + rlc_pP->poll_byte = poll_byteP; + rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; + + rlc_am_init_timer_poll_retransmit(rlc_pP, t_poll_retransmitP); + rlc_am_init_timer_reordering (rlc_pP, t_reorderingP); + rlc_am_init_timer_status_prohibit(rlc_pP, t_status_prohibitP); } //----------------------------------------------------------------------------- -void rlc_am_set_debug_infos(rlc_am_entity_t *rlcP, u32 frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +void rlc_am_set_debug_infos(rlc_am_entity_t *rlc_pP, + frame_t frameP, + eNB_flag_t eNB_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + rb_id_t rb_idP, + rb_type_t rb_typeP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SET DEBUG INFOS] module_id %d rb_id %d rb_type %d\n", frame, module_idP, rb_idP, module_idP, rb_idP, rb_typeP); - - rlcP->module_id = module_idP; - rlcP->rb_id = rb_idP; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SET DEBUG INFOS] module_id %d rb_id %d rb_type %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rb_idP, + enb_module_idP, + ue_module_idP, + rb_idP, + rb_typeP); + + rlc_pP->enb_module_id = enb_module_idP; + rlc_pP->ue_module_id = ue_module_idP; + rlc_pP->rb_id = rb_idP; if (rb_typeP != SIGNALLING_RADIO_BEARER) { - rlcP->is_data_plane = 1; + rlc_pP->is_data_plane = 1; } else { - rlcP->is_data_plane = 0; + rlc_pP->is_data_plane = 0; } - rlcP->is_enb = eNB_flagP; + rlc_pP->is_enb = eNB_flagP; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h index a03b03096327c53d8eb7fc107b386eeaad24ddfd..3b0d272a3ce22f79e9de2b870116effda8156876 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_init.h @@ -78,23 +78,23 @@ typedef volatile struct { } rlc_am_info_t; //----------------------------------------------------------------------------- -/*! \fn void rlc_am_init (rlc_am_entity_t* rlcP,u32_t frame) +/*! \fn void rlc_am_init (rlc_am_entity_t* rlc_pP,frame_t frameP) * \brief Initialize the RLC AM protocol instance, reset variables, allocate buffers, lists, then, the next step in order have a running RLC AM instance is to configure and set debug informations for this RLC instance. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index */ -public_rlc_am_init( void rlc_am_init (rlc_am_entity_t* rlcP,u32_t frame);) +public_rlc_am_init( void rlc_am_init (rlc_am_entity_t* rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_cleanup(rlc_am_entity_t* rlcP,u32_t frame) +/*! \fn void rlc_am_cleanup(rlc_am_entity_t* rlc_pP,frame_t frameP) * \brief Free all memory resources allocated and kept by this RLC AM instance. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index */ -public_rlc_am_init( void rlc_am_cleanup(rlc_am_entity_t* rlcP,u32_t frame);) +public_rlc_am_init( void rlc_am_cleanup(rlc_am_entity_t* rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_configure(rlc_am_entity_t *rlcP, u32_t frame, u16_t max_retx_thresholdP, u16_t poll_pduP, u16_t poll_byteP, u32_t t_poll_retransmitP, u32_t t_reorderingP, u32_t t_status_prohibitP) +/*! \fn void rlc_am_configure(rlc_am_entity_t *rlc_pP, frame_t frameP, u16_t max_retx_thresholdP, u16_t poll_pduP, u16_t poll_byteP, u32_t t_poll_retransmitP, u32_t t_reorderingP, u32_t t_status_prohibitP) * \brief Set RLC AM protocol parameters. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index * \param[in] max_retx_thresholdP Limit the number of retransmissions of an AMD PDU. @@ -104,8 +104,8 @@ AMD PDU. * \param[in] t_reorderingP This timer is used by the receiving side of an AM RLC entity in order to detect loss of RLC PDUs at lower layer, value in frames. * \param[in] t_status_prohibitP This timer is used by the receiving side of an AM RLC entity in order to prohibit transmission of a STATUS PDU, value in frames. */ -public_rlc_am_init( void rlc_am_configure(rlc_am_entity_t *rlcP, - u32_t frame, +public_rlc_am_init( void rlc_am_configure(rlc_am_entity_t *rlc_pP, + frame_t frameP, u16_t max_retx_thresholdP, u16_t poll_pduP, u16_t poll_byteP, @@ -113,15 +113,16 @@ public_rlc_am_init( void rlc_am_configure(rlc_am_entity_t *rlcP, u32_t t_reorderingP, u32_t t_status_prohibitP);) -/*! \fn void rlc_am_set_debug_infos(rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void rlc_am_set_debug_infos(rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Set informations that will be displayed in traces, helping the debug process. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualization variable, module identifier. +* \param[in] enb_module_idP eNB Virtualization variable, module identifier. +* \param[in] ue_module_idP UE Virtualization variable, module identifier. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or data). */ -public_rlc_am_init( void rlc_am_set_debug_infos(rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_am_init( void rlc_am_set_debug_infos(rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c index a4f929a3cc41036fee700a8f781634213e673f64..e5ba3575eaedd28edee5623b518b9824e882da70 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.c @@ -25,11 +25,12 @@ Openair Tech : openair_tech@eurecom.fr Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ #define RLC_AM_MODULE #define RLC_AM_REASSEMBLY_C #include "platform_types.h" //----------------------------------------------------------------------------- +#include "assertions.h" #include "rlc.h" #include "rlc_am.h" #include "list.h" @@ -38,221 +39,301 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis //#define TRACE_RLC_AM_RX_DECODE //----------------------------------------------------------------------------- -inline void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlcP) +inline void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlc_pP) //----------------------------------------------------------------------------- { - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; } //----------------------------------------------------------------------------- -void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlcP, u32_t frame) +void rlc_am_reassembly (u8_t * src_pP, s32_t lengthP, rlc_am_entity_t *rlc_pP, frame_t frameP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] reassembly() %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, lengthP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] reassembly() %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + lengthP); - if (rlcP->output_sdu_in_construction == NULL) { - rlcP->output_sdu_in_construction = get_free_mem_block (RLC_SDU_MAX_SIZE); - rlcP->output_sdu_size_to_write = 0; - assert(rlcP->output_sdu_in_construction != NULL); + if (rlc_pP->output_sdu_in_construction == NULL) { + rlc_pP->output_sdu_in_construction = get_free_mem_block (RLC_SDU_MAX_SIZE); + rlc_pP->output_sdu_size_to_write = 0; + assert(rlc_pP->output_sdu_in_construction != NULL); } - if (rlcP->output_sdu_in_construction != NULL) { + if (rlc_pP->output_sdu_in_construction != NULL) { - // check if no overflow in size - if ((rlcP->output_sdu_size_to_write + lengthP) <= RLC_SDU_MAX_SIZE) { - memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, lengthP); + // check if no overflow in size + if ((rlc_pP->output_sdu_size_to_write + lengthP) <= RLC_SDU_MAX_SIZE) { + memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); - rlcP->output_sdu_size_to_write += lengthP; - } else { - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", frame, rlcP->module_id, rlcP->rb_id); - // erase SDU - rlcP->output_sdu_size_to_write = 0; - } + rlc_pP->output_sdu_size_to_write += lengthP; + } else { + LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_IND, SDU SIZE OVERFLOW SDU GARBAGED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + // erase SDU + rlc_pP->output_sdu_size_to_write = 0; + } } else { - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", frame, rlcP->module_id, rlcP->rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PAYLOAD] ERROR OUTPUT SDU IS NULL\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_AM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif } } //----------------------------------------------------------------------------- -void rlc_am_send_sdu (rlc_am_entity_t *rlcP,u32_t frame, u8_t eNB_flag) +void rlc_am_send_sdu (rlc_am_entity_t *rlc_pP,frame_t frameP, eNB_flag_t eNB_flagP) //----------------------------------------------------------------------------- { - if ((rlcP->output_sdu_in_construction)) { - LOG_D(RLC, "\n\n\n[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND_SDU] %d bytes sdu %p\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction); - if (rlcP->output_sdu_size_to_write > 0) { - u8_t eNB_id; - u8_t UE_id; - if (eNB_flag == 0) { - /* FIXME: force send on first eNB */ - eNB_id = 0; - UE_id = rlcP->module_id - NB_eNB_INST; - } else { - UE_id = rlcP->rb_id / NB_RB_MAX; - eNB_id = rlcP->module_id; - } - rlcP->stat_rx_pdcp_sdu += 1; - rlcP->stat_rx_pdcp_bytes += rlcP->output_sdu_size_to_write; - #ifdef TEST_RLC_AM - rlc_am_v9_3_0_test_data_ind (rlcP->module_id, - rlcP->rb_id, - rlcP->output_sdu_size_to_write, - rlcP->output_sdu_in_construction); - #else - rlc_data_ind (rlcP->module_id, eNB_id, UE_id, frame, eNB_flag, RLC_MBMS_NO, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction, rlcP->is_data_plane); - #endif - rlcP->output_sdu_in_construction = NULL; - } else { - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", frame,rlcP->module_id, rlcP->rb_id); - //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlcP->module_id); - //free_mem_block (rlcP->output_sdu_in_construction); - assert(3==4); - } - rlcP->output_sdu_size_to_write = 0; + if ((rlc_pP->output_sdu_in_construction)) { + LOG_D(RLC, "\n\n\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND_SDU] %d bytes sdu %p\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->output_sdu_size_to_write, + rlc_pP->output_sdu_in_construction); + if (rlc_pP->output_sdu_size_to_write > 0) { + rlc_pP->stat_rx_pdcp_sdu += 1; + rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; +#ifdef TEST_RLC_AM + rlc_am_v9_3_0_test_data_ind (rlc_pP->module_id, + rlc_pP->rb_id, + rlc_pP->output_sdu_size_to_write, + rlc_pP->output_sdu_in_construction); +#else + rlc_data_ind (rlc_pP->enb_module_id, rlc_pP->ue_module_id, frameP, eNB_flagP, RLC_MBMS_NO, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction, rlc_pP->is_data_plane); +#endif + rlc_pP->output_sdu_in_construction = NULL; + } else { + LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + //msg("[RLC_AM][MOD %d] Freeing mem_block ...\n", rlc_pP->module_id); + //free_mem_block (rlc_pP->output_sdu_in_construction); + assert(3==4); + } + rlc_pP->output_sdu_size_to_write = 0; } } //----------------------------------------------------------------------------- -void rlc_am_reassemble_pdu(rlc_am_entity_t* rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP) { -//----------------------------------------------------------------------------- - int i,j; +void rlc_am_reassemble_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t* tb_pP) { + //----------------------------------------------------------------------------- + int i,j; - rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", frame, rlcP->module_id, rlcP->rb_id, pdu_info->sn); + rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU SN=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info->sn); #ifdef TRACE_RLC_AM_RX_DECODE - rlc_am_display_data_pdu_infos(rlcP, frame, pdu_info); + rlc_am_display_data_pdu_infos(rlc_pP, frameP, pdu_info); #endif - if (pdu_info->e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { - switch (pdu_info->fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", frame, rlcP->module_id, rlcP->rb_id); - // one complete SDU - rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary - rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", frame, rlcP->module_id, rlcP->rb_id); - // one beginning segment of SDU in PDU - rlc_am_send_sdu(rlcP,frame,eNB_flag); // may be not necessary - rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", frame, rlcP->module_id, rlcP->rb_id); - // one last segment of SDU - //if (rlcP->reassembly_missing_sn_detected == 0) { - rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - //} // else { clear sdu already done - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", frame, rlcP->module_id, rlcP->rb_id); - //if (rlcP->reassembly_missing_sn_detected == 0) { - // one whole segment of SDU in PDU - rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlcP,frame); - //} else { - // rlcP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code - //} + if (pdu_info->e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { + switch (pdu_info->fi) { + case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + // one complete SDU + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); // may be not necessary + rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); // may be not necessary + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + // one beginning segment of SDU in PDU + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); // may be not necessary + rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlc_pP,frameP); + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + // one last segment of SDU + //if (rlc_pP->reassembly_missing_sn_detected == 0) { + rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + //} // else { clear sdu already done + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + //if (rlc_pP->reassembly_missing_sn_detected == 0) { + // one whole segment of SDU in PDU + rlc_am_reassembly (pdu_info->payload, pdu_info->payload_size, rlc_pP,frameP); + //} else { + // rlc_pP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code + //} - break; + break; #ifdef USER_MODE - default: - assert(0 != 0); + default: + assert(0 != 0); #endif + } + } else { + switch (pdu_info->fi) { + case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + for (i=0; i < pdu_info->num_li; i++) { + LOG_D(RLC, "%d ",pdu_info->li_list[i]); + } + LOG_D(RLC, "\n"); + //msg(" remaining size %d\n",size); + // N complete SDUs + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = 0; + for (i = 0; i < pdu_info->num_li; i++) { + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = j + pdu_info->li_list[i]; + } + if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug + // data is already ok, done by last loop above + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + } + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + for (i=0; i < pdu_info->num_li; i++) { + LOG_D(RLC, "%d ",pdu_info->li_list[i]); + } + LOG_D(RLC, "\n"); + //msg(" remaining size %d\n",size); + // N complete SDUs + one segment of SDU in PDU + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = 0; + for (i = 0; i < pdu_info->num_li; i++) { + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = j + pdu_info->li_list[i]; } - } else { - switch (pdu_info->fi) { - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=11 (00) Li=", frame, rlcP->module_id, rlcP->rb_id); - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // N complete SDUs - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = 0; - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = j + pdu_info->li_list[i]; - } - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - } - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=10 (01) Li=", frame, rlcP->module_id, rlcP->rb_id); - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // N complete SDUs + one segment of SDU in PDU - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = 0; - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = j + pdu_info->li_list[i]; - } - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP, frame); - } - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", frame, rlcP->module_id, rlcP->rb_id); - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - // one last segment of SDU + N complete SDUs in PDU - j = 0; - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = j + pdu_info->li_list[i]; - } - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - } - //rlcP->reassembly_missing_sn_detected = 0; - break; - case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", frame, rlcP->module_id, rlcP->rb_id); - for (i=0; i < pdu_info->num_li; i++) { - LOG_D(RLC, "%d ",pdu_info->li_list[i]); - } - LOG_D(RLC, "\n"); - //msg(" remaining size %d\n",size); - j = 0; - for (i = 0; i < pdu_info->num_li; i++) { - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlcP,frame); - rlc_am_send_sdu(rlcP,frame,eNB_flag); - j = j + pdu_info->li_list[i]; - } - if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlcP,frame); - } else { + if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug + // data is already ok, done by last loop above + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlc_pP, frameP); + } + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=01 (10) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + for (i=0; i < pdu_info->num_li; i++) { + LOG_D(RLC, "%d ",pdu_info->li_list[i]); + } + LOG_D(RLC, "\n"); + //msg(" remaining size %d\n",size); + // one last segment of SDU + N complete SDUs in PDU + j = 0; + for (i = 0; i < pdu_info->num_li; i++) { + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = j + pdu_info->li_list[i]; + } + if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug + // data is already ok, done by last loop above + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + } + //rlc_pP->reassembly_missing_sn_detected = 0; + break; + case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][REASSEMBLY PDU] TRY REASSEMBLY PDU FI=00 (11) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + for (i=0; i < pdu_info->num_li; i++) { + LOG_D(RLC, "%d ",pdu_info->li_list[i]); + } + LOG_D(RLC, "\n"); + //msg(" remaining size %d\n",size); + j = 0; + for (i = 0; i < pdu_info->num_li; i++) { + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->li_list[i], rlc_pP,frameP); + rlc_am_send_sdu(rlc_pP,frameP,eNB_flagP); + j = j + pdu_info->li_list[i]; + } + if (pdu_info->hidden_size > 0) { // normally should always be > 0 but just for help debug + // data is already ok, done by last loop above + rlc_am_reassembly (&pdu_info->payload[j], pdu_info->hidden_size, rlc_pP,frameP); + } else { #ifdef USER_MODE - //assert (5!=5); + //assert (5!=5); #endif - } - //rlcP->reassembly_missing_sn_detected = 0; - break; + } + //rlc_pP->reassembly_missing_sn_detected = 0; + break; #ifdef USER_MODE - default: - assert(1 != 1); + default: + assert(1 != 1); #endif - } - } - free_mem_block(tbP); + } + } + free_mem_block(tb_pP); } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h index 551ab976cc1f0c8bc7b6ecd1420e2de6223fc6f7..2dc00490fbc10fcc6602cde966fdd12eff5ffb8f 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_reassembly.h @@ -56,36 +56,36 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_am_reassembly(x) extern x # endif # endif -/*! \fn void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlcP) +/*! \fn void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlc_pP) * \brief Reset the data cursor index in the output SDU buffer to zero. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. */ -private_rlc_am_reassembly( void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlcP);) +private_rlc_am_reassembly( void rlc_am_clear_rx_sdu (rlc_am_entity_t *rlc_pP);) -/*! \fn void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Concatenate datas at the tail of the output SDU in construction. This SDU in construction will be sent to higher layer. * \param[in] srcP Pointer on data to be reassemblied. * \param[in] lengthP Length of data to be reassemblied. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index. */ -private_rlc_am_reassembly( void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlcP,u32_t frame);) +private_rlc_am_reassembly( void rlc_am_reassembly (u8_t * srcP, s32_t lengthP, rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_send_sdu (rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_send_sdu (rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Send the output SDU in construction to higher layer. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index. */ -private_rlc_am_reassembly( void rlc_am_send_sdu (rlc_am_entity_t *rlcP,u32_t frame, u8_t eNB_flag);) +private_rlc_am_reassembly( void rlc_am_send_sdu (rlc_am_entity_t *rlc_pP,frame_t frameP, eNB_flag_t eNB_flagP);) -/*! \fn void rlc_am_reassemble_pdu(rlc_am_entity_t* rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP) +/*! \fn void rlc_am_reassemble_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP, u8_t eNB_flagP, mem_block_t* tb_pP) * \brief Reassembly a RLC AM PDU, depending of the content of this PDU, data will be reassemblied to the current output SDU, the current will be sent to higher layers or not, after or before the reassembly, or no send of SDU will be triggered, depending on FI field in PDU header. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0). -* \param[in] tbP RLC AM PDU embedded in a mem_block_t. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0). +* \param[in] tb_pP RLC AM PDU embedded in a mem_block_t. */ -protected_rlc_am_reassembly( void rlc_am_reassemble_pdu(rlc_am_entity_t* rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP);) +protected_rlc_am_reassembly( void rlc_am_reassemble_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t* tb_pP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c index c95bbd38b8549b63b1516380f4e3bfdd7e24a895..6e95f55e5580e774e76e314dc24f2721d70a1304 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.c @@ -42,194 +42,248 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis //#define DEBUG_RLC_AM_DISPLAY_TB_DATA //#define RLC_AM_GENERATE_ERRORS //----------------------------------------------------------------------------- -signed int rlc_am_get_data_pdu_infos(u32_t frame, rlc_am_pdu_sn_10_t* headerP, s16_t total_sizeP, rlc_am_pdu_info_t* pdu_infoP) +signed int rlc_am_get_data_pdu_infos(frame_t frameP, rlc_am_pdu_sn_10_t* header_pP, s16_t total_sizeP, rlc_am_pdu_info_t* pdu_info_pP) //----------------------------------------------------------------------------- { - memset(pdu_infoP, 0, sizeof (rlc_am_pdu_info_t)); + memset(pdu_info_pP, 0, sizeof (rlc_am_pdu_info_t)); s16_t sum_li = 0; - pdu_infoP->d_c = headerP->b1 >> 7; - pdu_infoP->num_li = 0; + pdu_info_pP->d_c = header_pP->b1 >> 7; + pdu_info_pP->num_li = 0; - if (pdu_infoP->d_c) { - pdu_infoP->rf = (headerP->b1 >> 6) & 0x01; - pdu_infoP->p = (headerP->b1 >> 5) & 0x01; - pdu_infoP->fi = (headerP->b1 >> 3) & 0x03; - pdu_infoP->e = (headerP->b1 >> 2) & 0x01; - pdu_infoP->sn = headerP->b2 + (((u16_t)(headerP->b1 & 0x03)) << 8); + if (pdu_info_pP->d_c) { + pdu_info_pP->rf = (header_pP->b1 >> 6) & 0x01; + pdu_info_pP->p = (header_pP->b1 >> 5) & 0x01; + pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; + pdu_info_pP->e = (header_pP->b1 >> 2) & 0x01; + pdu_info_pP->sn = header_pP->b2 + (((u16_t)(header_pP->b1 & 0x03)) << 8); - pdu_infoP->header_size = 2; - if (pdu_infoP->rf) { - pdu_infoP->lsf = (headerP->data[0] >> 7) & 0x01; - pdu_infoP->so = headerP->data[1] + (((u16_t)(headerP->data[0] & 0x7F)) << 8); - pdu_infoP->payload = &headerP->data[2]; - pdu_infoP->header_size += 2; + pdu_info_pP->header_size = 2; + if (pdu_info_pP->rf) { + pdu_info_pP->lsf = (header_pP->data[0] >> 7) & 0x01; + pdu_info_pP->so = header_pP->data[1] + (((u16_t)(header_pP->data[0] & 0x7F)) << 8); + pdu_info_pP->payload = &header_pP->data[2]; + pdu_info_pP->header_size += 2; } else { - pdu_infoP->payload = &headerP->data[0]; + pdu_info_pP->payload = &header_pP->data[0]; } - if (pdu_infoP->e) { + if (pdu_info_pP->e) { rlc_am_e_li_t *e_li; unsigned int li_length_in_bytes = 1; unsigned int li_to_read = 1; - if (pdu_infoP->rf) { - e_li = (rlc_am_e_li_t*)(&headerP->data[2]); + if (pdu_info_pP->rf) { + e_li = (rlc_am_e_li_t*)(&header_pP->data[2]); } else { - e_li = (rlc_am_e_li_t*)(headerP->data); + e_li = (rlc_am_e_li_t*)(header_pP->data); } while (li_to_read) { li_length_in_bytes = li_length_in_bytes ^ 3; if (li_length_in_bytes == 2) { - pdu_infoP->li_list[pdu_infoP->num_li] = ((u16_t)(e_li->b1 << 4)) & 0x07F0; - pdu_infoP->li_list[pdu_infoP->num_li] |= (((u8_t)(e_li->b2 >> 4)) & 0x000F); + pdu_info_pP->li_list[pdu_info_pP->num_li] = ((u16_t)(e_li->b1 << 4)) & 0x07F0; + pdu_info_pP->li_list[pdu_info_pP->num_li] |= (((u8_t)(e_li->b2 >> 4)) & 0x000F); li_to_read = e_li->b1 & 0x80; - pdu_infoP->header_size += 2; + pdu_info_pP->header_size += 2; } else { - pdu_infoP->li_list[pdu_infoP->num_li] = ((u16_t)(e_li->b2 << 8)) & 0x0700; - pdu_infoP->li_list[pdu_infoP->num_li] |= e_li->b3; + pdu_info_pP->li_list[pdu_info_pP->num_li] = ((u16_t)(e_li->b2 << 8)) & 0x0700; + pdu_info_pP->li_list[pdu_info_pP->num_li] |= e_li->b3; li_to_read = e_li->b2 & 0x08; e_li++; - pdu_infoP->header_size += 1; + pdu_info_pP->header_size += 1; } - sum_li += pdu_infoP->li_list[pdu_infoP->num_li]; - pdu_infoP->num_li = pdu_infoP->num_li + 1; - if (pdu_infoP->num_li > RLC_AM_MAX_SDU_IN_PDU) { - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", frame, pdu_infoP->sn); + sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; + pdu_info_pP->num_li = pdu_info_pP->num_li + 1; + if (pdu_info_pP->num_li > RLC_AM_MAX_SDU_IN_PDU) { + LOG_E(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", + frameP, + pdu_info_pP->sn); return -2; } } if (li_length_in_bytes == 2) { - pdu_infoP->payload = &e_li->b3; + pdu_info_pP->payload = &e_li->b3; } else { - pdu_infoP->payload = &e_li->b1; + pdu_info_pP->payload = &e_li->b1; } } - pdu_infoP->payload_size = total_sizeP - pdu_infoP->header_size; - if (pdu_infoP->payload_size > sum_li) { - pdu_infoP->hidden_size = pdu_infoP->payload_size - sum_li; + pdu_info_pP->payload_size = total_sizeP - pdu_info_pP->header_size; + if (pdu_info_pP->payload_size > sum_li) { + pdu_info_pP->hidden_size = pdu_info_pP->payload_size - sum_li; } return 0; } else { - LOG_W(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX][GET DATA PDU INFO] SN %04d ERROR CONTROL PDU ", frame, pdu_infoP->sn); + LOG_W(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX][GET DATA PDU INFO] SN %04d ERROR CONTROL PDU ", + frameP, + pdu_info_pP->sn); return -1; } } //----------------------------------------------------------------------------- -void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_info_t* pdu_infoP) +void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_am_pdu_info_t* pdu_info_pP) //----------------------------------------------------------------------------- { int num_li; - if (pdu_infoP->d_c) { - if (pdu_infoP->rf) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d SO %05d LSF %01d POLL %1d ", frame, rlcP->module_id, rlcP->rb_id, pdu_infoP->sn, pdu_infoP->fi, pdu_infoP->so, pdu_infoP->lsf, pdu_infoP->p); + if (pdu_info_pP->d_c) { + if (pdu_info_pP->rf) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d SO %05d LSF %01d POLL %1d ", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info_pP->sn, + pdu_info_pP->fi, + pdu_info_pP->so, + pdu_info_pP->lsf, pdu_info_pP->p); } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d POLL %1d ", frame, rlcP->module_id, rlcP->rb_id, pdu_infoP->sn, pdu_infoP->fi, pdu_infoP->p); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] RX DATA PDU SN %04d FI %1d POLL %1d ", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info_pP->sn, + pdu_info_pP->fi, + pdu_info_pP->p); } - for (num_li = 0; num_li < pdu_infoP->num_li; num_li++) { - LOG_D(RLC, "LI %05d ", pdu_infoP->li_list[num_li]); + for (num_li = 0; num_li < pdu_info_pP->num_li; num_li++) { + LOG_D(RLC, "LI %05d ", pdu_info_pP->li_list[num_li]); } - if (pdu_infoP->hidden_size > 0) { - LOG_D(RLC, "hidden size %05d ", pdu_infoP->hidden_size); + if (pdu_info_pP->hidden_size > 0) { + LOG_D(RLC, "hidden size %05d ", pdu_info_pP->hidden_size); } LOG_D(RLC, "\n"); } else { - LOG_E(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][DISPLAY DATA PDU] ERROR RX CONTROL PDU\n", frame, rlcP->module_id, rlcP->rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][DISPLAY DATA PDU] ERROR RX CONTROL PDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } } -// assumed the sn of the tb is equal to VR(MS) +// assumed the sn of the tb_p is equal to VR(MS) //----------------------------------------------------------------------------- -void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlcP, u32_t frame, mem_block_t* tbP) +void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlc_pP, frame_t frameP, mem_block_t* tb_pP) //----------------------------------------------------------------------------- { - //rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor; - mem_block_t* cursor; + //rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; + rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; + mem_block_t* cursor_p; - cursor = tbP; - if (cursor) { + cursor_p = tb_pP; + if (cursor_p) { do { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if (((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received == 0) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received == 0) { #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_ms, pdu_info_cursor->sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ms, pdu_info_cursor_p->sn); #endif - rlcP->vr_ms = pdu_info_cursor->sn; + rlc_pP->vr_ms = pdu_info_cursor_p->sn; return; } - cursor = cursor->next; - } while (cursor != NULL); + cursor_p = cursor_p->next; + } while (cursor_p != NULL); #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_ms, (pdu_info_cursor->sn + 1) & RLC_AM_SN_MASK); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(MS)] UPDATED VR(MS) %04d -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ms, + (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK); #endif - rlcP->vr_ms = (pdu_info_cursor->sn + 1) & RLC_AM_SN_MASK; + rlc_pP->vr_ms = (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK; } } -// assumed the sn of the tb is equal to VR(R) +// assumed the sn of the tb_p is equal to VR(R) //----------------------------------------------------------------------------- -void rlc_am_rx_update_vr_r(rlc_am_entity_t *rlcP,u32_t frame,mem_block_t* tbP) +void rlc_am_rx_update_vr_r(rlc_am_entity_t *rlc_pP,frame_t frameP,mem_block_t* tb_pP) //----------------------------------------------------------------------------- { - rlc_am_pdu_info_t* pdu_info_cursor; - mem_block_t* cursor; - cursor = tbP; - if (cursor) { + rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; + mem_block_t* cursor_p; + + cursor_p = tb_pP; + if (cursor_p) { do { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if ((((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received == 0) || - (rlcP->vr_r != pdu_info_cursor->sn)) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if ((((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received == 0) || + (rlc_pP->vr_r != pdu_info_cursor_p->sn)) { return; } #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][UPDATE VR(R)] UPDATED VR(R) %04d -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_r, (pdu_info_cursor->sn + 1) & RLC_AM_SN_MASK); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][UPDATE VR(R)] UPDATED VR(R) %04d -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_r, + (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK); #endif - if (((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.rf == 1) { - if (((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.lsf == 1) { - rlcP->vr_r = (rlcP->vr_r + 1) & RLC_AM_SN_MASK; + if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.rf == 1) { + if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.lsf == 1) { + rlc_pP->vr_r = (rlc_pP->vr_r + 1) & RLC_AM_SN_MASK; } } else { - rlcP->vr_r = (rlcP->vr_r + 1) & RLC_AM_SN_MASK; + rlc_pP->vr_r = (rlc_pP->vr_r + 1) & RLC_AM_SN_MASK; } - cursor = cursor->next; - } while (cursor != NULL); - //rlcP->vr_r = (pdu_info_cursor->sn + 1) & RLC_AM_SN_MASK; + cursor_p = cursor_p->next; + } while (cursor_p != NULL); + //rlc_pP->vr_r = (pdu_info_cursor_p->sn + 1) & RLC_AM_SN_MASK; } } //----------------------------------------------------------------------------- void -rlc_am_receive_routing (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP) +rlc_am_receive_routing (rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) //----------------------------------------------------------------------------- { - mem_block_t *tb; - u8_t *first_byte; + mem_block_t *tb_p = NULL; + u8_t *first_byte_p = NULL; s16_t tb_size_in_bytes; - while ((tb = list_remove_head (&data_indP.data))) { - first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_ind *) (tb->data))->size; + while ((tb_p = list_remove_head (&data_indP.data))) { + first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; + tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; if (tb_size_in_bytes > 0) { - if ((*first_byte & 0x80) == 0x80) { - rlcP->stat_rx_data_bytes += tb_size_in_bytes; - rlcP->stat_rx_data_pdu += 1; - rlc_am_receive_process_data_pdu (rlcP, frame, eNB_flag, tb, first_byte, tb_size_in_bytes); + if ((*first_byte_p & 0x80) == 0x80) { + rlc_pP->stat_rx_data_bytes += tb_size_in_bytes; + rlc_pP->stat_rx_data_pdu += 1; + rlc_am_receive_process_data_pdu (rlc_pP, frameP, eNB_flagP, tb_p, first_byte_p, tb_size_in_bytes); } else { - rlcP->stat_rx_control_bytes += tb_size_in_bytes; - rlcP->stat_rx_control_pdu += 1; - rlc_am_receive_process_control_pdu (rlcP, frame, tb, &first_byte, &tb_size_in_bytes); + rlc_pP->stat_rx_control_bytes += tb_size_in_bytes; + rlc_pP->stat_rx_control_pdu += 1; + rlc_am_receive_process_control_pdu (rlc_pP, frameP, tb_p, &first_byte_p, &tb_size_in_bytes); // Test if remaining bytes not processed (up to know, highest probability is bug in MAC) AssertFatal( tb_size_in_bytes == 0, "Remaining %d bytes following a control PDU", tb_size_in_bytes); } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_r, rlcP->vr_mr); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RX ROUTING] VR(R)=%03d VR(MR)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_r, + rlc_pP->vr_mr); } } // end while } //----------------------------------------------------------------------------- -void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP, u8_t* first_byteP, u16_t tb_size_in_bytesP) +void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t* tb_pP, u8_t* first_byte_pP, u16_t tb_size_in_bytesP) //----------------------------------------------------------------------------- { // 5.1.3.2 Receive operations @@ -258,29 +312,54 @@ void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlcP, u32_t frame, u8_t e // - place the received RLC data PDU in the reception buffer; // - if some byte segments of the AMD PDU contained in the RLC data PDU have been received before: // - discard the duplicate byte segments. - rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; - rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10 = (rlc_am_pdu_sn_10_t*)first_byteP; + rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; + rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t*)first_byte_pP; - if (rlc_am_get_data_pdu_infos(frame,rlc_am_pdu_sn_10, tb_size_in_bytesP, pdu_info) >= 0) { + if (rlc_am_get_data_pdu_infos(frameP,rlc_am_pdu_sn_10_p, tb_size_in_bytesP, pdu_info_p) >= 0) { - ((rlc_am_rx_pdu_management_t*)(tbP->data))->all_segments_received = 0; - if (rlc_am_in_rx_window(rlcP, pdu_info->sn)) { + ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received = 0; + if (rlc_am_in_rx_window(rlc_pP, pdu_info_p->sn)) { - if (pdu_info->p) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] POLL BIT SET, STATUS REQUESTED:\n", frame, rlcP->module_id, rlcP->rb_id); - rlcP->status_requested = 1; + if (pdu_info_p->p) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] POLL BIT SET, STATUS REQUESTED:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->status_requested = 1; } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MR) %04d VR(MS) %04d VR(X) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_r, rlcP->vr_h, rlcP->vr_mr, rlcP->vr_ms, rlcP->vr_x); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MR) %04d VR(MS) %04d VR(X) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_r, + rlc_pP->vr_h, + rlc_pP->vr_mr, + rlc_pP->vr_ms, + rlc_pP->vr_x); - if (rlc_am_rx_list_insert_pdu(rlcP, frame,tbP) < 0) { - rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += tb_size_in_bytesP; - free_mem_block (tbP); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] PDU DISCARDED, STATUS REQUESTED:\n", frame, rlcP->module_id, rlcP->rb_id); - rlcP->status_requested = 1; + if (rlc_am_rx_list_insert_pdu(rlc_pP, frameP,tb_pP) < 0) { + rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += tb_size_in_bytesP; + free_mem_block (tb_pP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] PDU DISCARDED, STATUS REQUESTED:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->status_requested = 1; #if defined(RLC_STOP_ON_LOST_PDU) AssertFatal( 0 == 1, - "[FRAME %05d][RLC_AM][MOD %d][RB %d] LOST PDU DETECTED\n", frame, rlcP->module_id, rlcP->rb_id); + "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] LOST PDU DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #endif } else { // 5.1.3.2.3 @@ -316,45 +395,64 @@ void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlcP, u32_t frame, u8_t e #ifdef TRACE_RLC_AM_RX - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] RX LIST AFTER INSERTION:\n", frame, rlcP->module_id, rlcP->rb_id); - rlc_am_rx_list_display(rlcP, "rlc_am_receive_process_data_pdu AFTER INSERTION "); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] RX LIST AFTER INSERTION:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_am_rx_list_display(rlc_pP, "rlc_am_receive_process_data_pdu AFTER INSERTION "); #endif - if (rlc_am_sn_gte_vr_h(rlcP, pdu_info->sn) > 0) { - rlcP->vr_h = (pdu_info->sn + 1) & RLC_AM_SN_MASK; + if (rlc_am_sn_gte_vr_h(rlc_pP, pdu_info_p->sn) > 0) { + rlc_pP->vr_h = (pdu_info_p->sn + 1) & RLC_AM_SN_MASK; } - rlc_am_rx_check_all_byte_segments(rlcP, frame, tbP); - if ((pdu_info->sn == rlcP->vr_ms) && (((rlc_am_rx_pdu_management_t*)(tbP->data))->all_segments_received)) { - rlc_am_rx_update_vr_ms(rlcP, frame, tbP); + rlc_am_rx_check_all_byte_segments(rlc_pP, frameP, tb_pP); + if ((pdu_info_p->sn == rlc_pP->vr_ms) && (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received)) { + rlc_am_rx_update_vr_ms(rlc_pP, frameP, tb_pP); } - if (pdu_info->sn == rlcP->vr_r) { - if (((rlc_am_rx_pdu_management_t*)(tbP->data))->all_segments_received) { - rlc_am_rx_update_vr_r(rlcP, frame, tbP); - rlcP->vr_mr = (rlcP->vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; + if (pdu_info_p->sn == rlc_pP->vr_r) { + if (((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received) { + rlc_am_rx_update_vr_r(rlc_pP, frameP, tb_pP); + rlc_pP->vr_mr = (rlc_pP->vr_r + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; } - rlc_am_rx_list_reassemble_rlc_sdus(rlcP,frame,eNB_flag); + rlc_am_rx_list_reassemble_rlc_sdus(rlc_pP,frameP,eNB_flagP); } - if (rlcP->t_reordering.running) { - if ((rlcP->vr_x == rlcP->vr_r) || ((rlc_am_in_rx_window(rlcP, pdu_info->sn) == 0) && (rlcP->vr_x != rlcP->vr_mr))) { - rlc_am_stop_and_reset_timer_reordering(rlcP,frame); + if (rlc_pP->t_reordering.running) { + if ((rlc_pP->vr_x == rlc_pP->vr_r) || ((rlc_am_in_rx_window(rlc_pP, pdu_info_p->sn) == 0) && (rlc_pP->vr_x != rlc_pP->vr_mr))) { + rlc_am_stop_and_reset_timer_reordering(rlc_pP,frameP); } } - if (!(rlcP->t_reordering.running)) { - if (rlcP->vr_h != rlcP->vr_r) { // - if VR (H) > VR(R) translated to - if VR (H) != VR(R) - rlc_am_start_timer_reordering(rlcP,frame); - rlcP->vr_x = rlcP->vr_h; + if (!(rlc_pP->t_reordering.running)) { + if (rlc_pP->vr_h != rlc_pP->vr_r) { // - if VR (H) > VR(R) translated to - if VR (H) != VR(R) + rlc_am_start_timer_reordering(rlc_pP,frameP); + rlc_pP->vr_x = rlc_pP->vr_h; } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MS) %04d VR(MR) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_r, rlcP->vr_h, rlcP->vr_ms, rlcP->vr_mr); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] VR(R) %04d VR(H) %04d VR(MS) %04d VR(MR) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_r, + rlc_pP->vr_h, + rlc_pP->vr_ms, + rlc_pP->vr_mr); } else { - rlcP->stat_rx_data_pdu_out_of_window += 1; - rlcP->stat_rx_data_bytes_out_of_window += tb_size_in_bytesP; - free_mem_block (tbP); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, STATUS REQUESTED:\n", frame, rlcP->module_id, rlcP->rb_id); - rlcP->status_requested = 1; + rlc_pP->stat_rx_data_pdu_out_of_window += 1; + rlc_pP->stat_rx_data_bytes_out_of_window += tb_size_in_bytesP; + free_mem_block (tb_pP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] PDU OUT OF RX WINDOW, DISCARDED, STATUS REQUESTED:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->status_requested = 1; } } else { - free_mem_block (tbP); + free_mem_block (tb_pP); } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h index 34662c701fc0831825e82b6acad49a22af34ba65..2934b6c0db7b868b0541fa96eb1bd34c16097e25 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_receiver.h @@ -56,7 +56,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_am_receiver(x) extern x # endif # endif -/*! \fn signed int rlc_am_get_data_pdu_infos(u32_t frame, rlc_am_pdu_sn_10_t* headerP, s16_t sizeP, rlc_am_pdu_info_t* pdu_infoP) +/*! \fn signed int rlc_am_get_data_pdu_infos(frame_t frameP, rlc_am_pdu_sn_10_t* headerP, s16_t sizeP, rlc_am_pdu_info_t* pdu_infoP) * \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. * \param[in] frame Frame index. * \param[in] headerP RLC AM header PDU pointer. @@ -64,52 +64,52 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis * \param[in] pdu_infoP Structure containing extracted informations from PDU. * \return 0 if no error was encountered during the parsing of the PDU, else -1; */ -protected_rlc_am_receiver( signed int rlc_am_get_data_pdu_infos(u32_t frame, rlc_am_pdu_sn_10_t* headerP, s16_t sizeP, rlc_am_pdu_info_t* pdu_infoP)); +protected_rlc_am_receiver( signed int rlc_am_get_data_pdu_infos(frame_t frameP, rlc_am_pdu_sn_10_t* headerP, s16_t sizeP, rlc_am_pdu_info_t* pdu_infoP)); -/*! \fn void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_info_t* pdu_infoP) +/*! \fn void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_am_pdu_info_t* pdu_infoP) * \brief Display RLC AM PDU informations. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] pdu_infoP Structure containing extracted informations of a PDU. */ -protected_rlc_am_receiver( void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_info_t* pdu_infoP);) +protected_rlc_am_receiver( void rlc_am_display_data_pdu_infos(rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_am_pdu_info_t* pdu_infoP);) -/*! \fn void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlcP,mem_block_t* tbP) +/*! \fn void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlc_pP,mem_block_t* tb_pP) * \brief Update RLC AM protocol variable VR(MS). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index. -* \param[in] tbP PDU embedded in a mem_block_t struct. +* \param[in] tb_pP PDU embedded in a mem_block_t struct. * \note It is assumed that the sequence number of the transport block is equal to VR(MS) */ -protected_rlc_am_receiver( void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlcP,u32_t frame, mem_block_t* tbP);) +protected_rlc_am_receiver( void rlc_am_rx_update_vr_ms(rlc_am_entity_t *rlc_pP,frame_t frameP, mem_block_t* tb_pP);) -/*! \fn void rlc_am_rx_update_vr_r (rlc_am_entity_t *rlcP,u32_t frame,mem_block_t* tbP) +/*! \fn void rlc_am_rx_update_vr_r (rlc_am_entity_t *rlc_pP,frame_t frameP,mem_block_t* tb_pP) * \brief Update RLC AM protocol variable VR(R). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index. -* \param[in] tbP PDU embedded in a mem_block_t struct. +* \param[in] tb_pP PDU embedded in a mem_block_t struct. * \note It is assumed that the sequence number of the transport block is equal to VR(R) */ -protected_rlc_am_receiver( void rlc_am_rx_update_vr_r (rlc_am_entity_t *rlcP,u32_t frame, mem_block_t* tbP);) +protected_rlc_am_receiver( void rlc_am_rx_update_vr_r (rlc_am_entity_t *rlc_pP,frame_t frameP, mem_block_t* tb_pP);) -/*! \fn void rlc_am_receive_routing (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP) +/*! \fn void rlc_am_receive_routing (rlc_am_entity_t *rlc_pP, frame_t frameP, u8_t eNB_flagP, struct mac_data_ind data_indP) * \brief Convert transport blocks received from MAC layer into RLC AM PDUs, and dispatch to the right processing block these PDUS upon their type (CONTROL/DATA). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0). +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0). * \param[in] data_indP Transport blocks received from MAC layer. */ -protected_rlc_am_receiver( void rlc_am_receive_routing (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP)); +protected_rlc_am_receiver( void rlc_am_receive_routing (rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP)); -/*! \fn void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP, u8_t* first_byteP, u16_t tb_size_in_bytesP) +/*! \fn void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlc_pP, frame_t frameP, u8_t eNB_flagP, mem_block_t* tb_pP, u8_t* first_byteP, u16_t tb_size_in_bytesP) * \brief Process an incoming data PDU received from MAC layer. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0). -* \param[in] tbP PDU embedded in a mem_block_t struct. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0). +* \param[in] tb_pP PDU embedded in a mem_block_t struct. * \param[in] first_byteP Pointer on first byte of the PDU. * \param[in] tb_size_in_bytesP Transport block size in bytes (same as PDU size in bytes). */ -private_rlc_am_receiver( void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t* tbP, u8_t* first_byteP, u16_t tb_size_in_bytesP)); +private_rlc_am_receiver( void rlc_am_receive_process_data_pdu (rlc_am_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t* tb_pP, u8_t* first_byteP, u16_t tb_size_in_bytesP)); /** @} */ # endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c index 4ad7f018e1b6e1e0096f1f4373a4ab7cf057e237..87db121184ec189d09ccdf5b109fe4712a5d393d 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.c @@ -40,7 +40,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis //#define TRACE_RLC_AM_NACK //#define TRACE_RLC_AM_ACK //----------------------------------------------------------------------------- -void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_endP) +void rlc_am_nack_pdu (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP, sdu_size_t so_startP, sdu_size_t so_endP) //----------------------------------------------------------------------------- { // 5.2.1 Retransmission @@ -56,12 +56,12 @@ void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_st // - indicate to upper layers that max retransmission has been reached. - mem_block_t* mb = rlcP->pdu_retrans_buffer[snP].mem_block; + mem_block_t* mb_pP = rlc_pP->pdu_retrans_buffer[snP].mem_block; int pdu_sdu_index; int sdu_index; - if (mb != NULL) { - rlcP->num_nack_sn += 1; + if (mb_pP != NULL) { + rlc_pP->num_nack_sn += 1; assert(so_startP <= so_endP); //----------------------------------------- // allow holes in reports @@ -69,94 +69,109 @@ void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_st // increasing order among calls refering to only one status PDU // and among time //----------------------------------------- - if (rlcP->pdu_retrans_buffer[snP].last_nack_time != frame) { - rlcP->pdu_retrans_buffer[snP].last_nack_time = frame; - rlc_am_clear_holes(rlcP, snP); + if (rlc_pP->pdu_retrans_buffer[snP].last_nack_time != frameP) { + rlc_pP->pdu_retrans_buffer[snP].last_nack_time = frameP; + rlc_am_clear_holes(rlc_pP, snP); } if (!((so_startP == 0) && (so_endP == 0x7FFF))) { - rlcP->num_nack_so += 1; + rlc_pP->num_nack_so += 1; } - rlc_am_add_hole(rlcP, frame, snP, so_startP, so_endP); + rlc_am_add_hole(rlc_pP, frameP, snP, so_startP, so_endP); - if (rlcP->first_retrans_pdu_sn < 0) { - rlcP->first_retrans_pdu_sn = snP; - } else if (rlc_am_tx_sn1_gt_sn2(rlcP, rlcP->first_retrans_pdu_sn, snP)){ - rlcP->first_retrans_pdu_sn = snP; + if (rlc_pP->first_retrans_pdu_sn < 0) { + rlc_pP->first_retrans_pdu_sn = snP; + } else if (rlc_am_tx_sn1_gt_sn2(rlc_pP, rlc_pP->first_retrans_pdu_sn, snP)){ + rlc_pP->first_retrans_pdu_sn = snP; } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][NACK-PDU] NACK PDU SN %04d previous retx_count %d 1ST_RETRANS_PDU %04d\n", - frame, - rlcP->module_id, - rlcP->rb_id, - snP, - rlcP->pdu_retrans_buffer[snP].retx_count, - rlcP->first_retrans_pdu_sn); - - rlcP->pdu_retrans_buffer[snP].flags.retransmit = 1; - - if (rlcP->pdu_retrans_buffer[snP].retx_count == -1) { - rlcP->pdu_retrans_buffer[snP].retx_count = 0; - rlcP->retrans_num_bytes_to_retransmit += rlcP->pdu_retrans_buffer[snP].header_and_payload_size; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][NACK-PDU] NACK PDU SN %04d previous retx_count %d 1ST_RETRANS_PDU %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].retx_count, + rlc_pP->first_retrans_pdu_sn); + + rlc_pP->pdu_retrans_buffer[snP].flags.retransmit = 1; + + if (rlc_pP->pdu_retrans_buffer[snP].retx_count == -1) { + rlc_pP->pdu_retrans_buffer[snP].retx_count = 0; + rlc_pP->retrans_num_bytes_to_retransmit += rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size; } else { - rlcP->pdu_retrans_buffer[snP].retx_count += 1; + rlc_pP->pdu_retrans_buffer[snP].retx_count += 1; } - if (rlcP->pdu_retrans_buffer[snP].retx_count >= rlcP->max_retx_threshold) { - for (pdu_sdu_index = 0; pdu_sdu_index < rlcP->pdu_retrans_buffer[snP].nb_sdus; pdu_sdu_index++) { - sdu_index = rlcP->pdu_retrans_buffer[snP].sdus_index[pdu_sdu_index]; + if (rlc_pP->pdu_retrans_buffer[snP].retx_count >= rlc_pP->max_retx_threshold) { + for (pdu_sdu_index = 0; pdu_sdu_index < rlc_pP->pdu_retrans_buffer[snP].nb_sdus; pdu_sdu_index++) { + sdu_index = rlc_pP->pdu_retrans_buffer[snP].sdus_index[pdu_sdu_index]; assert(pdu_sdu_index < RLC_AM_MAX_SDU_IN_PDU); assert(sdu_index < RLC_AM_SDU_CONTROL_BUFFER_SIZE); - rlcP->input_sdus[sdu_index].nb_pdus_ack += 1; - if (rlcP->input_sdus[sdu_index].nb_pdus_ack == rlcP->input_sdus[sdu_index].nb_pdus) { + rlc_pP->input_sdus[sdu_index].nb_pdus_ack += 1; + if (rlc_pP->input_sdus[sdu_index].nb_pdus_ack == rlc_pP->input_sdus[sdu_index].nb_pdus) { #ifdef TEST_RLC_AM - rlc_am_v9_3_0_test_data_conf (rlcP->module_id, rlcP->rb_id, rlcP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_NO); + rlc_am_v9_3_0_test_data_conf (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_NO); #else - rlc_data_conf(rlcP->module_id, frame, rlcP->is_enb, rlcP->rb_id, rlcP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_NO, rlcP->is_data_plane); + rlc_data_conf(rlc_pP->enb_module_id, rlc_pP->ue_module_id, frameP, rlc_pP->is_enb, rlc_pP->rb_id, rlc_pP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_NO, rlc_pP->is_data_plane); #endif - rlcP->stat_tx_pdcp_sdu_discarded += 1; - rlcP->stat_tx_pdcp_bytes_discarded += rlcP->input_sdus[sdu_index].sdu_size; - rlc_am_free_in_sdu(rlcP, frame, sdu_index); + rlc_pP->stat_tx_pdcp_sdu_discarded += 1; + rlc_pP->stat_tx_pdcp_bytes_discarded += rlc_pP->input_sdus[sdu_index].sdu_size; + rlc_am_free_in_sdu(rlc_pP, frameP, sdu_index); } } } } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][NACK-PDU] ERROR NACK MISSING PDU SN %05d\n", frame, rlcP->module_id, rlcP->rb_id, snP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][NACK-PDU] ERROR NACK MISSING PDU SN %05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP); //assert(2==3); } } //----------------------------------------------------------------------------- -void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP) +void rlc_am_ack_pdu (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - mem_block_t* mb = rlcP->pdu_retrans_buffer[snP].mem_block; + mem_block_t* mb_pP = rlc_pP->pdu_retrans_buffer[snP].mem_block; int pdu_sdu_index; int sdu_index; - rlcP->pdu_retrans_buffer[snP].flags.retransmit = 0; - - if ((rlcP->pdu_retrans_buffer[snP].flags.ack == 0) && (mb != NULL)) { - //if (mb != NULL) { - free_mem_block(mb); - rlcP->pdu_retrans_buffer[snP].mem_block = NULL; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] ACK PDU SN %05d previous retx_count %d \n", frame, rlcP->module_id, rlcP->rb_id, snP, rlcP->pdu_retrans_buffer[snP].retx_count); - rlcP->retrans_num_pdus -= 1; - rlcP->retrans_num_bytes -= rlcP->pdu_retrans_buffer[snP].header_and_payload_size; - - if (rlcP->pdu_retrans_buffer[snP].retx_count >= 0) { - rlcP->retrans_num_bytes_to_retransmit -= rlcP->pdu_retrans_buffer[snP].header_and_payload_size; + rlc_pP->pdu_retrans_buffer[snP].flags.retransmit = 0; + + if ((rlc_pP->pdu_retrans_buffer[snP].flags.ack == 0) && (mb_pP != NULL)) { + //if (mb_pP != NULL) { + free_mem_block(mb_pP); + rlc_pP->pdu_retrans_buffer[snP].mem_block = NULL; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] ACK PDU SN %05d previous retx_count %d \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].retx_count); + rlc_pP->retrans_num_pdus -= 1; + rlc_pP->retrans_num_bytes -= rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size; + + if (rlc_pP->pdu_retrans_buffer[snP].retx_count >= 0) { + rlc_pP->retrans_num_bytes_to_retransmit -= rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size; } - for (pdu_sdu_index = 0; pdu_sdu_index < rlcP->pdu_retrans_buffer[snP].nb_sdus; pdu_sdu_index++) { - sdu_index = rlcP->pdu_retrans_buffer[snP].sdus_index[pdu_sdu_index]; + for (pdu_sdu_index = 0; pdu_sdu_index < rlc_pP->pdu_retrans_buffer[snP].nb_sdus; pdu_sdu_index++) { + sdu_index = rlc_pP->pdu_retrans_buffer[snP].sdus_index[pdu_sdu_index]; assert(sdu_index >= 0); assert(sdu_index < RLC_AM_SDU_CONTROL_BUFFER_SIZE); - rlcP->input_sdus[sdu_index].nb_pdus_ack += 1; - if ((rlcP->input_sdus[sdu_index].nb_pdus_ack == rlcP->input_sdus[sdu_index].nb_pdus) && - (rlcP->input_sdus[sdu_index].sdu_remaining_size == 0)) { + rlc_pP->input_sdus[sdu_index].nb_pdus_ack += 1; + if ((rlc_pP->input_sdus[sdu_index].nb_pdus_ack == rlc_pP->input_sdus[sdu_index].nb_pdus) && + (rlc_pP->input_sdus[sdu_index].sdu_remaining_size == 0)) { #ifdef TEST_RLC_AM - rlc_am_v9_3_0_test_data_conf (rlcP->module_id, rlcP->rb_id, rlcP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_YES); + rlc_am_v9_3_0_test_data_conf (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_YES); #else - rlc_data_conf(rlcP->module_id, frame, rlcP->is_enb, rlcP->rb_id, rlcP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_YES, rlcP->is_data_plane); + rlc_data_conf(rlc_pP->enb_module_id, rlc_pP->ue_module_id, frameP, rlc_pP->is_enb, rlc_pP->rb_id, rlc_pP->input_sdus[sdu_index].mui, RLC_SDU_CONFIRM_YES, rlc_pP->is_data_plane); #endif - rlc_am_free_in_sdu(rlcP, frame, sdu_index); + rlc_am_free_in_sdu(rlc_pP, frameP, sdu_index); } } // 7.1... @@ -164,83 +179,117 @@ void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP) // This state variable holds the value of the SN of the next AMD PDU for which a positive acknowledgment is to be // received in-sequence, and it serves as the lower edge of the transmitting window. It is initially set to 0, and is updated // whenever the AM RLC entity receives a positive acknowledgment for an AMD PDU with SN = VT(A). - rlcP->pdu_retrans_buffer[snP].flags.ack = 1; - if (snP == rlcP->vt_a) { - //rlcP->pdu_retrans_buffer[snP].flags.ack = 1; + rlc_pP->pdu_retrans_buffer[snP].flags.ack = 1; + if (snP == rlc_pP->vt_a) { + //rlc_pP->pdu_retrans_buffer[snP].flags.ack = 1; do { - memset(&rlcP->pdu_retrans_buffer[rlcP->vt_a], 0, sizeof(rlc_am_tx_data_pdu_management_t)); - if (rlcP->vt_a == rlcP->first_retrans_pdu_sn) { - rlcP->first_retrans_pdu_sn = (rlcP->vt_a + 1) & RLC_AM_SN_MASK; + memset(&rlc_pP->pdu_retrans_buffer[rlc_pP->vt_a], 0, sizeof(rlc_am_tx_data_pdu_management_t)); + if (rlc_pP->vt_a == rlc_pP->first_retrans_pdu_sn) { + rlc_pP->first_retrans_pdu_sn = (rlc_pP->vt_a + 1) & RLC_AM_SN_MASK; } - rlcP->vt_a = (rlcP->vt_a + 1) & RLC_AM_SN_MASK; - } while ((rlcP->pdu_retrans_buffer[rlcP->vt_a].flags.ack == 1) && (rlcP->vt_a != rlcP->vt_s)); - - - rlcP->vt_ms = (rlcP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vt_a, rlcP->vt_ms, rlcP->vt_s); + rlc_pP->vt_a = (rlc_pP->vt_a + 1) & RLC_AM_SN_MASK; + } while ((rlc_pP->pdu_retrans_buffer[rlc_pP->vt_a].flags.ack == 1) && (rlc_pP->vt_a != rlc_pP->vt_s)); + + + rlc_pP->vt_ms = (rlc_pP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vt_a, + rlc_pP->vt_ms, + rlc_pP->vt_s); } - if (snP == rlcP->first_retrans_pdu_sn) { + if (snP == rlc_pP->first_retrans_pdu_sn) { do { - rlcP->first_retrans_pdu_sn = (rlcP->first_retrans_pdu_sn + 1) & RLC_AM_SN_MASK; - if (rlcP->pdu_retrans_buffer[rlcP->first_retrans_pdu_sn].retx_count >= 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->first_retrans_pdu_sn); + rlc_pP->first_retrans_pdu_sn = (rlc_pP->first_retrans_pdu_sn + 1) & RLC_AM_SN_MASK; + if (rlc_pP->pdu_retrans_buffer[rlc_pP->first_retrans_pdu_sn].retx_count >= 0) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn); break; } - } while (rlcP->first_retrans_pdu_sn != rlcP->vt_s); - if (rlcP->vt_s == rlcP->first_retrans_pdu_sn) { - rlcP->first_retrans_pdu_sn = -1; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->first_retrans_pdu_sn); + } while (rlc_pP->first_retrans_pdu_sn != rlc_pP->vt_s); + if (rlc_pP->vt_s == rlc_pP->first_retrans_pdu_sn) { + rlc_pP->first_retrans_pdu_sn = -1; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED first_retrans_pdu_sn -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->first_retrans_pdu_sn); } } } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] WARNING ACK PDU SN %05d -> NO PDU TO ACK\n", frame, rlcP->module_id, rlcP->rb_id, snP); - if (mb != NULL) { - free_mem_block(mb); - rlcP->pdu_retrans_buffer[snP].mem_block = NULL; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] WARNING ACK PDU SN %05d -> NO PDU TO ACK\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP); + if (mb_pP != NULL) { + free_mem_block(mb_pP); + rlc_pP->pdu_retrans_buffer[snP].mem_block = NULL; } - if (rlcP->pdu_retrans_buffer[snP].flags.ack > 0) { - if (snP == rlcP->vt_a) { - //rlcP->pdu_retrans_buffer[snP].flags.ack = 1; + if (rlc_pP->pdu_retrans_buffer[snP].flags.ack > 0) { + if (snP == rlc_pP->vt_a) { + //rlc_pP->pdu_retrans_buffer[snP].flags.ack = 1; do { - memset(&rlcP->pdu_retrans_buffer[rlcP->vt_a], 0, sizeof(rlc_am_tx_data_pdu_management_t)); - if (rlcP->vt_a == rlcP->first_retrans_pdu_sn) { - rlcP->first_retrans_pdu_sn = (rlcP->vt_a + 1) & RLC_AM_SN_MASK; + memset(&rlc_pP->pdu_retrans_buffer[rlc_pP->vt_a], 0, sizeof(rlc_am_tx_data_pdu_management_t)); + if (rlc_pP->vt_a == rlc_pP->first_retrans_pdu_sn) { + rlc_pP->first_retrans_pdu_sn = (rlc_pP->vt_a + 1) & RLC_AM_SN_MASK; } - rlcP->vt_a = (rlcP->vt_a + 1) & RLC_AM_SN_MASK; - } while ((rlcP->pdu_retrans_buffer[rlcP->vt_a].flags.ack == 1) && (rlcP->vt_a != rlcP->vt_s)); - - rlcP->vt_ms = (rlcP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vt_a, rlcP->vt_ms, rlcP->vt_s); + rlc_pP->vt_a = (rlc_pP->vt_a + 1) & RLC_AM_SN_MASK; + } while ((rlc_pP->pdu_retrans_buffer[rlc_pP->vt_a].flags.ack == 1) && (rlc_pP->vt_a != rlc_pP->vt_s)); + + rlc_pP->vt_ms = (rlc_pP->vt_a + RLC_AM_WINDOW_SIZE) & RLC_AM_SN_MASK; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][ACK-PDU] UPDATED VT(A) %04d VT(MS) %04d VT(S) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vt_a, + rlc_pP->vt_ms, + rlc_pP->vt_s); } } } } //----------------------------------------------------------------------------- -mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlcP, u32 frame, u16_t snP) +mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - mem_block_t* mb_original = rlcP->pdu_retrans_buffer[snP].mem_block; - if (mb_original != NULL) { + mem_block_t* mb_original_p = rlc_pP->pdu_retrans_buffer[snP].mem_block; + if (mb_original_p != NULL) { - rlc_am_tx_data_pdu_management_t *pdu_mngt = &rlcP->pdu_retrans_buffer[snP % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE]; + rlc_am_tx_data_pdu_management_t *pdu_mngt = &rlc_pP->pdu_retrans_buffer[snP % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE]; int size = pdu_mngt->header_and_payload_size + sizeof(struct mac_tb_req); mem_block_t* mb_copy = get_free_mem_block(size); - memcpy(mb_copy->data, mb_original->data, size); + memcpy(mb_copy->data, mb_original_p->data, size); - rlc_am_pdu_sn_10_t *pdu = (rlc_am_pdu_sn_10_t*) (&mb_copy->data[sizeof(struct mac_tb_req)]); - ((struct mac_tb_req*)(mb_copy->data))->data_ptr = (u8_t*)pdu; + rlc_am_pdu_sn_10_t *pdu_p = (rlc_am_pdu_sn_10_t*) (&mb_copy->data[sizeof(struct mac_tb_req)]); + ((struct mac_tb_req*)(mb_copy->data))->data_ptr = (u8_t*)pdu_p; pdu_mngt->flags.retransmit = 0; - rlc_am_pdu_polling(rlcP, frame, pdu, pdu_mngt->payload_size); + rlc_am_pdu_polling(rlc_pP, frameP, pdu_p, pdu_mngt->payload_size); return mb_copy; } else { return NULL; } } //----------------------------------------------------------------------------- -mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t *sizeP) +mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP, sdu_size_t *sizeP) //----------------------------------------------------------------------------- { @@ -287,33 +336,45 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame // - set the header of the new AMD PDU segment in accordance with the description in sub clause 6.; // - set the P field according to sub clause 5.2.2. - mem_block_t* mb_original = rlcP->pdu_retrans_buffer[snP].mem_block; + mem_block_t* mb_original_p = rlc_pP->pdu_retrans_buffer[snP].mem_block; - if (mb_original != NULL) { - mem_block_t* mb_sub_segment = get_free_mem_block(*sizeP + sizeof(struct mac_tb_req)); - rlc_am_pdu_sn_10_t* pdu_original = (rlc_am_pdu_sn_10_t*) (&mb_original->data[sizeof(struct mac_tb_req)]); - rlc_am_pdu_sn_10_t* pdu_sub_segment = (rlc_am_pdu_sn_10_t*) (&mb_sub_segment->data[sizeof(struct mac_tb_req)]); + if (mb_original_p != NULL) { + mem_block_t* mb_sub_segment_p = get_free_mem_block(*sizeP + sizeof(struct mac_tb_req)); + rlc_am_pdu_sn_10_t* pdu_original_p = (rlc_am_pdu_sn_10_t*) (&mb_original_p->data[sizeof(struct mac_tb_req)]); + rlc_am_pdu_sn_10_t* pdu_sub_segment_p = (rlc_am_pdu_sn_10_t*) (&mb_sub_segment_p->data[sizeof(struct mac_tb_req)]); rlc_am_pdu_info_t pdu_info; int max_copy_payload_size; //LG avoid WARNING int test_max_copy_payload_size; int test_pdu_copy_size = 0; - ((struct mac_tb_req*)(mb_sub_segment->data))->data_ptr = (u8_t*)&(mb_sub_segment->data[sizeof(struct mac_tb_req)]); + ((struct mac_tb_req*)(mb_sub_segment_p->data))->data_ptr = (u8_t*)&(mb_sub_segment_p->data[sizeof(struct mac_tb_req)]); - if (rlc_am_get_data_pdu_infos(frame,pdu_original, rlcP->pdu_retrans_buffer[snP].header_and_payload_size, &pdu_info) >= 0) { + if (rlc_am_get_data_pdu_infos(frameP,pdu_original_p, rlc_pP->pdu_retrans_buffer[snP].header_and_payload_size, &pdu_info) >= 0) { int li_index = 0; - int start_offset = rlcP->pdu_retrans_buffer[snP].nack_so_start; - int stop_offset = rlcP->pdu_retrans_buffer[snP].nack_so_stop; - - LOG_D(RLC, "\n[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] ORIGINAL PDU SN %04d:\n",frame, rlcP->module_id, rlcP->rb_id, snP); - rlc_am_display_data_pdu_infos(rlcP, frame,&pdu_info); + int start_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_start; + int stop_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; + + LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL PDU SN %04d:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP); + rlc_am_display_data_pdu_infos(rlc_pP, frameP,&pdu_info); // all 15 bits set to 1 (indicate that the missing portion of the AMD PDU includes all bytes // to the last byte of the AMD PDU) if (stop_offset == 0x7FFF) { - rlcP->pdu_retrans_buffer[snP].nack_so_stop = rlcP->pdu_retrans_buffer[snP].payload_size - 1; - stop_offset = rlcP->pdu_retrans_buffer[snP].nack_so_stop; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] UPDATED RETRANS PDU SN %04d nack_so_stop FROM 0x7FFF to %05d\n",frame, rlcP->module_id, rlcP->rb_id, snP, stop_offset); + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = rlc_pP->pdu_retrans_buffer[snP].payload_size - 1; + stop_offset = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] UPDATED RETRANS PDU SN %04d nack_so_stop FROM 0x7FFF to %05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, stop_offset); } // FIXED PART AMD PDU SEGMENT HEADER @@ -330,10 +391,10 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame // Furthermore, when an AMD PDU segment header consists of an odd number of LI(s), four padding bits follow after the // last LI. - pdu_sub_segment->b1 = (pdu_original->b1 & 0x83) | 0x40; - pdu_sub_segment->b2 = pdu_original->b2; - pdu_sub_segment->data[0] = ((u8_t)(start_offset >> 8)); - pdu_sub_segment->data[1] = ((u8_t)(start_offset & 0xFF)); + pdu_sub_segment_p->b1 = (pdu_original_p->b1 & 0x83) | 0x40; + pdu_sub_segment_p->b2 = pdu_original_p->b2; + pdu_sub_segment_p->data[0] = ((u8_t)(start_offset >> 8)); + pdu_sub_segment_p->data[1] = ((u8_t)(start_offset & 0xFF)); *sizeP = *sizeP - 4; @@ -347,26 +408,46 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame int test_start_offset; unsigned int test_li_length_in_bytes = 1; s16_t test_li_list[RLC_AM_MAX_SDU_IN_PDU]; - u8_t* fill_payload; + u8_t* fill_payload_p; //int test_fi_last_byte_pdu_is_last_byte_sdu = 0; //int test_fi_first_byte_pdu_is_first_byte_sdu = 0; - rlc_am_e_li_t* e_li_sub_segment = (rlc_am_e_li_t*)(&pdu_sub_segment->data[2]); + rlc_am_e_li_t* e_li_sub_segment = (rlc_am_e_li_t*)(&pdu_sub_segment_p->data[2]); //int first_enter_in_start_offset_lt_li_sum = 1; - int not_fi_original = ((pdu_original->b1 & 0x18) >> 3) ^ 3; + int not_fi_original = ((pdu_original_p->b1 & 0x18) >> 3) ^ 3; //------------------------------------------------------- // set MAX payload size that can be copied // first constraint : the size of the hole to retransmit - rlc_am_get_next_hole(rlcP, frame, snP, &start_offset, &stop_offset); + rlc_am_get_next_hole(rlc_pP, frameP, snP, &start_offset, &stop_offset); max_copy_payload_size = stop_offset - start_offset + 1; assert(max_copy_payload_size > 0); assert(test_pdu_remaining_size > 0); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] HOLE FOUND SO %d -> %d\n",frame, rlcP->module_id, rlcP->rb_id, start_offset, stop_offset); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] ORIGINAL FI %d\n",frame, rlcP->module_id, rlcP->rb_id, (pdu_original->b1 & 0x18) >> 3); - // second constraint the size of the pdu requested by MAC layer + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] HOLE FOUND SO %d -> %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + start_offset, + stop_offset); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL FI %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + (pdu_original_p->b1 & 0x18) >> 3); + // second constraint the size of the pdu_p requested by MAC layer if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, test_pdu_remaining_size); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; } @@ -378,11 +459,30 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame //.find the li corresponding to the nack_so_start (start_offset) if (pdu_info.num_li > 0) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] ORIGINAL NUM LI %d\n",frame, rlcP->module_id, rlcP->rb_id, pdu_info.num_li); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ORIGINAL NUM LI %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info.num_li); while ((li_index < pdu_info.num_li) && (continue_fill_pdu_with_pdu)) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] FIND LI %d\n",frame, rlcP->module_id, rlcP->rb_id, pdu_info.li_list[li_index]); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] FIND LI %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info.li_list[li_index]); if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, test_pdu_remaining_size); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; } assert(max_copy_payload_size >= 0); @@ -393,17 +493,40 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame //--------------------------------------------------------------- if (test_start_offset < test_li_sum) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] test_start_offset < test_li_sum %d < %d\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset, test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] test_start_offset < test_li_sum %d < %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset, + test_li_sum); /*if (test_max_copy_payload_size > (test_li_sum - test_start_offset)) { #ifdef TRACE_RLC_AM_RESEGMENT - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] CUT test_max_copy_payload_size with test_li_sum - test_start_offset %d -> %d\n",frame, rlcP->module_id, rlcP->rb_id, test_max_copy_payload_size, test_li_sum - test_start_offset); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] CUT test_max_copy_payload_size with test_li_sum - test_start_offset %d -> %d\n",frameP, rlc_pP->module_id, rlc_pP->rb_id, test_max_copy_payload_size, test_li_sum - test_start_offset); #endif test_max_copy_payload_size = test_li_sum - test_start_offset; }*/ if ((max_copy_payload_size + test_start_offset) < test_li_sum) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (max_copy_payload_size %d + test_start_offset %d) < test_li_sum %d\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, test_start_offset, test_li_sum); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset , test_start_offset + max_copy_payload_size - 1, max_copy_payload_size ); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size %d + test_start_offset %d) < test_li_sum %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + test_start_offset, + test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset , + test_start_offset + max_copy_payload_size - 1, + max_copy_payload_size ); assert(max_copy_payload_size > 0); continue_fill_pdu_with_pdu = 0; test_pdu_copy_size = test_pdu_copy_size + max_copy_payload_size; @@ -412,8 +535,23 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame max_copy_payload_size = 0; } else if ((max_copy_payload_size + test_start_offset) == test_li_sum) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (max_copy_payload_size + test_start_offset) == test_li_sum %d == %d\n",frame, rlcP->module_id, rlcP->rb_id, (max_copy_payload_size + test_start_offset) , test_li_sum); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset , test_start_offset + max_copy_payload_size - 1, max_copy_payload_size ); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size + test_start_offset) == test_li_sum %d == %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + (max_copy_payload_size + test_start_offset) , + test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset , + test_start_offset + max_copy_payload_size - 1, + max_copy_payload_size ); assert(max_copy_payload_size > 0); continue_fill_pdu_with_pdu = 0; test_pdu_copy_size = test_pdu_copy_size + max_copy_payload_size; @@ -422,8 +560,24 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame max_copy_payload_size = 0; } else if ((max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum %d > %d\n SET LI %d\n",frame, rlcP->module_id, rlcP->rb_id, (max_copy_payload_size + test_start_offset) + (test_li_length_in_bytes ^ 3), test_li_sum, test_li_sum - test_start_offset); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset , test_li_sum - 1, test_li_sum - test_start_offset ); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (max_copy_payload_size + test_start_offset - (test_li_length_in_bytes ^ 3)) > test_li_sum %d > %d\n SET LI %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + (max_copy_payload_size + test_start_offset) + (test_li_length_in_bytes ^ 3), + test_li_sum, + test_li_sum - test_start_offset); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset , + test_li_sum - 1, + test_li_sum - test_start_offset ); assert((test_li_sum - test_start_offset) > 0); test_li_list[test_num_li++] = test_li_sum - test_start_offset; test_pdu_copy_size = test_pdu_copy_size + test_li_sum - test_start_offset; @@ -433,14 +587,36 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame test_li_length_in_bytes; max_copy_payload_size = max_copy_payload_size - test_li_sum + test_start_offset - test_li_length_in_bytes; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] NOW max_copy_payload_size %d BYTES test_start_offset %d\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] NOW max_copy_payload_size %d BYTES test_start_offset %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + test_li_sum); // normally the next while itereation will add bytes to PDU //not_test_fi = not_test_fi | 0x01; // set b0, last byte does correspond to last byte of a SDU test_start_offset = test_li_sum; } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (test_max_copy_payload_size + test_start_offset ) > test_li_sum %d > %d\n NO REMAINING SIZE FOR LI",frame, rlcP->module_id, rlcP->rb_id, (max_copy_payload_size + test_start_offset), test_li_sum); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset , test_li_sum - 1, test_li_sum - test_start_offset ); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (test_max_copy_payload_size + test_start_offset ) > test_li_sum %d > %d\n NO REMAINING SIZE FOR LI", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + (max_copy_payload_size + test_start_offset), + test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPY SO %d -> %d %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset , + test_li_sum - 1, + test_li_sum - test_start_offset ); assert((test_li_sum - test_start_offset) > 0); continue_fill_pdu_with_pdu = 0; test_pdu_copy_size = test_pdu_copy_size + test_li_sum - test_start_offset; @@ -455,7 +631,14 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame // start offset start at the begining of a SDU // and it cant be the first data field of the original PDU } else if (test_start_offset == test_li_sum) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (test_start_offset == test_li_sum) %d == %d\n",frame, rlcP->module_id, rlcP->rb_id, test_start_offset , test_li_sum); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (test_start_offset == test_li_sum) %d == %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_start_offset , + test_li_sum); if ((test_num_li == 0) && (test_pdu_copy_size == 0)) { not_test_fi = not_test_fi | 0x02; // set b1, first byte does correspond to first byte of a SDU } @@ -469,45 +652,76 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame (max_copy_payload_size > 0) ){ if (max_copy_payload_size > test_pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] TRYING HIDDEN SIZE...CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, test_pdu_remaining_size); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] TRYING HIDDEN SIZE...CUT max_copy_payload_size with test_pdu_remaining_size %d -> %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + test_pdu_remaining_size); max_copy_payload_size = test_pdu_remaining_size; } // remaining bytes to fill, redundant check, but ... if ((max_copy_payload_size + test_start_offset) >= (pdu_info.hidden_size + test_li_sum)) { test_pdu_copy_size += (pdu_info.hidden_size + test_li_sum - test_start_offset); - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPYING WHOLE REMAINING SIZE %d (max_copy_payload_size %d, test_start_offset %d, pdu_info.hidden_size %d test_li_sum %d test_pdu_copy_size %d)\n",frame, rlcP->module_id, rlcP->rb_id, pdu_info.hidden_size + test_li_sum - test_start_offset, max_copy_payload_size, test_start_offset, pdu_info.hidden_size, test_li_sum, test_pdu_copy_size); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPYING WHOLE REMAINING SIZE %d (max_copy_payload_size %d, test_start_offset %d, pdu_info.hidden_size %d test_li_sum %d test_pdu_copy_size %d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info.hidden_size + test_li_sum - test_start_offset, + max_copy_payload_size, + test_start_offset, + pdu_info.hidden_size, + test_li_sum, + test_pdu_copy_size); test_start_offset = pdu_info.hidden_size + test_li_sum; not_test_fi = (not_test_fi & 0x2) | (not_fi_original & 0x1); // set b0 idendical to the b0 of the non segmented PDU } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COPYING REMAINING SIZE %d (/%d)\n",frame, rlcP->module_id, rlcP->rb_id, max_copy_payload_size, pdu_info.hidden_size); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COPYING REMAINING SIZE %d (/%d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_copy_payload_size, + pdu_info.hidden_size); test_pdu_copy_size += max_copy_payload_size; test_start_offset = test_start_offset + max_copy_payload_size; not_test_fi = not_test_fi & 0x2; // clear b0 because no SDU ending in this PDU } } } else { // num_li == 0 - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] (num_li == 0)\n",frame, rlcP->module_id, rlcP->rb_id); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] (num_li == 0)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); test_pdu_copy_size = max_copy_payload_size; - if ((stop_offset == (start_offset + max_copy_payload_size - 1)) && (stop_offset == rlcP->pdu_retrans_buffer[snP].payload_size - 1)) { + if ((stop_offset == (start_offset + max_copy_payload_size - 1)) && (stop_offset == rlc_pP->pdu_retrans_buffer[snP].payload_size - 1)) { not_test_fi = (not_test_fi & 0x2) | (not_fi_original & 0x1); // set b0 idendical to the b0 of the non segmented PDU } else { not_test_fi = not_test_fi & 0x2; // clear b0 because no SDU ending in this PDU } } //--------------------------------------------------------------- - /*if (stop_offset == (rlcP->pdu_retrans_buffer[snP].payload_size - 1)) { + /*if (stop_offset == (rlc_pP->pdu_retrans_buffer[snP].payload_size - 1)) { test_fi = (test_fi & 0x02) | (fi_original & 0x01); }*/ //--------------------------------------------------------------- // write FI field in header //--------------------------------------------------------------- - pdu_sub_segment->b1 = pdu_sub_segment->b1 | (((not_test_fi << 3) ^ 0x18) & 0x18); + pdu_sub_segment_p->b1 = pdu_sub_segment_p->b1 | (((not_test_fi << 3) ^ 0x18) & 0x18); //--------------------------------------------------------------- - // fill the segment pdu with Lis and data + // fill the segment pdu_p with Lis and data //--------------------------------------------------------------- - LOG_T(RLC, "[FRAME XXXXX][RLC_AM][MOD XX][RB XX][RE-SEGMENT] fill the segment pdu with Lis and data, test_num_li %d\n",test_num_li); + LOG_T(RLC, "[FRAME XXXXX][RLC_AM][MOD XX][RB XX][RE-SEGMENT] fill the segment pdu_p with Lis and data, test_num_li %d\n", + test_num_li); if (test_num_li > 0) { - pdu_sub_segment->b1 = pdu_sub_segment->b1 | 0x04; // set E bit + pdu_sub_segment_p->b1 = pdu_sub_segment_p->b1 | 0x04; // set E bit test_li_length_in_bytes = 1; for (fill_num_li=0; fill_num_li < test_num_li; fill_num_li++) { test_li_length_in_bytes = test_li_length_in_bytes ^ 3; @@ -520,7 +734,7 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame } e_li_sub_segment->b1 = e_li_sub_segment->b1 | (test_li_list[fill_num_li] >> 4); e_li_sub_segment->b2 = test_li_list[fill_num_li] << 4; - fill_payload = (u8_t*)(&e_li_sub_segment->b3); + fill_payload_p = (u8_t*)(&e_li_sub_segment->b3); *sizeP = *sizeP - 2; } else { if (fill_num_li != (test_num_li - 1)) { @@ -529,46 +743,62 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame e_li_sub_segment->b2 = e_li_sub_segment->b2 | (test_li_list[fill_num_li] >> 8); e_li_sub_segment->b3 = test_li_list[fill_num_li] & 0xFF; e_li_sub_segment++; - fill_payload = (u8_t*)e_li_sub_segment; + fill_payload_p = (u8_t*)e_li_sub_segment; *sizeP = *sizeP - 1; } - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] ADD LI %d\n", frame, rlcP->module_id,rlcP->rb_id, test_li_list[fill_num_li]); + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ADD LI %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + test_li_list[fill_num_li]); } } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] ADD NO LI\n", frame, rlcP->module_id,rlcP->rb_id); - fill_payload = (u8_t*)e_li_sub_segment; + LOG_T(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] ADD NO LI\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + fill_payload_p = (u8_t*)e_li_sub_segment; } //--------------------------------------------------------------- // copy payload to retransmit //--------------------------------------------------------------- - memcpy(fill_payload, - &rlcP->pdu_retrans_buffer[snP].payload[start_offset], + memcpy(fill_payload_p, + &rlc_pP->pdu_retrans_buffer[snP].payload[start_offset], test_pdu_copy_size); - ((struct mac_tb_req*)(mb_sub_segment->data))->tb_size = (((u64_t)fill_payload)+ test_pdu_copy_size) - ((u64_t)(&pdu_sub_segment->b1)); + ((struct mac_tb_req*)(mb_sub_segment_p->data))->tb_size = (((u64_t)fill_payload_p)+ test_pdu_copy_size) - ((u64_t)(&pdu_sub_segment_p->b1)); // set LSF - if ((test_pdu_copy_size + start_offset) == rlcP->pdu_retrans_buffer[snP].payload_size) { - pdu_sub_segment->data[0] = pdu_sub_segment->data[0] | 0x80; + if ((test_pdu_copy_size + start_offset) == rlc_pP->pdu_retrans_buffer[snP].payload_size) { + pdu_sub_segment_p->data[0] = pdu_sub_segment_p->data[0] | 0x80; - rlcP->pdu_retrans_buffer[snP].flags.retransmit = 0; + rlc_pP->pdu_retrans_buffer[snP].flags.retransmit = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES LSF!\n", - frame, - rlcP->module_id,rlcP->rb_id, + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES LSF!\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, snP, start_offset, - ((struct mac_tb_req*)(mb_sub_segment->data))->tb_size, + ((struct mac_tb_req*)(mb_sub_segment_p->data))->tb_size, test_pdu_copy_size); } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES\n", - frame, - rlcP->module_id, - rlcP->rb_id, + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d SO %d %d BYTES PAYLOAD %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, snP, start_offset, - ((struct mac_tb_req*)(mb_sub_segment->data))->tb_size, + ((struct mac_tb_req*)(mb_sub_segment_p->data))->tb_size, test_pdu_copy_size); } LOG_T(RLC, "[FRAME XXXXX][RLC_AM][MOD XX][RB XX][RE-SEGMENT] *sizeP %d = *sizeP %d - test_pdu_copy_size %d\n", @@ -579,55 +809,89 @@ mem_block_t* rlc_am_retransmit_get_subsegment(rlc_am_entity_t *rlcP, u32_t frame //--------------------------------------------------------------- // update nack_so_start //--------------------------------------------------------------- - rlc_am_remove_hole(rlcP, frame, snP, start_offset, test_pdu_copy_size+start_offset - 1); - //rlcP->pdu_retrans_buffer[snP].nack_so_start = rlcP->pdu_retrans_buffer[snP].nack_so_start + test_pdu_copy_size; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] RE-SEND DATA PDU SN %04d NOW nack_so_start %d nack_so_stop %d\n", frame, rlcP->module_id,rlcP->rb_id, snP, rlcP->pdu_retrans_buffer[snP].nack_so_start, rlcP->pdu_retrans_buffer[snP].nack_so_stop); - /*if (rlcP->pdu_retrans_buffer[snP].nack_so_start == rlcP->pdu_retrans_buffer[snP].nack_so_stop) { - rlcP->pdu_retrans_buffer[snP].nack_so_start = 0; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; + rlc_am_remove_hole(rlc_pP, frameP, snP, start_offset, test_pdu_copy_size+start_offset - 1); + //rlc_pP->pdu_retrans_buffer[snP].nack_so_start = rlc_pP->pdu_retrans_buffer[snP].nack_so_start + test_pdu_copy_size; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d NOW nack_so_start %d nack_so_stop %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].nack_so_start, + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop); + /*if (rlc_pP->pdu_retrans_buffer[snP].nack_so_start == rlc_pP->pdu_retrans_buffer[snP].nack_so_stop) { + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = 0; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; }*/ } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] COULD NOT GET INFO FOR DATA PDU SN %04d -> RETURN NULL\n", frame, rlcP->module_id,rlcP->rb_id, snP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] COULD NOT GET INFO FOR DATA PDU SN %04d -> RETURN NULL\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, snP); return NULL; } - rlc_am_pdu_polling(rlcP, frame, pdu_sub_segment, test_pdu_copy_size); + rlc_am_pdu_polling(rlc_pP, frameP, pdu_sub_segment_p, test_pdu_copy_size); - return mb_sub_segment; + return mb_sub_segment_p; } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][RE-SEGMENT] RE-SEND DATA PDU SN %04d BUT NO PDU AVAILABLE -> RETURN NULL\n", frame, rlcP->module_id,rlcP->rb_id, snP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][RE-SEGMENT] RE-SEND DATA PDU SN %04d BUT NO PDU AVAILABLE -> RETURN NULL\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP); assert(3==4); return NULL; } } //----------------------------------------------------------------------------- -void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, u32_t frame, char* messageP) +void rlc_am_tx_buffer_display (rlc_am_entity_t* rlc_pP, frame_t frameP, char* message_pP) //----------------------------------------------------------------------------- { - u16_t sn = rlcP->vt_a; - int i, loop = 0; - - if (messageP) { - LOG_D(RLC, "\n[FRAME %05d][RLC_AM][MOD %02d][RB %02d] Retransmission buffer %s VT(A)=%04d VT(S)=%04d:", frame, rlcP->module_id, rlcP->rb_id, messageP, rlcP->vt_a, rlcP->vt_s); + rlc_sn_t sn = rlc_pP->vt_a; + int i, loop = 0; + + if (message_pP) { + LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] Retransmission buffer %s VT(A)=%04d VT(S)=%04d:", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + message_pP, + rlc_pP->vt_a, + rlc_pP->vt_s); } else { - LOG_D(RLC, "\n[FRAME %05d][RLC_AM][MOD %02d][RB %02d] Retransmission buffer VT(A)=%04d VT(S)=%04d:", frame, rlcP->module_id, rlcP->rb_id, rlcP->vt_a, rlcP->vt_s); + LOG_D(RLC, "\n[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] Retransmission buffer VT(A)=%04d VT(S)=%04d:", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vt_a, + rlc_pP->vt_s); } - while (rlcP->vt_s != sn) { - if (rlcP->pdu_retrans_buffer[sn].mem_block) { + while (rlc_pP->vt_s != sn) { + if (rlc_pP->pdu_retrans_buffer[sn].mem_block) { if ((loop % 1) == 0) { LOG_D(RLC, "\nTX SN:\t"); } - if (rlcP->pdu_retrans_buffer[sn].flags.retransmit) { - LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, rlcP->pdu_retrans_buffer[sn].header_and_payload_size, rlcP->pdu_retrans_buffer[sn].payload_size, rlcP->pdu_retrans_buffer[sn].retx_count); + if (rlc_pP->pdu_retrans_buffer[sn].flags.retransmit) { + LOG_D(RLC, "%04d %d/%d Bytes (NACK RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, rlc_pP->pdu_retrans_buffer[sn].retx_count); } else { - LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, rlcP->pdu_retrans_buffer[sn].header_and_payload_size, rlcP->pdu_retrans_buffer[sn].payload_size, rlcP->pdu_retrans_buffer[sn].retx_count); + LOG_D(RLC, "%04d %d/%d Bytes (RTX:%02d ",sn, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size, rlc_pP->pdu_retrans_buffer[sn].payload_size, rlc_pP->pdu_retrans_buffer[sn].retx_count); } - if (rlcP->pdu_retrans_buffer[sn].num_holes == 0) { - LOG_D(RLC, "SO:%04d->%04d)\t", rlcP->pdu_retrans_buffer[sn].nack_so_start, rlcP->pdu_retrans_buffer[sn].nack_so_stop); + if (rlc_pP->pdu_retrans_buffer[sn].num_holes == 0) { + LOG_D(RLC, "SO:%04d->%04d)\t", rlc_pP->pdu_retrans_buffer[sn].nack_so_start, rlc_pP->pdu_retrans_buffer[sn].nack_so_stop); } else { - for (i=0; i<rlcP->pdu_retrans_buffer[sn].num_holes;i++){ + for (i=0; i<rlc_pP->pdu_retrans_buffer[sn].num_holes;i++){ assert(i < RLC_AM_MAX_HOLES_REPORT_PER_PDU); - LOG_D(RLC, "SO:%04d->%04d)\t", rlcP->pdu_retrans_buffer[sn].hole_so_start[i], rlcP->pdu_retrans_buffer[sn].hole_so_stop[i]); + LOG_D(RLC, "SO:%04d->%04d)\t", rlc_pP->pdu_retrans_buffer[sn].hole_so_start[i], rlc_pP->pdu_retrans_buffer[sn].hole_so_stop[i]); } } loop++; @@ -637,67 +901,89 @@ void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, u32_t frame, char* message LOG_D(RLC, "\n"); } //----------------------------------------------------------------------------- -void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlcP,u32_t frame) +void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - u16_t sn = (rlcP->vt_s - 1) & RLC_AM_SN_MASK; - u16_t sn_end = (rlcP->vt_a - 1) & RLC_AM_SN_MASK; - int found_pdu = 0; - u16_t found_pdu_sn = 0; // avoid warning - mem_block_t* pdu; - rlc_am_pdu_sn_10_t* pdu_sn_10; - - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][FORCE-TRAFFIC] rlc_am_retransmit_any_pdu()\n", frame, rlcP->module_id,rlcP->rb_id); + rlc_sn_t sn = (rlc_pP->vt_s - 1) & RLC_AM_SN_MASK; + rlc_sn_t sn_end = (rlc_pP->vt_a - 1) & RLC_AM_SN_MASK; + int found_pdu = 0; + rlc_sn_t found_pdu_sn = 0; // avoid warning + mem_block_t* pdu_p = NULL; + rlc_am_pdu_sn_10_t* pdu_sn_10_p = NULL; + + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] rlc_am_retransmit_any_pdu()\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); while (sn != sn_end) { - if (rlcP->pdu_retrans_buffer[sn].mem_block != NULL) { + if (rlc_pP->pdu_retrans_buffer[sn].mem_block != NULL) { if (!found_pdu) { found_pdu = 1; found_pdu_sn = sn; } - if (rlcP->pdu_retrans_buffer[sn].header_and_payload_size <= rlcP->nb_bytes_requested_by_mac) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][FORCE-TRAFFIC] RE-SEND DATA PDU SN %04d\n", frame, rlcP->module_id,rlcP->rb_id, sn); - rlc_am_nack_pdu (rlcP, frame, sn, 0, 0x7FFF); - // no need for update rlcP->nb_bytes_requested_by_mac - pdu = rlc_am_retransmit_get_copy(rlcP, frame, sn); - pdu_sn_10 = (rlc_am_pdu_sn_10_t*) (&pdu->data[sizeof(struct mac_tb_req)]); - rlc_am_pdu_polling(rlcP, frame, pdu_sn_10, rlcP->pdu_retrans_buffer[sn].header_and_payload_size); - pdu_sn_10->b1 = pdu_sn_10->b1 | 0x20; - rlcP->c_pdu_without_poll = 0; - rlcP->c_byte_without_poll = 0; - //rlcP->poll_sn = (rlcP->vt_s -1) & RLC_AM_SN_MASK; - rlc_am_start_timer_poll_retransmit(rlcP,frame); - rlcP->stat_tx_data_pdu += 1; - rlcP->stat_tx_retransmit_pdu += 1; - rlcP->stat_tx_data_bytes += ((struct mac_tb_req*)(pdu->data))->tb_size; - rlcP->stat_tx_retransmit_bytes += ((struct mac_tb_req*)(pdu->data))->tb_size; - list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer); + if (rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size <= rlc_pP->nb_bytes_requested_by_mac) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] RE-SEND DATA PDU SN %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, sn); + rlc_am_nack_pdu (rlc_pP, frameP, sn, 0, 0x7FFF); + // no need for update rlc_pP->nb_bytes_requested_by_mac + pdu_p = rlc_am_retransmit_get_copy(rlc_pP, frameP, sn); + pdu_sn_10_p = (rlc_am_pdu_sn_10_t*) (&pdu_p->data[sizeof(struct mac_tb_req)]); + rlc_am_pdu_polling(rlc_pP, frameP, pdu_sn_10_p, rlc_pP->pdu_retrans_buffer[sn].header_and_payload_size); + pdu_sn_10_p->b1 = pdu_sn_10_p->b1 | 0x20; + rlc_pP->c_pdu_without_poll = 0; + rlc_pP->c_byte_without_poll = 0; + //rlc_pP->poll_sn = (rlc_pP->vt_s -1) & RLC_AM_SN_MASK; + rlc_am_start_timer_poll_retransmit(rlc_pP,frameP); + rlc_pP->stat_tx_data_pdu += 1; + rlc_pP->stat_tx_retransmit_pdu += 1; + rlc_pP->stat_tx_data_bytes += ((struct mac_tb_req*)(pdu_p->data))->tb_size; + rlc_pP->stat_tx_retransmit_bytes += ((struct mac_tb_req*)(pdu_p->data))->tb_size; + list_add_tail_eurecom (pdu_p, &rlc_pP->pdus_to_mac_layer); return; } } sn = (sn - 1) & RLC_AM_SN_MASK; } - // no pdu with correct size has been found - // so re-segment a pdu if possible + // no pdu_p with correct size has been found + // so re-segment a pdu_p if possible if (found_pdu) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][FORCE-TRAFFIC] SEND SEGMENT OF DATA PDU SN %04d\n", frame, rlcP->module_id,rlcP->rb_id, found_pdu_sn); - if (rlcP->nb_bytes_requested_by_mac > 4) { - rlc_am_nack_pdu (rlcP, frame, found_pdu_sn, 0, 0x7FFF); - pdu = rlc_am_retransmit_get_subsegment(rlcP, frame, found_pdu_sn, &rlcP->nb_bytes_requested_by_mac); - pdu_sn_10 = (rlc_am_pdu_sn_10_t*) (&pdu->data[sizeof(struct mac_tb_req)]); - rlc_am_pdu_polling(rlcP, frame, pdu_sn_10, rlcP->pdu_retrans_buffer[found_pdu_sn].header_and_payload_size); - pdu_sn_10->b1 = pdu_sn_10->b1 | 0x20; - rlcP->c_pdu_without_poll = 0; - rlcP->c_byte_without_poll = 0; - //rlcP->poll_sn = (rlcP->vt_s -1) & RLC_AM_SN_MASK; - rlc_am_start_timer_poll_retransmit(rlcP,frame); - rlcP->stat_tx_data_pdu += 1; - rlcP->stat_tx_retransmit_pdu += 1; - rlcP->stat_tx_data_bytes += ((struct mac_tb_req*)(pdu->data))->tb_size; - rlcP->stat_tx_retransmit_bytes += ((struct mac_tb_req*)(pdu->data))->tb_size; - list_add_tail_eurecom (pdu, &rlcP->pdus_to_mac_layer); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] SEND SEGMENT OF DATA PDU SN %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + found_pdu_sn); + if (rlc_pP->nb_bytes_requested_by_mac > 4) { + rlc_am_nack_pdu (rlc_pP, frameP, found_pdu_sn, 0, 0x7FFF); + pdu_p = rlc_am_retransmit_get_subsegment(rlc_pP, frameP, found_pdu_sn, &rlc_pP->nb_bytes_requested_by_mac); + pdu_sn_10_p = (rlc_am_pdu_sn_10_t*) (&pdu_p->data[sizeof(struct mac_tb_req)]); + rlc_am_pdu_polling(rlc_pP, frameP, pdu_sn_10_p, rlc_pP->pdu_retrans_buffer[found_pdu_sn].header_and_payload_size); + pdu_sn_10_p->b1 = pdu_sn_10_p->b1 | 0x20; + rlc_pP->c_pdu_without_poll = 0; + rlc_pP->c_byte_without_poll = 0; + //rlc_pP->poll_sn = (rlc_pP->vt_s -1) & RLC_AM_SN_MASK; + rlc_am_start_timer_poll_retransmit(rlc_pP,frameP); + rlc_pP->stat_tx_data_pdu += 1; + rlc_pP->stat_tx_retransmit_pdu += 1; + rlc_pP->stat_tx_data_bytes += ((struct mac_tb_req*)(pdu_p->data))->tb_size; + rlc_pP->stat_tx_retransmit_bytes += ((struct mac_tb_req*)(pdu_p->data))->tb_size; + list_add_tail_eurecom (pdu_p, &rlc_pP->pdus_to_mac_layer); return; } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][FORCE-TRAFFIC] ... BUT NOT ENOUGH BYTES ALLOWED BY MAC %0d\n", frame, rlcP->module_id,rlcP->rb_id, rlcP->nb_bytes_requested_by_mac); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][FORCE-TRAFFIC] ... BUT NOT ENOUGH BYTES ALLOWED BY MAC %0d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->nb_bytes_requested_by_mac); } } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h index ee11c1711081a625f7c80d6f270d78a43e578293..ffef72c73236e3e038d312b2df46a1c755b41db6 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_retransmit.h @@ -57,58 +57,58 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_am_retransmit(x) extern x # endif # endif -/*! \fn void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_endP) +/*! \fn void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, frame_t frameP, u16_t snP, sdu_size_t so_startP, sdu_size_t so_endP) * \brief The RLC AM PDU which have the sequence number snP is marked NACKed with segment offset fields. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. * \param[in] snP Sequence number of the PDU that is negative acknowledged. * \param[in] so_startP Start of the segment offset of the PDU that . * \param[in] so_endP Transport blocks received from MAC layer. * \note It may appear a new hole in the retransmission buffer depending on the segment offset informations. Depending on the state of the retransmission buffer, negative confirmation can be sent to higher layers about the drop by the RLC AM instance of a particular SDU. */ -protected_rlc_am_retransmit(void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_endP);) +protected_rlc_am_retransmit(void rlc_am_nack_pdu (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, sdu_size_t so_startP, sdu_size_t so_endP);) -/*! \fn void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP) +/*! \fn void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP) * \brief The RLC AM PDU which have the sequence number snP is marked ACKed. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. * \param[in] snP Sequence number of the PDU that is acknowledged. * \note Depending on the state of the retransmission buffer, positive confirmation can be sent to higher layers about the receiving by the peer RLC AM instance of a particular SDU. */ -protected_rlc_am_retransmit(void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP);) +protected_rlc_am_retransmit(void rlc_am_ack_pdu (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP);) -/*! \fn mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP) +/*! \fn mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP) * \brief The RLC AM PDU which have the sequence number snP is marked ACKed. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. * \param[in] snP Sequence number of the PDU to be copied. * \return A copy of the PDU having sequence number equal to parameter snP. */ -protected_rlc_am_retransmit(mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP)); +protected_rlc_am_retransmit(mem_block_t* rlc_am_retransmit_get_copy (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP)); -/*! \fn mem_block_t* rlc_am_retransmit_get_subsegment (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t *sizeP) +/*! \fn mem_block_t* rlc_am_retransmit_get_subsegment (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, sdu_size_t *sizeP) * \brief The RLC AM PDU which have the sequence number snP is marked ACKed. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] frameP Frame index * \param[in] snP Sequence number of the PDU to be copied. * \param[in,out] sizeP Maximum size allowed for the subsegment, it is updated with the amount of bytes not used (sizeP[out] = sizeP[in] - size of segment). * \return A copy of a segment of the PDU having sequence number equal to parameter snP. */ -protected_rlc_am_retransmit(mem_block_t* rlc_am_retransmit_get_subsegment (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t *sizeP)); +protected_rlc_am_retransmit(mem_block_t* rlc_am_retransmit_get_subsegment (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, sdu_size_t *sizeP)); -/*! \fn void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlcP,u32_t frame) +/*! \fn void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlcP,frame_t frameP) * \brief Retransmit any PDU in order to unblock peer entity, if no suitable PDU is found (depending on requested MAC size) to be retransmitted, then try to retransmit a subsegment of any PDU. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. */ -protected_rlc_am_retransmit(void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlcP,u32_t frame);) +protected_rlc_am_retransmit(void rlc_am_retransmit_any_pdu(rlc_am_entity_t* rlcP,frame_t frameP);) -/*! \fn void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, u32_t frame, char* messageP) +/*! \fn void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, frame_t frameP, char* message_pP) * \brief Display the dump of the retransmission buffer. * \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. -* \param[in] messageP Message to be displayed along with the display of the dump of the retransmission buffer. +* \param[in] frameP Frame index. +* \param[in] message_pP Message to be displayed along with the display of the dump of the retransmission buffer. */ -protected_rlc_am_retransmit(void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, u32_t frame, char* messageP);) +protected_rlc_am_retransmit(void rlc_am_tx_buffer_display (rlc_am_entity_t* rlcP, frame_t frameP, char* message_pP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c index f273ecafd68c3447ce7db727f6be43febf5f9b86..0563b4f2d529e51b865ca81516c8998c398b6cb3 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.c @@ -44,356 +44,668 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis // returns 0 if success // returns neg value if failure //----------------------------------------------------------------------------- -signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlcP, u32 frame, mem_block_t* tbP) +signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP, mem_block_t* tb_pP) //----------------------------------------------------------------------------- { - rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor; - rlc_am_pdu_info_t* pdu_info_previous_cursor; - mem_block_t* cursor; - mem_block_t* previous_cursor = NULL; + rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; + rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; + rlc_am_pdu_info_t* pdu_info_previous_cursor_p = NULL; + mem_block_t* cursor_p = NULL; + mem_block_t* previous_cursor_p = NULL; - cursor = rlcP->receiver_buffer.head; + cursor_p = rlc_pP->receiver_buffer.head; // it is assumed this pdu is in rx window - if (cursor) { - if (rlcP->vr_mr < rlcP->vr_r) { - if (pdu_info->sn >= rlcP->vr_r) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - while ((cursor != NULL) && (pdu_info_cursor->sn >= rlcP->vr_r)){ // LG added = - if (pdu_info->sn < pdu_info_cursor->sn) { - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info->sn)) { - if (pdu_info->rf != pdu_info_previous_cursor->rf) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + if (cursor_p) { + if (rlc_pP->vr_mr < rlc_pP->vr_r) { + if (pdu_info_p->sn >= rlc_pP->vr_r) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + while ((cursor_p != NULL) && (pdu_info_cursor_p->sn >= rlc_pP->vr_r)){ // LG added = + if (pdu_info_p->sn < pdu_info_cursor_p->sn) { + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_p->sn)) { + if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - if ((pdu_info_previous_cursor->so + pdu_info_previous_cursor->payload_size - 1) >= pdu_info->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->rf == 1) { + if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) >= pdu_info_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info->sn == pdu_info_cursor->sn) { - if (pdu_info_cursor->rf == 0) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { + if (pdu_info_cursor_p->rf == 0) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - if ((pdu_info->so + pdu_info->payload_size - 1) < pdu_info_cursor->so) { - - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info_cursor->sn)) { - if ((pdu_info_previous_cursor->so + pdu_info_previous_cursor->payload_size - 1) < pdu_info->so) { - - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + } else if (pdu_info_p->rf == 1) { + if ((pdu_info_p->so + pdu_info_p->payload_size - 1) < pdu_info_cursor_p->so) { + + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn)) { + if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) < pdu_info_p->so) { + + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info->so <= pdu_info_cursor->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->so <= pdu_info_cursor_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } - previous_cursor = cursor; - cursor = cursor->next; - if (cursor != NULL) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; + previous_cursor_p = cursor_p; + cursor_p = cursor_p->next; + if (cursor_p != NULL) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; } } - if (cursor != NULL) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + if (cursor_p != NULL) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - if (pdu_info_cursor->rf == 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + if (pdu_info_cursor_p->rf == 0) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; - } else if ((pdu_info->rf == 1) && (pdu_info_cursor->rf == 1) && (pdu_info->sn == pdu_info_cursor->sn)) { - if ((pdu_info_cursor->so + pdu_info_cursor->payload_size - 1) < pdu_info->so) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + } else if ((pdu_info_p->rf == 1) && (pdu_info_cursor_p->rf == 1) && (pdu_info_p->sn == pdu_info_cursor_p->sn)) { + if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } - } else if (pdu_info->sn != pdu_info_cursor->sn) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + } else if (pdu_info_p->sn != pdu_info_cursor_p->sn) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } } - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else { // (pdu_info->sn < rlcP->vr_r) - cursor = rlcP->receiver_buffer.tail; - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - while ((cursor != NULL) && (pdu_info_cursor->sn < rlcP->vr_r)){ - //pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if (pdu_info->sn > pdu_info_cursor->sn) { - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info_cursor->sn)) { - if (pdu_info->rf != pdu_info_previous_cursor->rf) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else { // (pdu_info_p->sn < rlc_pP->vr_r) + cursor_p = rlc_pP->receiver_buffer.tail; + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + while ((cursor_p != NULL) && (pdu_info_cursor_p->sn < rlc_pP->vr_r)){ + //pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if (pdu_info_p->sn > pdu_info_cursor_p->sn) { + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn)) { + if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - if ((pdu_info->so + pdu_info->payload_size - 1) >= pdu_info_previous_cursor->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->rf == 1) { + if ((pdu_info_p->so + pdu_info_p->payload_size - 1) >= pdu_info_previous_cursor_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) < vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_insert_after_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info->sn == pdu_info_cursor->sn) { - if (pdu_info_cursor->rf == 0) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { + if (pdu_info_cursor_p->rf == 0) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - if ((pdu_info_cursor->so + pdu_info_cursor->payload_size - 1) < pdu_info->so) { - - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info_cursor->sn)) { - if ((pdu_info->so + pdu_info->payload_size - 1) < pdu_info_previous_cursor->so) { - - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - list2_insert_after_element(tbP, cursor, &rlcP->receiver_buffer); + } else if (pdu_info_p->rf == 1) { + if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { + + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn)) { + if ((pdu_info_p->so + pdu_info_p->payload_size - 1) < pdu_info_previous_cursor_p->so) { + + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - list2_insert_after_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) < vr(r) and sn < vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info_cursor->so <= pdu_info->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_cursor_p->so <= pdu_info_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } - previous_cursor = cursor; - cursor = cursor->previous; - if (cursor != NULL) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; + previous_cursor_p = cursor_p; + cursor_p = cursor_p->previous; + if (cursor_p != NULL) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; } } - if (cursor != NULL) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn < vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_insert_after_element(tbP, cursor, &rlcP->receiver_buffer); + if (cursor_p != NULL) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and sn < vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_insert_after_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - if (pdu_info_cursor->rf == 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + if (pdu_info_cursor_p->rf == 0) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; - } else if ((pdu_info->rf == 1) && (pdu_info_cursor->rf == 1) && (pdu_info->sn == pdu_info_cursor->sn)) { - if ((pdu_info_cursor->so + pdu_info_cursor->payload_size - 1) < pdu_info->so) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + } else if ((pdu_info_p->rf == 1) && (pdu_info_cursor_p->rf == 1) && (pdu_info_p->sn == pdu_info_cursor_p->sn)) { + if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } - } else if (pdu_info->sn != pdu_info_cursor->sn) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_tail(tbP, &rlcP->receiver_buffer); + } else if (pdu_info_p->sn != pdu_info_cursor_p->sn) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) < vr(r) and vr(h) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } } - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } - } else { // (pdu_info->vr_mr > rlcP->vr_r), > and not >= + } else { // (pdu_info_p->vr_mr > rlc_pP->vr_r), > and not >= // FAR MORE SIMPLE CASE - while (cursor != NULL){ - //msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d cursor %p\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, cursor); - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if (pdu_info->sn < pdu_info_cursor->sn) { - - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info->sn)) { - if (pdu_info->rf != pdu_info_previous_cursor->rf) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + while (cursor_p != NULL){ + //msg ("[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d cursor_p %p\n", frameP, rlc_pP->module_id, rlc_pP->rb_id, __LINE__, cursor_p); + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if (pdu_info_p->sn < pdu_info_cursor_p->sn) { + + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_p->sn)) { + if (pdu_info_p->rf != pdu_info_previous_cursor_p->rf) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - if ((pdu_info_previous_cursor->so + pdu_info_previous_cursor->payload_size - 1) >= pdu_info->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) > vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->rf == 1) { + if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) >= pdu_info_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SO OVERLAP -> DROPPED (vr(mr) > vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info->sn == pdu_info_cursor->sn) { - if (pdu_info_cursor->rf == 0) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->sn == pdu_info_cursor_p->sn) { + if (pdu_info_cursor_p->rf == 0) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d WRONG RF -> DROPPED (vr(mr) > vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; - } else if (pdu_info->rf == 1) { - - if ((pdu_info->so + pdu_info->payload_size - 1) < pdu_info_cursor->so) { - - if (previous_cursor != NULL) { - pdu_info_previous_cursor = &((rlc_am_rx_pdu_management_t*)(previous_cursor->data))->pdu_info; - if ((pdu_info_previous_cursor->sn == pdu_info_cursor->sn)) { - if ((pdu_info_previous_cursor->so + pdu_info_previous_cursor->payload_size - 1) < pdu_info->so) { - - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] PREVIOUS SO %d PAYLOAD SIZE %d\n", frame, rlcP->module_id, rlcP->rb_id, pdu_info_previous_cursor->so, pdu_info_previous_cursor->payload_size); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + } else if (pdu_info_p->rf == 1) { + + if ((pdu_info_p->so + pdu_info_p->payload_size - 1) < pdu_info_cursor_p->so) { + + if (previous_cursor_p != NULL) { + pdu_info_previous_cursor_p = &((rlc_am_rx_pdu_management_t*)(previous_cursor_p->data))->pdu_info; + if ((pdu_info_previous_cursor_p->sn == pdu_info_cursor_p->sn)) { + if ((pdu_info_previous_cursor_p->so + pdu_info_previous_cursor_p->payload_size - 1) < pdu_info_p->so) { + + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] PREVIOUS SO %d PAYLOAD SIZE %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_info_previous_cursor_p->so, + pdu_info_previous_cursor_p->payload_size); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP PREVIOUS SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn, pdu_info->so); - list2_insert_before_element(tbP, cursor, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d SEGMENT OFFSET %05d (vr(mr) > vr(r) and sn >= vr(r))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn, + pdu_info_p->so); + list2_insert_before_element(tb_pP, cursor_p, &rlc_pP->receiver_buffer); return 0; - } else if (pdu_info->so <= pdu_info_cursor->so) { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + } else if (pdu_info_p->so <= pdu_info_cursor_p->so) { + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } - previous_cursor = cursor; - cursor = cursor->next; + previous_cursor_p = cursor_p; + cursor_p = cursor_p->next; } - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))(last inserted)\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - // pdu_info_cursor can not be NULL here - if (pdu_info->sn == pdu_info_cursor->sn) { - if ((pdu_info_cursor->so + pdu_info_cursor->payload_size - 1) < pdu_info->so) { - list2_add_tail(tbP, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (vr(mr) > vr(r))(last inserted)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + // pdu_info_cursor_p can not be NULL here + if (pdu_info_p->sn == pdu_info_cursor_p->sn) { + if ((pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size - 1) < pdu_info_p->so) { + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d OVERLAP SO DUPLICATE -> DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -2; } } else { - list2_add_tail(tbP, &rlcP->receiver_buffer); + list2_add_tail(tb_pP, &rlc_pP->receiver_buffer); return 0; } } } else { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d (only inserted)\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); - list2_add_head(tbP, &rlcP->receiver_buffer); + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d (only inserted)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); + list2_add_head(tb_pP, &rlc_pP->receiver_buffer); return 0; } - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][INSERT PDU] LINE %d RX PDU SN %04d DROPPED @4\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_info->sn); + LOG_N(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][INSERT PDU] LINE %d RX PDU SN %04d DROPPED @4\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_info_p->sn); return -1; } //----------------------------------------------------------------------------- -void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP) +void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlc_pP, frame_t frameP, mem_block_t* tb_pP) //----------------------------------------------------------------------------- { - rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(tbP->data))->pdu_info; - mem_block_t* cursor; - mem_block_t* first_cursor; - u16_t sn = pdu_info->sn; - //list2_t list; - u16_t next_waited_so; - u16_t last_end_so; + rlc_am_pdu_info_t *pdu_info_p = &((rlc_am_rx_pdu_management_t*)(tb_pP->data))->pdu_info; + mem_block_t *cursor_p = NULL; + mem_block_t *first_cursor_p = NULL; + rlc_sn_t sn = pdu_info_p->sn; + sdu_size_t next_waited_so; + sdu_size_t last_end_so; //msg("rlc_am_rx_check_all_byte_segments(%d) @0\n",sn); - if (pdu_info->rf == 0) { - ((rlc_am_rx_pdu_management_t*)(tbP->data))->all_segments_received = 1; + if (pdu_info_p->rf == 0) { + ((rlc_am_rx_pdu_management_t*)(tb_pP->data))->all_segments_received = 1; return; } // for re-segmented AMD PDUS - cursor = tbP; + cursor_p = tb_pP; //list2_init(&list, NULL); - //list2_add_head(cursor, &list); + //list2_add_head(cursor_p, &list); //msg("rlc_am_rx_check_all_byte_segments(%d) @1\n",sn); // get all previous PDU with same SN - while (cursor->previous != NULL) { - if (((rlc_am_rx_pdu_management_t*)(cursor->previous->data))->pdu_info.sn == sn) { - //list2_add_head(cursor->previous, &list); - cursor = cursor->previous; + while (cursor_p->previous != NULL) { + if (((rlc_am_rx_pdu_management_t*)(cursor_p->previous->data))->pdu_info.sn == sn) { + //list2_add_head(cursor_p->previous, &list); + cursor_p = cursor_p->previous; //msg("rlc_am_rx_check_all_byte_segments(%d) @2\n",sn); } else { break; } } - // in case all first segments up to tbP are in list + // in case all first segments up to tb_pP are in list // the so field of the first PDU should be 0 - //cursor = list.head; - pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if (pdu_info->so != 0) { + //cursor_p = list.head; + pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if (pdu_info_p->so != 0) { return; } //msg("rlc_am_rx_check_all_byte_segments(%d) @3\n",sn); - next_waited_so = pdu_info->payload_size; - first_cursor = cursor; + next_waited_so = pdu_info_p->payload_size; + first_cursor_p = cursor_p; // then check if all segments are contiguous - last_end_so = pdu_info->payload_size; - while (cursor->next != NULL) { + last_end_so = pdu_info_p->payload_size; + while (cursor_p->next != NULL) { //msg("rlc_am_rx_check_all_byte_segments(%d) @4\n",sn); - cursor = cursor->next; - pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; + cursor_p = cursor_p->next; + pdu_info_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; - if (pdu_info->sn == sn) { + if (pdu_info_p->sn == sn) { // extra check normally not necessary if ( - !(pdu_info->rf == 1) || - !(pdu_info->so <= last_end_so) + !(pdu_info_p->rf == 1) || + !(pdu_info_p->so <= last_end_so) ) { - //msg("rlc_am_rx_check_all_byte_segments(%d) @5 pdu_info->rf %d pdu_info->so %d\n",sn, pdu_info->rf, pdu_info->so); + //msg("rlc_am_rx_check_all_byte_segments(%d) @5 pdu_info_p->rf %d pdu_info_p->so %d\n",sn, pdu_info_p->rf, pdu_info_p->so); return; } else { - if (pdu_info->so == next_waited_so) { - next_waited_so = next_waited_so + pdu_info->payload_size; + if (pdu_info_p->so == next_waited_so) { + next_waited_so = next_waited_so + pdu_info_p->payload_size; //msg("rlc_am_rx_check_all_byte_segments(%d) @6\n",sn); - } else { // assumed pdu_info->so + pdu_info->payload_size > next_waited_so - next_waited_so = (next_waited_so + pdu_info->payload_size) - (next_waited_so - pdu_info->so); + } else { // assumed pdu_info_p->so + pdu_info_p->payload_size > next_waited_so + next_waited_so = (next_waited_so + pdu_info_p->payload_size) - (next_waited_so - pdu_info_p->so); //msg("rlc_am_rx_check_all_byte_segments(%d) @7\n",sn); } - if (pdu_info->lsf > 0) { + if (pdu_info_p->lsf > 0) { //msg("rlc_am_rx_check_all_byte_segments(%d) @8\n",sn); - rlc_am_rx_mark_all_segments_received(rlcP, frame, first_cursor); + rlc_am_rx_mark_all_segments_received(rlc_pP, frameP, first_cursor_p); } } - last_end_so = pdu_info->so + pdu_info->payload_size; + last_end_so = pdu_info_p->so + pdu_info_p->payload_size; } else { //msg("rlc_am_rx_check_all_byte_segments(%d) @9\n",sn); return; @@ -401,84 +713,92 @@ void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, u32_t frame, mem_b } } //----------------------------------------------------------------------------- -void rlc_am_rx_mark_all_segments_received(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* fisrt_segment_tbP) +void rlc_am_rx_mark_all_segments_received(rlc_am_entity_t* rlc_pP, frame_t frameP, mem_block_t* fisrt_segment_tbP) //----------------------------------------------------------------------------- { - rlc_am_pdu_info_t* pdu_info = &((rlc_am_rx_pdu_management_t*)(fisrt_segment_tbP->data))->pdu_info; - rlc_am_pdu_info_t* pdu_info_cursor; - mem_block_t* cursor; - u16_t sn = pdu_info->sn; - - cursor = fisrt_segment_tbP; - if (cursor) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][PROCESS RX PDU] ALL SEGMENTS RECEIVED SN %04d:\n", frame, rlcP->module_id, rlcP->rb_id, sn); + rlc_am_pdu_info_t* pdu_info_p = &((rlc_am_rx_pdu_management_t*)(fisrt_segment_tbP->data))->pdu_info; + rlc_am_pdu_info_t* pdu_info_cursor_p = NULL; + mem_block_t* cursor_p = NULL; + rlc_sn_t sn = pdu_info_p->sn; + + cursor_p = fisrt_segment_tbP; + if (cursor_p) { + LOG_D(RLC, "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u][PROCESS RX PDU] ALL SEGMENTS RECEIVED SN %04d:\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); do { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - if (pdu_info_cursor->sn == sn) { - ((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received = 1; + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + if (pdu_info_cursor_p->sn == sn) { + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received = 1; } else { return; } - cursor = cursor->next; - } while (cursor != NULL); + cursor_p = cursor_p->next; + } while (cursor_p != NULL); } } //----------------------------------------------------------------------------- -void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlcP,u32_t frame, u8_t eNB_flag) +void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlc_pP,frame_t frameP, u8_t eNB_flag) //----------------------------------------------------------------------------- { - mem_block_t* cursor; - rlc_am_rx_pdu_management_t* rlc_am_rx_old_pdu_management; + mem_block_t* cursor_p = NULL; + rlc_am_rx_pdu_management_t* rlc_am_rx_old_pdu_management = NULL; - cursor = list2_get_head(&rlcP->receiver_buffer); - if (cursor == NULL) { + cursor_p = list2_get_head(&rlc_pP->receiver_buffer); + if (cursor_p == NULL) { return; } - rlc_am_rx_pdu_management_t* rlc_am_rx_pdu_management = ((rlc_am_rx_pdu_management_t*)(cursor->data)); + rlc_am_rx_pdu_management_t* rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); do { - if (rlc_am_rx_pdu_management->all_segments_received > 0) { - cursor = list2_remove_head(&rlcP->receiver_buffer); - rlc_am_reassemble_pdu(rlcP, frame, eNB_flag, cursor); - rlc_am_rx_old_pdu_management = rlc_am_rx_pdu_management; - cursor = list2_get_head(&rlcP->receiver_buffer); - if (cursor == NULL) { + if (rlc_am_rx_pdu_management_p->all_segments_received > 0) { + cursor_p = list2_remove_head(&rlc_pP->receiver_buffer); + rlc_am_reassemble_pdu(rlc_pP, frameP, eNB_flag, cursor_p); + rlc_am_rx_old_pdu_management = rlc_am_rx_pdu_management_p; + cursor_p = list2_get_head(&rlc_pP->receiver_buffer); + if (cursor_p == NULL) { return; } - rlc_am_rx_pdu_management = ((rlc_am_rx_pdu_management_t*)(cursor->data)); + rlc_am_rx_pdu_management_p = ((rlc_am_rx_pdu_management_t*)(cursor_p->data)); } else { #if defined(RLC_STOP_ON_LOST_PDU) - if (list2_get_head(&rlcP->receiver_buffer) != cursor) { + if (list2_get_head(&rlc_pP->receiver_buffer) != cursor_p) { AssertFatal( 0 == 1, - "[FRAME %05d][RLC_AM][MOD %d][RB %d] LOST PDU DETECTED\n", frame, rlcP->module_id, rlcP->rb_id); + "[FRAME %05u][%s][RLC_AM][MOD %u/%u][RB %u] LOST PDU DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } #endif return; } - } while ((rlc_am_rx_pdu_management->pdu_info.sn == ((rlc_am_rx_old_pdu_management->pdu_info.sn + 1) & RLC_AM_SN_MASK)) || ((rlc_am_rx_pdu_management->pdu_info.sn == rlc_am_rx_old_pdu_management->pdu_info.sn) && (rlc_am_rx_pdu_management->all_segments_received > 0))); + } while ((rlc_am_rx_pdu_management_p->pdu_info.sn == ((rlc_am_rx_old_pdu_management->pdu_info.sn + 1) & RLC_AM_SN_MASK)) || ((rlc_am_rx_pdu_management_p->pdu_info.sn == rlc_am_rx_old_pdu_management->pdu_info.sn) && (rlc_am_rx_pdu_management_p->all_segments_received > 0))); } //----------------------------------------------------------------------------- mem_block_t * -list2_insert_before_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP) +list2_insert_before_element (mem_block_t * element_to_insert_pP, mem_block_t * element_pP, list2_t * list_pP) //----------------------------------------------------------------------------- { - //msg ("list2_insert_before_element\n"); - //check_mem_area(NULL); - if ((element_to_insertP != NULL) && (elementP != NULL)) { - listP->nb_elements = listP->nb_elements + 1; - mem_block_t *previous = elementP->previous; - element_to_insertP->previous = previous; - element_to_insertP->next = elementP; - elementP->previous = element_to_insertP; + if ((element_to_insert_pP != NULL) && (element_pP != NULL)) { + list_pP->nb_elements = list_pP->nb_elements + 1; + mem_block_t *previous = element_pP->previous; + element_to_insert_pP->previous = previous; + element_to_insert_pP->next = element_pP; + element_pP->previous = element_to_insert_pP; if (previous != NULL) { - previous->next = element_to_insertP; - } else if (listP->head == elementP) { - listP->head = element_to_insertP; + previous->next = element_to_insert_pP; + } else if (list_pP->head == element_pP) { + list_pP->head = element_to_insert_pP; } - //check_mem_area(NULL); - return element_to_insertP; + return element_to_insert_pP; } else { assert(2==1); return NULL; @@ -486,72 +806,69 @@ list2_insert_before_element (mem_block_t * element_to_insertP, mem_block_t * ele } //----------------------------------------------------------------------------- mem_block_t * -list2_insert_after_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP) +list2_insert_after_element (mem_block_t * element_to_insert_pP, mem_block_t * element_pP, list2_t * list_pP) //----------------------------------------------------------------------------- { - //msg ("list2_insert_after_element\n"); - //check_mem_area(NULL); - - if ((element_to_insertP != NULL) && (elementP != NULL)) { - listP->nb_elements = listP->nb_elements + 1; - mem_block_t *next = elementP->next; - element_to_insertP->previous = elementP; - element_to_insertP->next = next; - elementP->next = element_to_insertP; + + if ((element_to_insert_pP != NULL) && (element_pP != NULL)) { + list_pP->nb_elements = list_pP->nb_elements + 1; + mem_block_t *next = element_pP->next; + element_to_insert_pP->previous = element_pP; + element_to_insert_pP->next = next; + element_pP->next = element_to_insert_pP; if (next != NULL) { - next->previous = element_to_insertP; - } else if (listP->tail == elementP) { - listP->tail = element_to_insertP; + next->previous = element_to_insert_pP; + } else if (list_pP->tail == element_pP) { + list_pP->tail = element_to_insert_pP; } - //check_mem_area(NULL); - return element_to_insertP; + return element_to_insert_pP; } else { assert(2==1); return NULL; } } //----------------------------------------------------------------------------- -void rlc_am_rx_list_display (rlc_am_entity_t* rlcP, char* messageP) +void rlc_am_rx_list_display (rlc_am_entity_t* rlc_pP, char* message_pP) //----------------------------------------------------------------------------- { - mem_block_t *cursor; - unsigned int loop = 0; + mem_block_t *cursor_p = NULL; + unsigned int loop = 0; - cursor = rlcP->receiver_buffer.head; - if (messageP) { - LOG_T(RLC, "Display list %s %s VR(R)=%04d:\n", rlcP->receiver_buffer.name, messageP, rlcP->vr_r); + cursor_p = rlc_pP->receiver_buffer.head; + if (message_pP) { + LOG_T(RLC, "Display list %s %s VR(R)=%04d:\n", rlc_pP->receiver_buffer.name, message_pP, rlc_pP->vr_r); } else { - LOG_T(RLC, "Display list %s VR(R)=%04d:\n", rlcP->receiver_buffer.name, rlcP->vr_r); + LOG_T(RLC, "Display list %s VR(R)=%04d:\n", rlc_pP->receiver_buffer.name, rlc_pP->vr_r); } - if (cursor) { + if (cursor_p) { // almost one element - while (cursor != NULL) { + while (cursor_p != NULL) { //if (((loop % 16) == 0) && (loop > 0)) { if ((loop % 4) == 0) { LOG_T(RLC, "\nRX SN:\t"); } - if (((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.rf) { - if (((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.lsf) { + if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.rf) { + if (((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.lsf) { LOG_T(RLC, "%04d (%04d->%04d LSF)\t", - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.so, - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.payload_size - 1); + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so, + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size - 1); } else { LOG_T(RLC, "%04d (%04d->%04d)\t", - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.so, - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.payload_size - 1); + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so, + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.so + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size - 1); } } else { LOG_T(RLC, "%04d (%04d NOSEG)\t", - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.sn, - ((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info.payload_size); + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.sn, + ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info.payload_size); } - //if (cursor == cursor->next) { + //if (cursor_p == cursor_p->next) { // rlc_am_v9_3_0_test_print_trace(); //} - assert(cursor != cursor->next); - cursor = cursor->next; + assert(cursor_p != cursor_p->next); + cursor_p = cursor_p->next; loop++; } LOG_T(RLC, "\n"); diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h index 3f2d086ed6f0ca3c2bb1b75011711195c8bd01e7..2a9d0c3a88c8390ff7fdfaaf6ea27ec6205b5fb1 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_rx_list.h @@ -66,38 +66,38 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "PHY/defs.h" //----------------------------------------------------------------------------- -/*! \fn signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlcP u32_t frame, mem_block_t* tbP) +/*! \fn signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlcP frame_t frameP, mem_block_t* tbP) * \brief Insert a PDU in the RX buffer (implemented with a list). * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] tbP A PDU embedded in a mem_block_t. * \return Zero if the PDU could be inserted in the RX buffer, a negative value if the PDU could not be inserted. */ -protected_rlc_am_rx_list( signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP);) +protected_rlc_am_rx_list( signed int rlc_am_rx_list_insert_pdu(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* tbP);) -/*! \fn void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP) +/*! \fn void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* tbP) * \brief Check if all sub-segments of a PDU are received, if yes then call rlc_am_rx_mark_all_segments_received() procedure. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] tbP A PDU embedded in a mem_block_t. */ -protected_rlc_am_rx_list( void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP);) +protected_rlc_am_rx_list( void rlc_am_rx_check_all_byte_segments(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* tbP);) -/*! \fn void rlc_am_rx_mark_all_segments_received (rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* first_segment_tbP) +/*! \fn void rlc_am_rx_mark_all_segments_received (rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* first_segment_tbP) * \brief Mark all PDUs having the same sequence number as first_segment_tbP with the information that all segments have been received. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] first_segment_tbP A PDU embedded in a mem_block_t, it is the first PDU in the RX buffer (list) that have its sequence number. */ -protected_rlc_am_rx_list( void rlc_am_rx_mark_all_segments_received(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* first_segment_tbP);) +protected_rlc_am_rx_list( void rlc_am_rx_mark_all_segments_received(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* first_segment_tbP);) -/*! \fn void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlcP,u32_t frame,u8_t eNB_flag) +/*! \fn void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlcP,frame_t frameP,u8_t eNB_flag) * \brief Reassembly all SDUS that it is possible to reassembly by parsing the RX buffer and looking for PDUs having the flag 'all segments received'. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0). */ -protected_rlc_am_rx_list( void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlcP,u32_t frame,u8_t eNB_flag);) +protected_rlc_am_rx_list( void rlc_am_rx_list_reassemble_rlc_sdus(rlc_am_entity_t* rlcP,frame_t frameP,u8_t eNB_flag);) /*! \fn mem_block_t* list2_insert_before_element (mem_block_t * element_to_insertP, mem_block_t * elementP, list2_t * listP) * \brief Insert a PDU embedded in a mem_block_t in a list at a position before a designated element of the list. diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c index 213a051c56e316ab215e8f1b6959a7d03ff77e84..3d6cbdf8c9bea29118020f0c97c5ec9fec9b64e6 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.c @@ -42,7 +42,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_sn_10_t *pduP, s16_t payload_sizeP) +void rlc_am_pdu_polling (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_am_pdu_sn_10_t *pdu_pP, s16_t payload_sizeP) //----------------------------------------------------------------------------- { // 5.2.2 Polling @@ -72,115 +72,182 @@ void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_sn_10_t // - start t-PollRetransmit; // - else: // - restart t-PollRetransmit; - rlcP->c_pdu_without_poll += 1; - rlcP->c_byte_without_poll += payload_sizeP; + rlc_pP->c_pdu_without_poll += 1; + rlc_pP->c_byte_without_poll += payload_sizeP; if ( - (rlcP->c_pdu_without_poll >= rlcP->poll_pdu) || - (rlcP->c_byte_without_poll >= rlcP->poll_byte) || - ((rlcP->sdu_buffer_occupancy == 0) && (rlcP->retrans_num_bytes_to_retransmit == 0)) || - (rlcP->vt_s == rlcP->vt_ms) + (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) || + (rlc_pP->c_byte_without_poll >= rlc_pP->poll_byte) || + ((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) || + (rlc_pP->vt_s == rlc_pP->vt_ms) ) { - if (rlcP->c_pdu_without_poll >= rlcP->poll_pdu) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][POLL] SET POLL BECAUSE TX NUM PDU THRESHOLD %d HAS BEEN REACHED\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->poll_pdu); + if (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX NUM PDU THRESHOLD %d HAS BEEN REACHED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->poll_pdu); } - if (rlcP->c_pdu_without_poll >= rlcP->poll_pdu) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->poll_byte); + if (rlc_pP->c_pdu_without_poll >= rlc_pP->poll_pdu) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX NUM BYTES THRESHOLD %d HAS BEEN REACHED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->poll_byte); } - if ((rlcP->sdu_buffer_occupancy == 0) && (rlcP->retrans_num_bytes_to_retransmit == 0)) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][POLL] SET POLL BECAUSE TX BUFFERS ARE EMPTY\n", frame, rlcP->module_id, rlcP->rb_id); + if ((rlc_pP->sdu_buffer_occupancy == 0) && (rlc_pP->retrans_num_bytes_to_retransmit == 0)) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE TX BUFFERS ARE EMPTY\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } - if (rlcP->vt_s == rlcP->vt_ms) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][POLL] SET POLL BECAUSE OF WINDOW STALLING\n", frame, rlcP->module_id, rlcP->rb_id); + if (rlc_pP->vt_s == rlc_pP->vt_ms) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][POLL] SET POLL BECAUSE OF WINDOW STALLING\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } - pduP->b1 = pduP->b1 | 0x20; - rlcP->c_pdu_without_poll = 0; - rlcP->c_byte_without_poll = 0; + pdu_pP->b1 = pdu_pP->b1 | 0x20; + rlc_pP->c_pdu_without_poll = 0; + rlc_pP->c_byte_without_poll = 0; - rlcP->poll_sn = (rlcP->vt_s -1) & RLC_AM_SN_MASK; - //optimisation if (!rlcP->t_poll_retransmit.running) { - rlc_am_start_timer_poll_retransmit(rlcP,frame); + rlc_pP->poll_sn = (rlc_pP->vt_s -1) & RLC_AM_SN_MASK; + //optimisation if (!rlc_pP->t_poll_retransmit.running) { + rlc_am_start_timer_poll_retransmit(rlc_pP,frameP); //optimisation } else { - //optimisation rlcP->t_poll_retransmit.frame_time_out = frame + rlcP->t_poll_retransmit.time_out; + //optimisation rlc_pP->t_poll_retransmit.frame_time_out = frameP + rlc_pP->t_poll_retransmit.time_out; //optimisation } } else { - pduP->b1 = pduP->b1 & 0xDF; + pdu_pP->b1 = pdu_pP->b1 & 0xDF; } } //----------------------------------------------------------------------------- -void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_segment_10 (rlc_am_entity_t *rlc_pP,frame_t frameP) { //----------------------------------------------------------------------------- list_t pdus; - signed int pdu_remaining_size; - signed int test_pdu_remaining_size; - - int nb_bytes_to_transmit = rlcP->nb_bytes_requested_by_mac; - rlc_am_pdu_sn_10_t *pdu; - struct mac_tb_req *pdu_tb_req; - mem_block_t *pdu_mem; - unsigned char *data; - unsigned char *data_sdu; - rlc_am_e_li_t *e_li; - rlc_am_tx_sdu_management_t *sdu_mngt; - rlc_am_tx_data_pdu_management_t *pdu_mngt; - - unsigned int li_length_in_bytes; - unsigned int test_li_length_in_bytes; - unsigned int test_remaining_size_to_substract; - unsigned int test_remaining_num_li_to_substract; - unsigned int continue_fill_pdu_with_sdu; - unsigned int num_fill_sdu; - unsigned int test_num_li; - unsigned int fill_num_li; - unsigned int sdu_buffer_index; - unsigned int data_pdu_size; - - unsigned int fi_first_byte_pdu_is_first_byte_sdu; - unsigned int fi_last_byte_pdu_is_last_byte_sdu; - unsigned int fi; - unsigned int max_li_overhead; - - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] rlcP->current_sdu_index %d rlcP->next_sdu_index %d rlcP->input_sdus[rlcP->current_sdu_index].mem_block %p sdu_buffer_occupancy %d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->current_sdu_index, rlcP->next_sdu_index, rlcP->input_sdus[rlcP->current_sdu_index].mem_block, rlcP->sdu_buffer_occupancy); - if (rlcP->sdu_buffer_occupancy <= 0) { + signed int pdu_remaining_size = 0; + signed int test_pdu_remaining_size = 0; + + int nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac; + rlc_am_pdu_sn_10_t *pdu_p = NULL; + struct mac_tb_req *pdu_tb_req_p = NULL; + mem_block_t *pdu_mem_p = NULL; + unsigned char *data = NULL; + unsigned char *data_sdu_p = NULL; + rlc_am_e_li_t *e_li_p = NULL; + rlc_am_tx_sdu_management_t *sdu_mngt_p = NULL; + rlc_am_tx_data_pdu_management_t *pdu_mngt_p = NULL; + + unsigned int li_length_in_bytes = 0; + unsigned int test_li_length_in_bytes = 0; + unsigned int test_remaining_size_to_substract= 0; + unsigned int test_remaining_num_li_to_substract = 0; + unsigned int continue_fill_pdu_with_sdu = 0; + unsigned int num_fill_sdu = 0; + unsigned int test_num_li = 0; + unsigned int fill_num_li = 0; + unsigned int sdu_buffer_index = 0; + unsigned int data_pdu_size = 0; + + unsigned int fi_first_byte_pdu_is_first_byte_sdu = 0; + unsigned int fi_last_byte_pdu_is_last_byte_sdu = 0; + unsigned int fi = 0; + unsigned int max_li_overhead = 0; + + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] rlc_pP->current_sdu_index %d rlc_pP->next_sdu_index %d rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block %p sdu_buffer_occupancy %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->current_sdu_index, + rlc_pP->next_sdu_index, + rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block, + rlc_pP->sdu_buffer_occupancy); + if (rlc_pP->sdu_buffer_occupancy <= 0) { return; } - //msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT]\n", rlcP->module_id, rlcP->rb_id, frame); + //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT]\n", rlc_pP->module_id, rlc_pP->rb_id, frameP); list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem = NULL; - - - while ((rlcP->input_sdus[rlcP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] nb_bytes_to_transmit %d BO %d\n", frame, rlcP->module_id, rlcP->rb_id, nb_bytes_to_transmit, rlcP->sdu_buffer_occupancy); - // pdu management - if (!pdu_mem) { - if (rlcP->nb_sdu_no_segmented <= 1) { + pdu_mem_p = NULL; + + + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (nb_bytes_to_transmit > 0) ) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] nb_bytes_to_transmit %d BO %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bytes_to_transmit, + rlc_pP->sdu_buffer_occupancy); + // pdu_p management + if (!pdu_mem_p) { + if (rlc_pP->nb_sdu_no_segmented <= 1) { max_li_overhead = 0; } else { - max_li_overhead = (((rlcP->nb_sdu_no_segmented - 1) * 3) / 2) + ((rlcP->nb_sdu_no_segmented - 1) % 2); + max_li_overhead = (((rlc_pP->nb_sdu_no_segmented - 1) * 3) / 2) + ((rlc_pP->nb_sdu_no_segmented - 1) % 2); } - LOG_T(RLC, "FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] max_li_overhead %d\n", frame, rlcP->module_id, rlcP->rb_id, max_li_overhead); - if (nb_bytes_to_transmit >= (rlcP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead)) { - data_pdu_size = rlcP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", frame, rlcP->module_id, rlcP->rb_id, data_pdu_size); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] max_li_overhead %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + max_li_overhead); + if (nb_bytes_to_transmit >= (rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead)) { + data_pdu_size = rlc_pP->sdu_buffer_occupancy + RLC_AM_HEADER_MIN_SIZE + max_li_overhead; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); } else { data_pdu_size = nb_bytes_to_transmit; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", frame, rlcP->module_id, rlcP->rb_id, data_pdu_size); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); } - if (!(pdu_mem = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { - LOG_C(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", frame, rlcP->module_id, rlcP->rb_id); + if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { + LOG_C(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] ERROR COULD NOT GET NEW PDU, EXIT\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); return; } - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] get new PDU %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, data_pdu_size); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] get new PDU %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); pdu_remaining_size = data_pdu_size - RLC_AM_HEADER_MIN_SIZE; - pdu = (rlc_am_pdu_sn_10_t*) (&pdu_mem->data[sizeof(struct mac_tb_req)]); - pdu_tb_req = (struct mac_tb_req*) (pdu_mem->data); - pdu_mngt = &rlcP->pdu_retrans_buffer[rlcP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE]; - memset(pdu_mngt, 0, sizeof (rlc_am_tx_data_pdu_management_t)); + pdu_p = (rlc_am_pdu_sn_10_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); + pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); + pdu_mngt_p = &rlc_pP->pdu_retrans_buffer[rlc_pP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE]; + memset(pdu_mngt_p, 0, sizeof (rlc_am_tx_data_pdu_management_t)); - memset (pdu_mem->data, 0, sizeof (rlc_am_pdu_sn_10_t)+sizeof(struct mac_tb_req)); + memset (pdu_mem_p->data, 0, sizeof (rlc_am_pdu_sn_10_t)+sizeof(struct mac_tb_req)); li_length_in_bytes = 1; } //---------------------------------------- @@ -189,31 +256,31 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) continue_fill_pdu_with_sdu = 1; num_fill_sdu = 0; test_num_li = 0; - sdu_buffer_index = rlcP->current_sdu_index; + sdu_buffer_index = rlc_pP->current_sdu_index; test_pdu_remaining_size = pdu_remaining_size; test_li_length_in_bytes = 1; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - while ((rlcP->input_sdus[sdu_buffer_index].mem_block) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = &rlcP->input_sdus[sdu_buffer_index]; + while ((rlc_pP->input_sdus[sdu_buffer_index].mem_block) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = &rlc_pP->input_sdus[sdu_buffer_index]; - if (sdu_mngt->sdu_remaining_size > test_pdu_remaining_size) { + if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt->sdu_remaining_size == test_pdu_remaining_size) { + } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -221,8 +288,8 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { - if (pdu_mngt->nb_sdus >= (RLC_AM_MAX_SDU_IN_PDU-1)) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { + if (pdu_mngt_p->nb_sdus >= (RLC_AM_MAX_SDU_IN_PDU-1)) { continue_fill_pdu_with_sdu = 0; //num_fill_sdu += 1; test_pdu_remaining_size = 0; @@ -232,13 +299,21 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) } else { test_num_li += 1; num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); + test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; test_remaining_num_li_to_substract = 1; test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] sdu_mngt->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + test_pdu_remaining_size, + test_li_length_in_bytes ^ 3); // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -247,9 +322,9 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) test_remaining_num_li_to_substract = 0; pdu_remaining_size = pdu_remaining_size - 1; } - pdu_mngt->sdus_index[pdu_mngt->nb_sdus++] = sdu_buffer_index; - sdu_mngt->pdus_index[sdu_mngt->nb_pdus++] = rlcP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; - assert(sdu_mngt->nb_pdus < RLC_AM_MAX_SDU_FRAGMENTS); + pdu_mngt_p->sdus_index[pdu_mngt_p->nb_sdus++] = sdu_buffer_index; + sdu_mngt_p->pdus_index[sdu_mngt_p->nb_pdus++] = rlc_pP->vt_s % RLC_AM_PDU_RETRANSMISSION_BUFFER_SIZE; + assert(sdu_mngt_p->nb_pdus < RLC_AM_MAX_SDU_FRAGMENTS); sdu_buffer_index = (sdu_buffer_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; } if (test_remaining_num_li_to_substract > 0) { @@ -258,134 +333,212 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; } //---------------------------------------- - // Do the real filling of the pdu + // Do the real filling of the pdu_p //---------------------------------------- - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] data shift %d Bytes num_li %d\n", frame, rlcP->module_id, rlcP->rb_id, ((test_num_li*3) +1) >> 1, test_num_li); - data = ((unsigned char*)(&pdu->data[((test_num_li*3) +1) >> 1])); - pdu_mngt->payload = data; - e_li = (rlc_am_e_li_t*)(pdu->data); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + ((test_num_li*3) +1) >> 1, + test_num_li); + data = ((unsigned char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); + pdu_mngt_p->payload = data; + e_li_p = (rlc_am_e_li_t*)(pdu_p->data); continue_fill_pdu_with_sdu = 1; li_length_in_bytes = 1; fill_num_li = 0; fi_first_byte_pdu_is_first_byte_sdu = 0; fi_last_byte_pdu_is_last_byte_sdu = 0; - if (rlcP->input_sdus[rlcP->current_sdu_index].sdu_remaining_size == - rlcP->input_sdus[rlcP->current_sdu_index].sdu_size) { + if (rlc_pP->input_sdus[rlc_pP->current_sdu_index].sdu_remaining_size == + rlc_pP->input_sdus[rlc_pP->current_sdu_index].sdu_size) { fi_first_byte_pdu_is_first_byte_sdu = 1; } - while ((rlcP->input_sdus[rlcP->current_sdu_index].mem_block) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = &rlcP->input_sdus[rlcP->current_sdu_index]; - if (sdu_mngt->sdu_segmented_size == 0) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt, sdu_mngt->sdu_remaining_size); + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index].mem_block) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = &rlc_pP->input_sdus[rlc_pP->current_sdu_index]; + if (sdu_mngt_p->sdu_segmented_size == 0) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size); } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes LENGTH \n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_size); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes LENGTH \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size, + sdu_mngt_p->sdu_size); } - data_sdu = &sdu_mngt->first_byte[sdu_mngt->sdu_segmented_size]; - - if (sdu_mngt->sdu_remaining_size > pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] Filling all remaining PDU with %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, pdu_remaining_size); - //msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] pdu_mem %p pdu %p pdu->data %p data %p data_sdu %p pdu_remaining_size %d\n", rlcP->module_id, rlcP->rb_id, frame, pdu_mem, pdu, pdu->data, data, data_sdu,pdu_remaining_size); - - memcpy(data, data_sdu, pdu_remaining_size); - pdu_mngt->payload_size += pdu_remaining_size; - sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; - sdu_mngt->sdu_segmented_size = sdu_mngt->sdu_segmented_size + pdu_remaining_size; + data_sdu_p = &sdu_mngt_p->first_byte[sdu_mngt_p->sdu_segmented_size]; + + if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling all remaining PDU with %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); + //msg ("[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", rlc_pP->module_id, rlc_pP->rb_id, frameP, pdu_mem_p, pdu_p, pdu_p->data, data, data_sdu_p,pdu_remaining_size); + + memcpy(data, data_sdu_p, pdu_remaining_size); + pdu_mngt_p->payload_size += pdu_remaining_size; + sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; + sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; fi_last_byte_pdu_is_last_byte_sdu = 0; // no LI - rlcP->sdu_buffer_occupancy -= pdu_remaining_size; + rlc_pP->sdu_buffer_occupancy -= pdu_remaining_size; continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] sdu_remaining_size %d bytes sdu_segmented_size %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_segmented_size); - } else if (sdu_mngt->sdu_remaining_size == pdu_remaining_size) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", frame, rlcP->module_id, rlcP->rb_id, pdu_remaining_size); - memcpy(data, data_sdu, pdu_remaining_size); - pdu_mngt->payload_size += pdu_remaining_size; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] sdu_remaining_size %d bytes sdu_segmented_size %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + sdu_mngt_p->sdu_segmented_size); + } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); + memcpy(data, data_sdu_p, pdu_remaining_size); + pdu_mngt_p->payload_size += pdu_remaining_size; // free SDU - rlcP->sdu_buffer_occupancy -= sdu_mngt->sdu_remaining_size; - rlc_am_free_in_sdu_data(rlcP, rlcP->current_sdu_index); - //free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - //rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - //rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; + rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + rlc_am_free_in_sdu_data(rlc_pP, rlc_pP->current_sdu_index); + //free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + //rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + //rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; fi_last_byte_pdu_is_last_byte_sdu = 1; // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - } else if ((sdu_mngt->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { if (fill_num_li == (RLC_AM_MAX_SDU_IN_PDU - 1)) { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt->sdu_remaining_size); - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); - pdu_mngt->payload_size += sdu_mngt->sdu_remaining_size; - pdu_remaining_size = 0; //Forced to 0 pdu_remaining_size - sdu_mngt->sdu_remaining_size; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] [SIZE %d] REACHING RLC_AM_MAX_SDU_IN_PDU LIs -> STOP SEGMENTATION FOR THIS PDU SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size); + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); + pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; + pdu_remaining_size = 0; //Forced to 0 pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; // free SDU - rlcP->sdu_buffer_occupancy -= sdu_mngt->sdu_remaining_size; - rlc_am_free_in_sdu_data(rlcP, rlcP->current_sdu_index); - //rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - //rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; + rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + rlc_am_free_in_sdu_data(rlc_pP, rlc_pP->current_sdu_index); + //rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + //rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; fi_last_byte_pdu_is_last_byte_sdu = 1; } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] Filling PDU with %d all remaining bytes of SDU\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt->sdu_remaining_size); - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); - pdu_mngt->payload_size += sdu_mngt->sdu_remaining_size; - data = &data[sdu_mngt->sdu_remaining_size]; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling PDU with %d all remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size); + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); + pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; + data = &data[sdu_mngt_p->sdu_remaining_size]; li_length_in_bytes = li_length_in_bytes ^ 3; fill_num_li += 1; if (li_length_in_bytes == 2) { if (fill_num_li == test_num_li) { - //e_li->e1 = 0; - e_li->b1 = 0; + //e_li_p->e1 = 0; + e_li_p->b1 = 0; } else { - //e_li->e1 = 1; - e_li->b1 = 0x80; + //e_li_p->e1 = 1; + e_li_p->b1 = 0x80; } - //e_li->li1 = sdu_mngt->sdu_remaining_size; - e_li->b1 = e_li->b1 | (sdu_mngt->sdu_remaining_size >> 4); - e_li->b2 = sdu_mngt->sdu_remaining_size << 4; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] set e_li->b1=0x%02X set e_li->b2=0x%02X fill_num_li=%d test_num_li=%d\n", frame, rlcP->module_id, rlcP->rb_id, e_li->b1, e_li->b2, fill_num_li, test_num_li); + //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); + e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] set e_li_p->b1=0x%02X set e_li_p->b2=0x%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b1, + e_li_p->b2, + fill_num_li, + test_num_li); } else { if (fill_num_li != test_num_li) { - //e_li->e2 = 1; - e_li->b2 = e_li->b2 | 0x08; + //e_li_p->e2 = 1; + e_li_p->b2 = e_li_p->b2 | 0x08; } - //e_li->li2 = sdu_mngt->sdu_remaining_size; - e_li->b2 = e_li->b2 | (sdu_mngt->sdu_remaining_size >> 8); - e_li->b3 = sdu_mngt->sdu_remaining_size & 0xFF; - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] set e_li->b2=0x%02X set e_li->b3=0x%02X fill_num_li=%d test_num_li=%d\n", frame, rlcP->module_id, rlcP->rb_id, e_li->b2, e_li->b3, fill_num_li, test_num_li); - e_li++; + //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); + e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] set e_li_p->b2=0x%02X set e_li_p->b3=0x%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b2, + e_li_p->b3, + fill_num_li, + test_num_li); + e_li_p++; } - pdu_remaining_size = pdu_remaining_size - (sdu_mngt->sdu_remaining_size + li_length_in_bytes); + pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes); // free SDU - rlcP->sdu_buffer_occupancy -= sdu_mngt->sdu_remaining_size; - sdu_mngt->sdu_remaining_size = 0; - - rlc_am_free_in_sdu_data(rlcP, rlcP->current_sdu_index); - //free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - //rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - //rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; + rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + sdu_mngt_p->sdu_remaining_size = 0; + + rlc_am_free_in_sdu_data(rlc_pP, rlc_pP->current_sdu_index); + //free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + //rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + //rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; } } else { - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", frame, rlcP->module_id, rlcP->rb_id, sdu_mngt->sdu_remaining_size, pdu_remaining_size - sdu_mngt->sdu_remaining_size); + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); #ifdef USER_MODE assert(1!=1); #endif - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); - pdu_mngt->payload_size += sdu_mngt->sdu_remaining_size; - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size; + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); + pdu_mngt_p->payload_size += sdu_mngt_p->sdu_remaining_size; + pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; // free SDU - rlcP->sdu_buffer_occupancy -= sdu_mngt->sdu_remaining_size; - rlc_am_free_in_sdu_data(rlcP, rlcP->current_sdu_index); - //rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - //rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; + rlc_pP->sdu_buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + rlc_am_free_in_sdu_data(rlc_pP, rlc_pP->current_sdu_index); + //rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + //rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % RLC_AM_SDU_CONTROL_BUFFER_SIZE; // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; @@ -402,52 +555,54 @@ void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame) if (!fi_last_byte_pdu_is_last_byte_sdu) { fi = fi + 1; } - pdu->b1 = pdu->b1 | (fi << 3); + pdu_p->b1 = pdu_p->b1 | (fi << 3); // set fist e bit if (fill_num_li > 0) { - pdu->b1 = pdu->b1 | 0x04; + pdu_p->b1 = pdu_p->b1 | 0x04; } - LOG_T(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEGMENT] SEND PDU SN %04d SIZE %d BYTES PAYLOAD SIZE %d BYTES\n", - frame, - rlcP->module_id, - rlcP->rb_id, - rlcP->vt_s, + LOG_T(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][SEGMENT] SEND PDU SN %04d SIZE %d BYTES PAYLOAD SIZE %d BYTES\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vt_s, data_pdu_size - pdu_remaining_size, - pdu_mngt->payload_size); + pdu_mngt_p->payload_size); - rlcP->stat_tx_data_pdu += 1; - rlcP->stat_tx_data_bytes += (data_pdu_size - pdu_remaining_size); + rlc_pP->stat_tx_data_pdu += 1; + rlc_pP->stat_tx_data_bytes += (data_pdu_size - pdu_remaining_size); - //pdu->sn = rlcP->vt_s; - pdu->b1 = pdu->b1 | 0x80; // DATA/CONTROL field is DATA PDU - pdu->b1 = pdu->b1 | (rlcP->vt_s >> 8); - pdu->b2 = rlcP->vt_s & 0xFF; - rlcP->vt_s = (rlcP->vt_s+1) & RLC_AM_SN_MASK; + //pdu_p->sn = rlc_pP->vt_s; + pdu_p->b1 = pdu_p->b1 | 0x80; // DATA/CONTROL field is DATA PDU + pdu_p->b1 = pdu_p->b1 | (rlc_pP->vt_s >> 8); + pdu_p->b2 = rlc_pP->vt_s & 0xFF; + rlc_pP->vt_s = (rlc_pP->vt_s+1) & RLC_AM_SN_MASK; - pdu_tb_req->data_ptr = (unsigned char*)pdu; - pdu_tb_req->tb_size = data_pdu_size - pdu_remaining_size; + pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; + pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; - assert(pdu_tb_req->tb_size < 3000); - rlc_am_pdu_polling(rlcP, frame,pdu, pdu_mngt->payload_size); + assert(pdu_tb_req_p->tb_size < 3000); + rlc_am_pdu_polling(rlc_pP, frameP,pdu_p, pdu_mngt_p->payload_size); - //list_add_tail_eurecom (pdu_mem, &rlcP->segmentation_pdu_list); - pdu_mngt->mem_block = pdu_mem; - pdu_mngt->first_byte = (unsigned char*)pdu; - pdu_mngt->header_and_payload_size = data_pdu_size - pdu_remaining_size; - pdu_mngt->retx_count = -1; + //list_add_tail_eurecom (pdu_mem_p, &rlc_pP->segmentation_pdu_list); + pdu_mngt_p->mem_block = pdu_mem_p; + pdu_mngt_p->first_byte = (unsigned char*)pdu_p; + pdu_mngt_p->header_and_payload_size = data_pdu_size - pdu_remaining_size; + pdu_mngt_p->retx_count = -1; - rlcP->retrans_num_pdus += 1; - rlcP->retrans_num_bytes += pdu_mngt->header_and_payload_size; + rlc_pP->retrans_num_pdus += 1; + rlc_pP->retrans_num_bytes += pdu_mngt_p->header_and_payload_size; - pdu = NULL; - pdu_mem = NULL; + pdu_p = NULL; + pdu_mem_p = NULL; //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; nb_bytes_to_transmit = 0; // 1 PDU only - mem_block_t* copy = rlc_am_retransmit_get_copy (rlcP, frame,(rlcP->vt_s-1) & RLC_AM_SN_MASK); - list_add_tail_eurecom (copy, &rlcP->segmentation_pdu_list); + mem_block_t* copy = rlc_am_retransmit_get_copy (rlc_pP, frameP,(rlc_pP->vt_s-1) & RLC_AM_SN_MASK); + list_add_tail_eurecom (copy, &rlc_pP->segmentation_pdu_list); } } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h index 5ff2e76d2e8cc62ea50df9c9f95cb9acd9d5fda2..aa4fa45b36c1f7909c6d869d5321ad5c5df13e72 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segment.h @@ -58,20 +58,20 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # endif # endif -/*! \fn void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_sn_10_t *pduP, s16_t payload_sizeP) +/*! \fn void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, frame_t frameP, rlc_am_pdu_sn_10_t *pduP, s16_t payload_sizeP) * \brief Set or not the poll bit in the PDU header depending on RLC AM protocol variables. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in[ frame Frame index. * \param[in] pduP Pointer on the header of the PDU in order to be able to set the poll bit if necessary. * \param[in] payload_sizeP Size of the payload of the PDU. */ -protected_rlc_am_segment(void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, u32_t frame, rlc_am_pdu_sn_10_t *pduP, s16_t payload_sizeP);) +protected_rlc_am_segment(void rlc_am_pdu_polling (rlc_am_entity_t *rlcP, frame_t frameP, rlc_am_pdu_sn_10_t *pduP, s16_t payload_sizeP);) /*! \fn void rlc_am_segment_10 (rlc_am_entity_t *rlcP) * \brief Segment a PDU with 10 bits sequence number, based on segmentation information given by MAC (size to transmit). * \param[in] rlcP RLC AM protocol instance pointer. * \param[in[ frame Frame index. */ -protected_rlc_am_segment(void rlc_am_segment_10 (rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_segment(void rlc_am_segment_10 (rlc_am_entity_t *rlcP,frame_t frameP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c index 5a74d6b1416ea9ca0fc202ca39712f36d3ebfb79..33d8b25ded1f1f64c516e46ca13d105d85e659a9 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.c @@ -36,129 +36,178 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #define TRACE_RLC_AM_HOLE //----------------------------------------------------------------------------- -void rlc_am_clear_holes (rlc_am_entity_t *rlcP, u16_t snP) +void rlc_am_clear_holes (rlc_am_entity_t *rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - rlcP->pdu_retrans_buffer[snP].num_holes = 0; + rlc_pP->pdu_retrans_buffer[snP].num_holes = 0; } //----------------------------------------------------------------------------- -void rlc_am_shift_down_holes (rlc_am_entity_t *rlcP, u16_t snP, int indexP) +void rlc_am_shift_down_holes (rlc_am_entity_t *rlc_pP, rlc_sn_t snP, int indexP) //----------------------------------------------------------------------------- { int i; - for (i=indexP; i < rlcP->pdu_retrans_buffer[snP].num_holes - 1; i++) { - rlcP->pdu_retrans_buffer[snP].hole_so_start[i] = rlcP->pdu_retrans_buffer[snP].hole_so_start[i+1]; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlcP->pdu_retrans_buffer[snP].hole_so_stop[i+1]; + for (i=indexP; i < rlc_pP->pdu_retrans_buffer[snP].num_holes - 1; i++) { + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i+1]; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i+1]; } - rlcP->pdu_retrans_buffer[snP].num_holes = rlcP->pdu_retrans_buffer[snP].num_holes - 1; + rlc_pP->pdu_retrans_buffer[snP].num_holes = rlc_pP->pdu_retrans_buffer[snP].num_holes - 1; } //----------------------------------------------------------------------------- -void rlc_am_shift_up_holes (rlc_am_entity_t *rlcP, u16_t snP, int indexP) +void rlc_am_shift_up_holes (rlc_am_entity_t *rlc_pP, rlc_sn_t snP, int indexP) //----------------------------------------------------------------------------- { // shift include indexP int i; - for (i=rlcP->pdu_retrans_buffer[snP].num_holes; i > indexP; i--) { - rlcP->pdu_retrans_buffer[snP].hole_so_start[i] = rlcP->pdu_retrans_buffer[snP].hole_so_start[i-1]; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlcP->pdu_retrans_buffer[snP].hole_so_stop[i-1]; + for (i=rlc_pP->pdu_retrans_buffer[snP].num_holes; i > indexP; i--) { + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i-1]; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i-1]; } - rlcP->pdu_retrans_buffer[snP].num_holes = rlcP->pdu_retrans_buffer[snP].num_holes + 1; - assert(rlcP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + rlc_pP->pdu_retrans_buffer[snP].num_holes = rlc_pP->pdu_retrans_buffer[snP].num_holes + 1; + assert(rlc_pP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); } //----------------------------------------------------------------------------- -void rlc_am_remove_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP) +void rlc_am_remove_hole (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP, u16_t so_startP, u16_t so_stopP) //----------------------------------------------------------------------------- { int i; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] REMOVE HOLE SN %04d so_startP %05d so_stopP %05d rlcP->pdu_retrans_buffer[snP].nack_so_start %05d rlcP->pdu_retrans_buffer[snP].nack_so_stop %05d\n", - frame,rlcP->module_id, rlcP->rb_id, snP, so_startP, so_stopP, rlcP->pdu_retrans_buffer[snP].nack_so_start, rlcP->pdu_retrans_buffer[snP].nack_so_stop); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d so_startP %05d so_stopP %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_start %05d rlc_pP->pdu_retrans_buffer[snP].nack_so_stop %05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + so_startP, + so_stopP, + rlc_pP->pdu_retrans_buffer[snP].nack_so_start, + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop); #endif assert(so_startP <= so_stopP); - if (rlcP->pdu_retrans_buffer[snP].num_holes == 0) { - assert(so_startP == rlcP->pdu_retrans_buffer[snP].nack_so_start); - assert(so_stopP <= rlcP->pdu_retrans_buffer[snP].nack_so_stop); + if (rlc_pP->pdu_retrans_buffer[snP].num_holes == 0) { + assert(so_startP == rlc_pP->pdu_retrans_buffer[snP].nack_so_start); + assert(so_stopP <= rlc_pP->pdu_retrans_buffer[snP].nack_so_stop); #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] REMOVE HOLE SN %04d MODIFIED nack_so_start %05d->%05d\n", - frame,rlcP->module_id, rlcP->rb_id, snP, rlcP->pdu_retrans_buffer[snP].nack_so_start, so_stopP+1); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d MODIFIED nack_so_start %05d->%05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].nack_so_start, + so_stopP+1); #endif - rlcP->pdu_retrans_buffer[snP].nack_so_start = so_stopP+1; - if (rlcP->pdu_retrans_buffer[snP].nack_so_start >= rlcP->pdu_retrans_buffer[snP].nack_so_stop) { - rlcP->pdu_retrans_buffer[snP].nack_so_start = 0; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_stopP+1; + if (rlc_pP->pdu_retrans_buffer[snP].nack_so_start >= rlc_pP->pdu_retrans_buffer[snP].nack_so_stop) { + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = 0; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; } } else { // normally should be removed in increasing order... - for (i = 0; i < rlcP->pdu_retrans_buffer[snP].num_holes; i++) { - if (so_startP <= rlcP->pdu_retrans_buffer[snP].hole_so_start[i]) { - if (so_stopP >= rlcP->pdu_retrans_buffer[snP].hole_so_stop[i]) { - rlc_am_shift_down_holes(rlcP, snP, i); + for (i = 0; i < rlc_pP->pdu_retrans_buffer[snP].num_holes; i++) { + if (so_startP <= rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i]) { + if (so_stopP >= rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i]) { + rlc_am_shift_down_holes(rlc_pP, snP, i); i = i - 1; } else { - rlcP->pdu_retrans_buffer[snP].hole_so_start[i] = so_stopP; - if (rlcP->pdu_retrans_buffer[snP].num_holes == 0) { - rlcP->pdu_retrans_buffer[snP].nack_so_start = 0; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i] = so_stopP; + if (rlc_pP->pdu_retrans_buffer[snP].num_holes == 0) { + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = 0; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; } else { - rlcP->pdu_retrans_buffer[snP].nack_so_start = rlcP->pdu_retrans_buffer[snP].hole_so_start[0]; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = rlcP->pdu_retrans_buffer[snP].hole_so_stop[rlcP->pdu_retrans_buffer[snP].num_holes - 1]; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[0]; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[rlc_pP->pdu_retrans_buffer[snP].num_holes - 1]; } #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", frame,rlcP->module_id, rlcP->rb_id, snP, rlcP->pdu_retrans_buffer[snP].nack_so_start, rlcP->pdu_retrans_buffer[snP].nack_so_stop, rlcP->pdu_retrans_buffer[snP].num_holes); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].nack_so_start, + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop, + rlc_pP->pdu_retrans_buffer[snP].num_holes); #endif return; } - } else if (so_startP > rlcP->pdu_retrans_buffer[snP].hole_so_start[i]) { - if (so_startP <= rlcP->pdu_retrans_buffer[snP].hole_so_stop[i]) { - if (so_stopP < rlcP->pdu_retrans_buffer[snP].hole_so_stop[i]) { + } else if (so_startP > rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i]) { + if (so_startP <= rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i]) { + if (so_stopP < rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i]) { // BAD CASE: 1 HOLE IS SPLITTED IN 2 HOLES - rlc_am_shift_up_holes(rlcP, snP, i+1); - rlcP->pdu_retrans_buffer[snP].hole_so_start[i+1] = so_startP+1; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i+1] = rlcP->pdu_retrans_buffer[snP].hole_so_stop[i]; + rlc_am_shift_up_holes(rlc_pP, snP, i+1); + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i+1] = so_startP+1; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i+1] = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i]; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP - 1; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP - 1; } else { - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = so_startP; } } } } - if (rlcP->pdu_retrans_buffer[snP].num_holes == 0) { - rlcP->pdu_retrans_buffer[snP].nack_so_start = 0; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; + if (rlc_pP->pdu_retrans_buffer[snP].num_holes == 0) { + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = 0; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = 0x7FFF; } else { - rlcP->pdu_retrans_buffer[snP].nack_so_start = rlcP->pdu_retrans_buffer[snP].hole_so_start[0]; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = rlcP->pdu_retrans_buffer[snP].hole_so_stop[rlcP->pdu_retrans_buffer[snP].num_holes - 1]; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[0]; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[rlc_pP->pdu_retrans_buffer[snP].num_holes - 1]; } } #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", frame,rlcP->module_id, rlcP->rb_id, snP, rlcP->pdu_retrans_buffer[snP].nack_so_start, rlcP->pdu_retrans_buffer[snP].nack_so_stop, rlcP->pdu_retrans_buffer[snP].num_holes); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] REMOVE HOLE SN %04d NOW nack_so_start %05d nack_so_stop %05d num holes %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->pdu_retrans_buffer[snP].nack_so_start, + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop, + rlc_pP->pdu_retrans_buffer[snP].num_holes); #endif - assert(rlcP->pdu_retrans_buffer[snP].nack_so_start < rlcP->pdu_retrans_buffer[snP].payload_size); + assert(rlc_pP->pdu_retrans_buffer[snP].nack_so_start < rlc_pP->pdu_retrans_buffer[snP].payload_size); } //----------------------------------------------------------------------------- -void rlc_am_get_next_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, int* so_startP, int* so_stopP) +void rlc_am_get_next_hole (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP, int* so_startP, int* so_stopP) //----------------------------------------------------------------------------- { - if (rlcP->pdu_retrans_buffer[snP].num_holes == 0) { - *so_startP = rlcP->pdu_retrans_buffer[snP].nack_so_start; - *so_stopP = rlcP->pdu_retrans_buffer[snP].nack_so_stop; + if (rlc_pP->pdu_retrans_buffer[snP].num_holes == 0) { + *so_startP = rlc_pP->pdu_retrans_buffer[snP].nack_so_start; + *so_stopP = rlc_pP->pdu_retrans_buffer[snP].nack_so_stop; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == 0)\n", - frame,rlcP->module_id, rlcP->rb_id, snP, *so_startP, *so_stopP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == 0)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + *so_startP, + *so_stopP); #endif } else { - *so_startP = rlcP->pdu_retrans_buffer[snP].hole_so_start[0]; - *so_stopP = rlcP->pdu_retrans_buffer[snP].hole_so_stop[0]; + *so_startP = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[0]; + *so_stopP = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[0]; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == %d)\n", - frame,rlcP->module_id, rlcP->rb_id, snP, *so_startP, *so_stopP, rlcP->pdu_retrans_buffer[snP].num_holes); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] rlc_am_get_next_hole(SN %04d) %05d->%05d (NUM HOLES == %d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + *so_startP, + *so_stopP, + rlc_pP->pdu_retrans_buffer[snP].num_holes); #endif } } //----------------------------------------------------------------------------- -void rlc_am_add_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP) +void rlc_am_add_hole (rlc_am_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP, sdu_size_t so_startP, sdu_size_t so_stopP) //----------------------------------------------------------------------------- { int i, hole_index; @@ -169,83 +218,112 @@ void rlc_am_add_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_st // if global NACK - if ((so_startP == 0) && ((so_stopP == 0x7FFF) || (so_stopP == rlcP->pdu_retrans_buffer[snP].payload_size - 1))) { - rlcP->pdu_retrans_buffer[snP].num_holes = 0; - rlcP->pdu_retrans_buffer[snP].nack_so_start = so_startP; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; + if ((so_startP == 0) && ((so_stopP == 0x7FFF) || (so_stopP == rlc_pP->pdu_retrans_buffer[snP].payload_size - 1))) { + rlc_pP->pdu_retrans_buffer[snP].num_holes = 0; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_startP; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] SN %04d GLOBAL NACK 0->%05d\n", - frame,rlcP->module_id, rlcP->rb_id, snP, so_stopP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] SN %04d GLOBAL NACK 0->%05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + so_stopP); #endif - assert(rlcP->pdu_retrans_buffer[snP].nack_so_start < rlcP->pdu_retrans_buffer[snP].payload_size); + assert(rlc_pP->pdu_retrans_buffer[snP].nack_so_start < rlc_pP->pdu_retrans_buffer[snP].payload_size); return; } if (so_stopP == 0x7FFF) { - so_stopP = rlcP->pdu_retrans_buffer[snP].payload_size - 1; + so_stopP = rlc_pP->pdu_retrans_buffer[snP].payload_size - 1; } // first hole - if (rlcP->pdu_retrans_buffer[snP].num_holes == 0) { - rlcP->pdu_retrans_buffer[snP].hole_so_start[0] = so_startP; - rlcP->pdu_retrans_buffer[snP].hole_so_stop [0] = so_stopP; + if (rlc_pP->pdu_retrans_buffer[snP].num_holes == 0) { + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[0] = so_startP; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop [0] = so_stopP; - rlcP->pdu_retrans_buffer[snP].num_holes = 1; + rlc_pP->pdu_retrans_buffer[snP].num_holes = 1; - rlcP->pdu_retrans_buffer[snP].nack_so_start = so_startP; - rlcP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_startP; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] FIRST HOLE SN %04d GLOBAL NACK %05d->%05d\n", - frame,rlcP->module_id, rlcP->rb_id, snP, so_startP, so_stopP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] FIRST HOLE SN %04d GLOBAL NACK %05d->%05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + so_startP, + so_stopP); #endif - assert(rlcP->pdu_retrans_buffer[snP].nack_so_start < rlcP->pdu_retrans_buffer[snP].payload_size); + assert(rlc_pP->pdu_retrans_buffer[snP].nack_so_start < rlc_pP->pdu_retrans_buffer[snP].payload_size); return; } hole_index = 0; - while (hole_index < rlcP->pdu_retrans_buffer[snP].num_holes) { - if (so_stopP < rlcP->pdu_retrans_buffer[snP].hole_so_start[hole_index]) { - assert(rlcP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + while (hole_index < rlc_pP->pdu_retrans_buffer[snP].num_holes) { + if (so_stopP < rlc_pP->pdu_retrans_buffer[snP].hole_so_start[hole_index]) { + assert(rlc_pP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); if (hole_index > 0) { - assert(so_startP > rlcP->pdu_retrans_buffer[snP].hole_so_stop[hole_index-1]); + assert(so_startP > rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[hole_index-1]); } - for (i=rlcP->pdu_retrans_buffer[snP].num_holes; i >= hole_index; i--) { - rlcP->pdu_retrans_buffer[snP].hole_so_start[i] = rlcP->pdu_retrans_buffer[snP].hole_so_start[i-1]; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlcP->pdu_retrans_buffer[snP].hole_so_stop[i-1]; + for (i=rlc_pP->pdu_retrans_buffer[snP].num_holes; i >= hole_index; i--) { + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_start[i-1]; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i] = rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[i-1]; } - rlcP->pdu_retrans_buffer[snP].hole_so_start[hole_index] = so_startP; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[hole_index] = so_stopP; + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[hole_index] = so_startP; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[hole_index] = so_stopP; // update nack "window" vars nack_so_start, nack_so_stop if (hole_index == 0) { - rlcP->pdu_retrans_buffer[snP].nack_so_start = so_startP; + rlc_pP->pdu_retrans_buffer[snP].nack_so_start = so_startP; } - rlcP->pdu_retrans_buffer[snP].num_holes += 1; + rlc_pP->pdu_retrans_buffer[snP].num_holes += 1; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] INSERT %d th HOLE SN %04d GLOBAL NACK %05d->%05d\n", - frame,rlcP->module_id, rlcP->rb_id, rlcP->pdu_retrans_buffer[snP].num_holes, snP, so_startP, so_stopP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] INSERT %d th HOLE SN %04d GLOBAL NACK %05d->%05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->pdu_retrans_buffer[snP].num_holes, + snP, + so_startP, + so_stopP); #endif - assert(rlcP->pdu_retrans_buffer[snP].nack_so_start < rlcP->pdu_retrans_buffer[snP].payload_size); - assert(rlcP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + assert(rlc_pP->pdu_retrans_buffer[snP].nack_so_start < rlc_pP->pdu_retrans_buffer[snP].payload_size); + assert(rlc_pP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); return; } hole_index = hole_index + 1; } // if here insert to the "tail" - if (so_startP > rlcP->pdu_retrans_buffer[snP].hole_so_stop[hole_index - 1]) { - assert(rlcP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); - rlcP->pdu_retrans_buffer[snP].hole_so_start[hole_index] = so_startP; - rlcP->pdu_retrans_buffer[snP].hole_so_stop[hole_index] = so_stopP; - rlcP->pdu_retrans_buffer[snP].num_holes += 1; + if (so_startP > rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[hole_index - 1]) { + assert(rlc_pP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + rlc_pP->pdu_retrans_buffer[snP].hole_so_start[hole_index] = so_startP; + rlc_pP->pdu_retrans_buffer[snP].hole_so_stop[hole_index] = so_stopP; + rlc_pP->pdu_retrans_buffer[snP].num_holes += 1; // update nack "window" vars nack_so_start, nack_so_stop - rlcP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; + rlc_pP->pdu_retrans_buffer[snP].nack_so_stop = so_stopP; #ifdef TRACE_RLC_AM_HOLE - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][HOLE] INSERT THE %d th LAST HOLE SN %04d GLOBAL NACK %05d->%05d\n", - frame,rlcP->module_id, rlcP->rb_id, rlcP->pdu_retrans_buffer[snP].num_holes, snP, so_startP, so_stopP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][HOLE] INSERT THE %d th LAST HOLE SN %04d GLOBAL NACK %05d->%05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->pdu_retrans_buffer[snP].num_holes, + snP, + so_startP, + so_stopP); #endif } else { assert(1==2); } - assert(rlcP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); - assert(rlcP->pdu_retrans_buffer[snP].nack_so_start < rlcP->pdu_retrans_buffer[snP].payload_size); + assert(rlc_pP->pdu_retrans_buffer[snP].num_holes < RLC_AM_MAX_HOLES_REPORT_PER_PDU); + assert(rlc_pP->pdu_retrans_buffer[snP].nack_so_start < rlc_pP->pdu_retrans_buffer[snP].payload_size); } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h index 04c69da98f4c2f7ff7df433dfb9d5f9f1e9e7e89..5d7c65ea01205addbba6665e0b06bbc6e4eb828a 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_segments_holes.h @@ -58,14 +58,14 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_am_segments_holes(x) extern x # endif # endif -/*! \fn void rlc_am_clear_holes (rlc_am_entity_t *rlcP, u16_t snP) +/*! \fn void rlc_am_clear_holes (rlc_am_entity_t *rlcP, rlc_sn_t snP) * \brief Remove all marked holes for PDU with sequence number "snP". * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] snP Sequence number. */ -protected_rlc_am_segments_holes(void rlc_am_clear_holes (rlc_am_entity_t *rlcP, u16_t snP);) +protected_rlc_am_segments_holes(void rlc_am_clear_holes (rlc_am_entity_t *rlcP, rlc_sn_t snP);) -/*! \fn void rlc_am_remove_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP) +/*! \fn void rlc_am_remove_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, u16_t so_startP, u16_t so_stopP) * \brief Remove for PDU with sequence number "snP" a NACK for byte segment offset [so_startP, so_stopP]. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in[ frame Frame index. @@ -73,9 +73,9 @@ protected_rlc_am_segments_holes(void rlc_am_clear_holes (rlc_am_entity_t *rlcP, * \param[in] so_startP Start of segment offset. * \param[in] so_stopP End of segment offset. */ -protected_rlc_am_segments_holes(void rlc_am_remove_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP);) +protected_rlc_am_segments_holes(void rlc_am_remove_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, u16_t so_startP, u16_t so_stopP);) -/*! \fn void rlc_am_get_next_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, int* so_startP, int* so_stopP) +/*! \fn void rlc_am_get_next_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, int* so_startP, int* so_stopP) * \brief Get for PDU with sequence number "snP" the first hole start and stop parameters. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in[ frame Frame index. @@ -83,9 +83,9 @@ protected_rlc_am_segments_holes(void rlc_am_remove_hole (rlc_am_entity_t *rlcP, * \param[in,out] so_startP Start of segment offset. * \param[in,out] so_stopP End of segment offset. */ -protected_rlc_am_segments_holes(void rlc_am_get_next_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, int* so_startP, int* so_stopP);) +protected_rlc_am_segments_holes(void rlc_am_get_next_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, int* so_startP, int* so_stopP);) -/*! \fn void rlc_am_add_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP) +/*! \fn void rlc_am_add_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, u16_t so_startP, u16_t so_stopP) * \brief Mark for PDU with sequence number "snP" a NACK for byte segment offset [so_startP, so_stopP]. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in[ frame Frame index. @@ -93,6 +93,6 @@ protected_rlc_am_segments_holes(void rlc_am_get_next_hole (rlc_am_entity_t *rlcP * \param[in,out] so_startP Start of segment offset. * \param[in,out] so_stopP End of segment offset. */ -protected_rlc_am_segments_holes(void rlc_am_add_hole (rlc_am_entity_t *rlcP, u32_t frame, u16_t snP, u16_t so_startP, u16_t so_stopP);) +protected_rlc_am_segments_holes(void rlc_am_add_hole (rlc_am_entity_t *rlcP, frame_t frameP, rlc_sn_t snP, u16_t so_startP, u16_t so_stopP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c index 1f1123e22c8e3bedce7d1cb50ad33632f1392c5f..aea56f08482a18457e4580a6b733bca1f79d6774 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.c @@ -42,124 +42,124 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis rlc_am_control_pdu_info_t g_rlc_am_control_pdu_info; //----------------------------------------------------------------------------- -u16_t rlc_am_read_bit_field(u8_t** dataP, unsigned int* bit_posP, signed int bits_to_readP) { +u16_t rlc_am_read_bit_field(u8_t** data_ppP, unsigned int* bit_pos_pP, signed int bits_to_readP) { //----------------------------------------------------------------------------- - u16_t value = 0; - unsigned int bits_read; + u16_t value = 0; + unsigned int bits_read = 0; do { // bits read > bits to read - if ((8 - *bit_posP) > bits_to_readP) { - bits_read = 8 - *bit_posP; - value = (value << bits_to_readP) | ((((u16_t)(**dataP)) & (u16_t)(0x00FF >> *bit_posP)) >> (bits_read - + if ((8 - *bit_pos_pP) > bits_to_readP) { + bits_read = 8 - *bit_pos_pP; + value = (value << bits_to_readP) | ((((u16_t)(**data_ppP)) & (u16_t)(0x00FF >> *bit_pos_pP)) >> (bits_read - bits_to_readP)); - *bit_posP = *bit_posP + bits_to_readP; + *bit_pos_pP = *bit_pos_pP + bits_to_readP; return value; // bits read == bits to read - } else if ((8 - *bit_posP) == bits_to_readP) { - value = (value << bits_to_readP) | (((u16_t)(**dataP)) & (u16_t)(0x00FF >> *bit_posP)); - *bit_posP = 0; - *dataP = *dataP + 1; + } else if ((8 - *bit_pos_pP) == bits_to_readP) { + value = (value << bits_to_readP) | (((u16_t)(**data_ppP)) & (u16_t)(0x00FF >> *bit_pos_pP)); + *bit_pos_pP = 0; + *data_ppP = *data_ppP + 1; return value; // bits read < bits to read } else { - bits_read = 8 - *bit_posP; - value = (value << bits_read) | ((((u16_t)(**dataP)) & (u16_t)(0x00FF >> *bit_posP))); - *bit_posP = 0; - *dataP = *dataP + 1; + bits_read = 8 - *bit_pos_pP; + value = (value << bits_read) | ((((u16_t)(**data_ppP)) & (u16_t)(0x00FF >> *bit_pos_pP))); + *bit_pos_pP = 0; + *data_ppP = *data_ppP + 1; bits_to_readP = bits_to_readP - bits_read; } } while (bits_to_readP > 0); return value; } //----------------------------------------------------------------------------- -void rlc_am_write8_bit_field(u8_t** dataP, unsigned int* bit_posP, signed int bits_to_writeP, u8_t valueP) { +void rlc_am_write8_bit_field(u8_t** data_ppP, unsigned int* bit_pos_pP, signed int bits_to_writeP, u8_t valueP) { //----------------------------------------------------------------------------- unsigned int available_bits; do { - available_bits = 8 - *bit_posP; + available_bits = 8 - *bit_pos_pP; // available_bits > bits to write if (available_bits > bits_to_writeP) { - **dataP = **dataP | (((valueP & (((u8_t)0xFF) >> (available_bits - bits_to_writeP)))) << (available_bits - + **data_ppP = **data_ppP | (((valueP & (((u8_t)0xFF) >> (available_bits - bits_to_writeP)))) << (available_bits - bits_to_writeP)); - *bit_posP = *bit_posP + bits_to_writeP; + *bit_pos_pP = *bit_pos_pP + bits_to_writeP; return; // bits read == bits to read } else if (available_bits == bits_to_writeP) { - **dataP = **dataP | (valueP & (((u8_t)0xFF) >> (8 - bits_to_writeP))); - *bit_posP = 0; - *dataP = *dataP + 1; + **data_ppP = **data_ppP | (valueP & (((u8_t)0xFF) >> (8 - bits_to_writeP))); + *bit_pos_pP = 0; + *data_ppP = *data_ppP + 1; return; // available_bits < bits to write } else { - **dataP = **dataP | (valueP >> (bits_to_writeP - available_bits)); - *bit_posP = 0; - *dataP = *dataP + 1; + **data_ppP = **data_ppP | (valueP >> (bits_to_writeP - available_bits)); + *bit_pos_pP = 0; + *data_ppP = *data_ppP + 1; bits_to_writeP = bits_to_writeP - available_bits; } } while (bits_to_writeP > 0); } //----------------------------------------------------------------------------- -void rlc_am_write16_bit_field(u8_t** dataP, unsigned int* bit_posP, signed int bits_to_writeP, u16_t valueP) { +void rlc_am_write16_bit_field(u8_t** data_ppP, unsigned int* bit_pos_pP, signed int bits_to_writeP, u16_t valueP) { //----------------------------------------------------------------------------- assert(bits_to_writeP <= 16); if (bits_to_writeP > 8) { - rlc_am_write8_bit_field(dataP,bit_posP, bits_to_writeP - 8, (u8_t)(valueP >> 8)); - rlc_am_write8_bit_field(dataP,bit_posP, 8, (u8_t)(valueP & 0x00FF)); + rlc_am_write8_bit_field(data_ppP,bit_pos_pP, bits_to_writeP - 8, (u8_t)(valueP >> 8)); + rlc_am_write8_bit_field(data_ppP,bit_pos_pP, 8, (u8_t)(valueP & 0x00FF)); } else { - rlc_am_write8_bit_field(dataP,bit_posP, bits_to_writeP, (u8_t)(valueP & 0x00FF)); + rlc_am_write8_bit_field(data_ppP,bit_pos_pP, bits_to_writeP, (u8_t)(valueP & 0x00FF)); } } //----------------------------------------------------------------------------- -signed int rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_t* headerP, s16_t *total_size_pP, rlc_am_control_pdu_info_t* pdu_infoP) +signed int rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_t* header_pP, sdu_ssize_t *total_size_pP, rlc_am_control_pdu_info_t* pdu_info_pP) //----------------------------------------------------------------------------- { - memset(pdu_infoP, 0, sizeof (rlc_am_control_pdu_info_t)); + memset(pdu_info_pP, 0, sizeof (rlc_am_control_pdu_info_t)); - pdu_infoP->d_c = headerP->b1 >> 7; + pdu_info_pP->d_c = header_pP->b1 >> 7; - if (!pdu_infoP->d_c) { - pdu_infoP->cpt = (headerP->b1 >> 4) & 0x07; - if (pdu_infoP->cpt != 0x00) return -3; - pdu_infoP->ack_sn = ((headerP->b2 >> 2) & 0x3F) | (((u16_t)(headerP->b1 & 0x0F)) << 6); - pdu_infoP->e1 = (headerP->b2 >> 1) & 0x01; + if (!pdu_info_pP->d_c) { + pdu_info_pP->cpt = (header_pP->b1 >> 4) & 0x07; + if (pdu_info_pP->cpt != 0x00) return -3; + pdu_info_pP->ack_sn = ((header_pP->b2 >> 2) & 0x3F) | (((u16_t)(header_pP->b1 & 0x0F)) << 6); + pdu_info_pP->e1 = (header_pP->b2 >> 1) & 0x01; //*total_size_pP -= 1; - if (pdu_infoP->e1) { + if (pdu_info_pP->e1) { unsigned int nack_to_read = 1; unsigned int bit_pos = 7; // range from 0 (MSB/left) to 7 (LSB/right) - u8_t* byte_pos = &headerP->b2; + u8_t* byte_pos_p = &header_pP->b2; while (nack_to_read) { - pdu_infoP->nack_list[pdu_infoP->num_nack].nack_sn = rlc_am_read_bit_field(&byte_pos, &bit_pos, 10); - pdu_infoP->nack_list[pdu_infoP->num_nack].e1 = rlc_am_read_bit_field(&byte_pos, &bit_pos, 1); - pdu_infoP->nack_list[pdu_infoP->num_nack].e2 = rlc_am_read_bit_field(&byte_pos, &bit_pos, 1); + pdu_info_pP->nack_list[pdu_info_pP->num_nack].nack_sn = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 10); + pdu_info_pP->nack_list[pdu_info_pP->num_nack].e1 = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 1); + pdu_info_pP->nack_list[pdu_info_pP->num_nack].e2 = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 1); // READ SOstart, SOend field - if (pdu_infoP->nack_list[pdu_infoP->num_nack].e2) { - pdu_infoP->nack_list[pdu_infoP->num_nack].so_start = rlc_am_read_bit_field(&byte_pos, &bit_pos, 15); - pdu_infoP->nack_list[pdu_infoP->num_nack].so_end = rlc_am_read_bit_field(&byte_pos, &bit_pos, 15); + if (pdu_info_pP->nack_list[pdu_info_pP->num_nack].e2) { + pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_start = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 15); + pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_end = rlc_am_read_bit_field(&byte_pos_p, &bit_pos, 15); } else { - pdu_infoP->nack_list[pdu_infoP->num_nack].so_start = 0; + pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_start = 0; // all 15 bits set to 1 (indicate that the missing portion of the AMD PDU includes all bytes // to the last byte of the AMD PDU) - pdu_infoP->nack_list[pdu_infoP->num_nack].so_end = 0x7FFF; + pdu_info_pP->nack_list[pdu_info_pP->num_nack].so_end = 0x7FFF; } - pdu_infoP->num_nack = pdu_infoP->num_nack + 1; + pdu_info_pP->num_nack = pdu_info_pP->num_nack + 1; - if (!pdu_infoP->nack_list[pdu_infoP->num_nack - 1].e1) { + if (!pdu_info_pP->nack_list[pdu_info_pP->num_nack - 1].e1) { nack_to_read = 0; - *total_size_pP = *total_size_pP - (s16_t)((uint64_t)byte_pos + (uint64_t)((bit_pos + 7)/8) - (uint64_t)headerP); + *total_size_pP = *total_size_pP - (sdu_ssize_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); return 0; } - if (pdu_infoP->num_nack == RLC_AM_MAX_NACK_IN_STATUS_PDU) { - *total_size_pP = *total_size_pP - (s16_t)((uint64_t)byte_pos + (uint64_t)((bit_pos + 7)/8) - (uint64_t)headerP); + if (pdu_info_pP->num_nack == RLC_AM_MAX_NACK_IN_STATUS_PDU) { + *total_size_pP = *total_size_pP - (sdu_ssize_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); return -2; } } - *total_size_pP = *total_size_pP - (s16_t)((uint64_t)byte_pos + (uint64_t)((bit_pos + 7)/8) - (uint64_t)headerP); + *total_size_pP = *total_size_pP - (sdu_ssize_t)((uint64_t)byte_pos_p + (uint64_t)((bit_pos + 7)/8) - (uint64_t)header_pP); } else { *total_size_pP = *total_size_pP - 2; } @@ -169,21 +169,21 @@ signed int rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_t* headerP, s16_t *tota } } //----------------------------------------------------------------------------- -void rlc_am_display_control_pdu_infos(rlc_am_control_pdu_info_t* pdu_infoP) +void rlc_am_display_control_pdu_infos(rlc_am_control_pdu_info_t* pdu_info_pP) //----------------------------------------------------------------------------- { int num_nack; - if (!pdu_infoP->d_c) { - LOG_T(RLC, "CONTROL PDU ACK SN %04d", pdu_infoP->ack_sn); + if (!pdu_info_pP->d_c) { + LOG_T(RLC, "CONTROL PDU ACK SN %04d", pdu_info_pP->ack_sn); - for (num_nack = 0; num_nack < pdu_infoP->num_nack; num_nack++) { - if (pdu_infoP->nack_list[num_nack].e2) { - LOG_T(RLC, "\n\tNACK SN %04d SO START %05d SO END %05d", pdu_infoP->nack_list[num_nack].nack_sn, - pdu_infoP->nack_list[num_nack].so_start, - pdu_infoP->nack_list[num_nack].so_end); + for (num_nack = 0; num_nack < pdu_info_pP->num_nack; num_nack++) { + if (pdu_info_pP->nack_list[num_nack].e2) { + LOG_T(RLC, "\n\tNACK SN %04d SO START %05d SO END %05d", pdu_info_pP->nack_list[num_nack].nack_sn, + pdu_info_pP->nack_list[num_nack].so_start, + pdu_info_pP->nack_list[num_nack].so_end); } else { - LOG_T(RLC, "\n\tNACK SN %04d", pdu_infoP->nack_list[num_nack].nack_sn); + LOG_T(RLC, "\n\tNACK SN %04d", pdu_info_pP->nack_list[num_nack].nack_sn); } } LOG_T(RLC, "\n"); @@ -192,23 +192,30 @@ void rlc_am_display_control_pdu_infos(rlc_am_control_pdu_info_t* pdu_infoP) } } //----------------------------------------------------------------------------- -void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP, u8_t** first_byteP, s16_t *tb_size_in_bytes_pP) +void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP, mem_block_t* tb_pP, u8_t** first_byte_ppP, sdu_ssize_t *tb_size_in_bytes_pP) //----------------------------------------------------------------------------- { - //rlc_am_control_pdu_info_t* pdu_info = ((rlc_am_control_pdu_info_t*)(tbP->data)); - rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10 = (rlc_am_pdu_sn_10_t*)*first_byteP; - s16_t initial_pdu_size = *tb_size_in_bytes_pP; - - if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10, tb_size_in_bytes_pP, &g_rlc_am_control_pdu_info) >= 0) { - - rlc_am_tx_buffer_display(rlcP, frame, " TX BUFFER BEFORE PROCESS OF STATUS PDU"); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] RX CONTROL PDU VT(A) %04d VT(S) %04d POLL_SN %04d ACK_SN %04d\n", - frame, rlcP->module_id, rlcP->rb_id, rlcP->vt_a, rlcP->vt_s, rlcP->poll_sn, g_rlc_am_control_pdu_info.ack_sn); + rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10_p = (rlc_am_pdu_sn_10_t*)*first_byte_ppP; + sdu_ssize_t initial_pdu_size = *tb_size_in_bytes_pP; + + if (rlc_am_get_control_pdu_infos(rlc_am_pdu_sn_10_p, tb_size_in_bytes_pP, &g_rlc_am_control_pdu_info) >= 0) { + + rlc_am_tx_buffer_display(rlc_pP, frameP, " TX BUFFER BEFORE PROCESS OF STATUS PDU"); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RX CONTROL PDU VT(A) %04d VT(S) %04d POLL_SN %04d ACK_SN %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vt_a, + rlc_pP->vt_s, + rlc_pP->poll_sn, + g_rlc_am_control_pdu_info.ack_sn); rlc_am_display_control_pdu_infos(&g_rlc_am_control_pdu_info); - u16_t ack_sn = g_rlc_am_control_pdu_info.ack_sn; - u16_t sn_cursor = rlcP->vt_a; - u16_t nack_sn; + rlc_sn_t ack_sn = g_rlc_am_control_pdu_info.ack_sn; + rlc_sn_t sn_cursor = rlc_pP->vt_a; + rlc_sn_t nack_sn; unsigned int nack_index; // 5.2.1 Retransmission @@ -234,29 +241,29 @@ void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_ assert(ack_sn < RLC_AM_SN_MODULO); assert(g_rlc_am_control_pdu_info.num_nack < RLC_AM_MAX_NACK_IN_STATUS_PDU); - if (rlc_am_in_tx_window(rlcP, ack_sn) > 0) { - rlcP->num_nack_so = 0; - rlcP->num_nack_sn = 0; + if (rlc_am_in_tx_window(rlc_pP, ack_sn) > 0) { + rlc_pP->num_nack_so = 0; + rlc_pP->num_nack_sn = 0; if (g_rlc_am_control_pdu_info.num_nack == 0) { while (sn_cursor != ack_sn) { - if (sn_cursor == rlcP->poll_sn) { - rlc_am_stop_and_reset_timer_poll_retransmit(rlcP,frame); + if (sn_cursor == rlc_pP->poll_sn) { + rlc_am_stop_and_reset_timer_poll_retransmit(rlc_pP,frameP); } - rlc_am_ack_pdu(rlcP, frame, sn_cursor); + rlc_am_ack_pdu(rlc_pP, frameP, sn_cursor); sn_cursor = (sn_cursor + 1) & RLC_AM_SN_MASK; } } else { nack_index = 0; nack_sn = g_rlc_am_control_pdu_info.nack_list[nack_index].nack_sn; while (sn_cursor != ack_sn) { - if (sn_cursor == rlcP->poll_sn) { - rlc_am_stop_and_reset_timer_poll_retransmit(rlcP,frame); + if (sn_cursor == rlc_pP->poll_sn) { + rlc_am_stop_and_reset_timer_poll_retransmit(rlc_pP,frameP); } if (sn_cursor != nack_sn) { - rlc_am_ack_pdu(rlcP, frame, sn_cursor); + rlc_am_ack_pdu(rlc_pP, frameP, sn_cursor); } else { - rlc_am_nack_pdu (rlcP, frame, + rlc_am_nack_pdu (rlc_pP, frameP, sn_cursor, g_rlc_am_control_pdu_info.nack_list[nack_index].so_start, g_rlc_am_control_pdu_info.nack_list[nack_index].so_end); @@ -278,53 +285,63 @@ void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_ } } } else { - LOG_N(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] WARNING CONTROL PDU ACK SN OUT OF WINDOW\n", frame, rlcP->module_id, rlcP->rb_id); + LOG_N(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] WARNING CONTROL PDU ACK SN OUT OF WINDOW\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } } else { - LOG_W(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d] ERROR IN DECODING CONTROL PDU\n", frame, rlcP->module_id, rlcP->rb_id); + LOG_W(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] ERROR IN DECODING CONTROL PDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } - *first_byteP = (u8_t*)((uint64_t)*first_byteP + initial_pdu_size - *tb_size_in_bytes_pP); + *first_byte_ppP = (u8_t*)((uint64_t)*first_byte_ppP + initial_pdu_size - *tb_size_in_bytes_pP); - free_mem_block(tbP); - rlc_am_tx_buffer_display(rlcP, frame, NULL); + free_mem_block(tb_pP); + rlc_am_tx_buffer_display(rlc_pP, frameP, NULL); } //----------------------------------------------------------------------------- -int rlc_am_write_status_pdu(u32_t frame, rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* pdu_infoP) +int rlc_am_write_status_pdu(frame_t frameP, rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10_pP, rlc_am_control_pdu_info_t* pdu_info_pP) //----------------------------------------------------------------------------- { unsigned int bit_pos = 4; // range from 0 (MSB/left) to 7 (LSB/right) - u8_t* byte_pos = &rlc_am_pdu_sn_10P->b1; - unsigned int index; - unsigned int num_bytes; + u8_t* byte_pos_p = &rlc_am_pdu_sn_10_pP->b1; + unsigned int index = 0; + unsigned int num_bytes = 0; - rlc_am_write16_bit_field(&byte_pos, &bit_pos, 10, pdu_infoP->ack_sn); - if (pdu_infoP->num_nack > 0) { - rlc_am_write8_bit_field(&byte_pos, &bit_pos, 1, 1); + rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 10, pdu_info_pP->ack_sn); + if (pdu_info_pP->num_nack > 0) { + rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, 1); } else { - rlc_am_write8_bit_field(&byte_pos, &bit_pos, 1, 0); + rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, 0); } - for (index = 0; index < pdu_infoP->num_nack ; index++) { - rlc_am_write16_bit_field(&byte_pos, &bit_pos, 10, pdu_infoP->nack_list[index].nack_sn); - rlc_am_write8_bit_field(&byte_pos, &bit_pos, 1, pdu_infoP->nack_list[index].e1); - rlc_am_write8_bit_field(&byte_pos, &bit_pos, 1, pdu_infoP->nack_list[index].e2); + for (index = 0; index < pdu_info_pP->num_nack ; index++) { + rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 10, pdu_info_pP->nack_list[index].nack_sn); + rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, pdu_info_pP->nack_list[index].e1); + rlc_am_write8_bit_field(&byte_pos_p, &bit_pos, 1, pdu_info_pP->nack_list[index].e2); // if SO_START SO_END fields - if (pdu_infoP->nack_list[index].e2 > 0) { - rlc_am_write16_bit_field(&byte_pos, &bit_pos, 15, pdu_infoP->nack_list[index].so_start); - rlc_am_write16_bit_field(&byte_pos, &bit_pos, 15, pdu_infoP->nack_list[index].so_end); + if (pdu_info_pP->nack_list[index].e2 > 0) { + rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 15, pdu_info_pP->nack_list[index].so_start); + rlc_am_write16_bit_field(&byte_pos_p, &bit_pos, 15, pdu_info_pP->nack_list[index].so_end); } } - num_bytes = ((unsigned int)byte_pos) - ((unsigned int)(&rlc_am_pdu_sn_10P->b1)); + num_bytes = ((unsigned int)byte_pos_p) - ((unsigned int)(&rlc_am_pdu_sn_10_pP->b1)); if (bit_pos > 0) { num_bytes += 1; } #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD XX][RB XX] WROTE STATUS PDU %d BYTES\n", - frame, num_bytes); + LOG_D(RLC, "[FRAME %5u][RLC_AM][MOD XX][RB XX] WROTE STATUS PDU %d BYTES\n", + frameP, num_bytes); #endif return num_bytes; } //----------------------------------------------------------------------------- -void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) +void rlc_am_send_status_pdu(rlc_am_entity_t* rlc_pP, frame_t frameP) //----------------------------------------------------------------------------- { // When STATUS reporting has been triggered, the receiving side of an AM RLC entity shall: @@ -349,49 +366,70 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) // - set the ACK_SN to the SN of the next not received RLC Data PDU which is not indicated as missing in the // resulting STATUS PDU. - signed int nb_bits_to_transmit = rlcP->nb_bytes_requested_by_mac << 3; - rlc_am_control_pdu_info_t control_pdu_info; - rlc_am_pdu_info_t *pdu_info_cursor; - u16_t previous_sn_cursor = (rlcP->vr_r - 1) & RLC_AM_SN_MASK; - u16_t sn_cursor; - mem_block_t *cursor = rlcP->receiver_buffer.head; - int all_segments_received; - int waited_so = 0; - mem_block_t *tb; - int pdu_size; + signed int nb_bits_to_transmit = rlc_pP->nb_bytes_requested_by_mac << 3; + rlc_am_control_pdu_info_t control_pdu_info; + rlc_am_pdu_info_t *pdu_info_cursor_p = NULL; + rlc_sn_t previous_sn_cursor = (rlc_pP->vr_r - 1) & RLC_AM_SN_MASK; + rlc_sn_t sn_cursor = 0; + mem_block_t *cursor_p = rlc_pP->receiver_buffer.head; + int all_segments_received = 0; + int waited_so = 0; + mem_block_t *tb_p = NULL; + sdu_size_t pdu_size = 0; memset(&control_pdu_info, 0, sizeof(rlc_am_control_pdu_info_t)); // header size nb_bits_to_transmit = nb_bits_to_transmit - 15; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] nb_bits_to_transmit %d (15 already allocated for header)\n", - frame,rlcP->module_id, rlcP->rb_id, nb_bits_to_transmit); - rlc_am_rx_list_display(rlcP, " DISPLAY BEFORE CONSTRUCTION OF STATUS REPORT"); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] nb_bits_to_transmit %d (15 already allocated for header)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bits_to_transmit); + rlc_am_rx_list_display(rlc_pP, " DISPLAY BEFORE CONSTRUCTION OF STATUS REPORT"); #endif - if (cursor != NULL) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - sn_cursor = pdu_info_cursor->sn; + if (cursor_p != NULL) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + sn_cursor = pdu_info_cursor_p->sn; - while (rlc_am_in_rx_window(rlcP, sn_cursor) == 0) { - cursor = cursor->next; + while (rlc_am_in_rx_window(rlc_pP, sn_cursor) == 0) { + cursor_p = cursor_p->next; previous_sn_cursor = sn_cursor; - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - sn_cursor = pdu_info_cursor->sn; + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + sn_cursor = pdu_info_cursor_p->sn; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d FIND VR(R) <= SN sn_cursor %04d -> %04d\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, previous_sn_cursor, sn_cursor); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d FIND VR(R) <= SN sn_cursor %04d -> %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + previous_sn_cursor, + sn_cursor); #endif } // 12 bits = size of NACK_SN field + E1, E2 bits // 42 bits = size of NACK_SN field + SO_START, SO_END fields, E1, E2 bits - while ((cursor != NULL) && (nb_bits_to_transmit >= 12)){ - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received; - sn_cursor = pdu_info_cursor->sn; + while ((cursor_p != NULL) && (nb_bits_to_transmit >= 12)){ + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received; + sn_cursor = pdu_info_cursor_p->sn; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d LOOPING sn_cursor %04d previous sn_cursor %04d \n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor, previous_sn_cursor); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d LOOPING sn_cursor %04d previous sn_cursor %04d \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + sn_cursor, + previous_sn_cursor); #endif // ------------------------------------------------------------------------------- @@ -399,29 +437,50 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) // ------------------------------------------------------------------------------- if (sn_cursor == previous_sn_cursor) { do { - cursor = cursor->next; - if (cursor != NULL) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received; - sn_cursor = pdu_info_cursor->sn; + cursor_p = cursor_p->next; + if (cursor_p != NULL) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received; + sn_cursor = pdu_info_cursor_p->sn; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d NOW sn_cursor %04d \n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d NOW sn_cursor %04d \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + sn_cursor); #endif } else { if (all_segments_received) { control_pdu_info.ack_sn = (sn_cursor + 1) & RLC_AM_SN_MASK; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d \n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, control_pdu_info.ack_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + control_pdu_info.ack_sn); #endif } else { control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d (CASE PREVIOUS SN)\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, control_pdu_info.ack_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK SN %04d (CASE PREVIOUS SN)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + control_pdu_info.ack_sn); #endif } goto end_push_nack; } - } while ((cursor != NULL) && (sn_cursor == previous_sn_cursor)); + } while ((cursor_p != NULL) && (sn_cursor == previous_sn_cursor)); } // ------------------------------------------------------------------------------- // simple case, PDU(s) is/are missing @@ -437,14 +496,27 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 12; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d\n", - frame, rlcP->module_id, rlcP->rb_id, __LINE__, previous_sn_cursor); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + previous_sn_cursor); #endif } else { control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d NO MORE BITS FOR SENDING NACK %04d -> ABORT AND SET FINAL ACK %04d\n", - frame, rlcP->module_id, rlcP->rb_id, __LINE__, previous_sn_cursor, control_pdu_info.ack_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d NO MORE BITS FOR SENDING NACK %04d -> ABORT AND SET FINAL ACK %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + previous_sn_cursor, + control_pdu_info.ack_sn); #endif goto end_push_nack; } @@ -455,62 +527,99 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) if (all_segments_received == 0) { waited_so = 0; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] if (all_segments_received == 0) \n", frame, rlcP->module_id, rlcP->rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] if (all_segments_received == 0) \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #endif do { - if (pdu_info_cursor->so > waited_so) { + if (pdu_info_cursor_p->so > waited_so) { if (nb_bits_to_transmit >= 42) { control_pdu_info.nack_list[control_pdu_info.num_nack].nack_sn = sn_cursor; control_pdu_info.nack_list[control_pdu_info.num_nack].so_start = waited_so; - control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = pdu_info_cursor->so - 1; + control_pdu_info.nack_list[control_pdu_info.num_nack].so_end = pdu_info_cursor_p->so - 1; control_pdu_info.nack_list[control_pdu_info.num_nack].e1 = 1; control_pdu_info.nack_list[control_pdu_info.num_nack].e2 = 1; control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 42; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d (CASE SO %d > WAITED SO %d)\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor, waited_so, pdu_info_cursor->so - 1, pdu_info_cursor->so, waited_so); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d (CASE SO %d > WAITED SO %d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + sn_cursor, + waited_so, + pdu_info_cursor_p->so - 1, + pdu_info_cursor_p->so, + waited_so); #endif - if (pdu_info_cursor->lsf == 1) { // last segment flag + if (pdu_info_cursor_p->lsf == 1) { // last segment flag //waited_so = 0x7FF; waited_so = 0x7FFF; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d SN %04d SET WAITED SO 0x7FFF)\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO 0x7FFF)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, sn_cursor); #endif //break; } else { - waited_so = pdu_info_cursor->so + pdu_info_cursor->payload_size; + waited_so = pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @1\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor, waited_so); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + sn_cursor, + waited_so); #endif } } else { control_pdu_info.ack_sn = sn_cursor; goto end_push_nack; } - } else { //else { // pdu_info_cursor->so <= waited_so - waited_so = pdu_info_cursor->so + pdu_info_cursor->payload_size; - if (pdu_info_cursor->lsf == 1) { // last segment flag + } else { //else { // pdu_info_cursor_p->so <= waited_so + waited_so = pdu_info_cursor_p->so + pdu_info_cursor_p->payload_size; + if (pdu_info_cursor_p->lsf == 1) { // last segment flag //waited_so = 0x7FF; waited_so = 0x7FFF; } #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @2\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, sn_cursor, waited_so); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d SN %04d SET WAITED SO %d @2\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + sn_cursor, waited_so); #endif } - cursor = cursor->next; - if (cursor != NULL) { - pdu_info_cursor = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; - all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received; + cursor_p = cursor_p->next; + if (cursor_p != NULL) { + pdu_info_cursor_p = &((rlc_am_rx_pdu_management_t*)(cursor_p->data))->pdu_info; + all_segments_received = ((rlc_am_rx_pdu_management_t*)(cursor_p->data))->all_segments_received; previous_sn_cursor = sn_cursor; - sn_cursor = pdu_info_cursor->sn; + sn_cursor = pdu_info_cursor_p->sn; } else { // LG control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; control_pdu_info.ack_sn = previous_sn_cursor; goto end_push_nack; } - } while ((cursor != NULL) && (sn_cursor == previous_sn_cursor)); + } while ((cursor_p != NULL) && (sn_cursor == previous_sn_cursor)); // may be last segment of PDU not received //if ((sn_cursor != previous_sn_cursor) && (waited_so != 0x7FF)) { @@ -525,7 +634,16 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) control_pdu_info.num_nack += 1; nb_bits_to_transmit = nb_bits_to_transmit - 42; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", frame, rlcP->module_id, rlcP->rb_id, __LINE__, previous_sn_cursor, waited_so, 0x7FFF); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING NACK %04d SO START %05d SO END %05d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + previous_sn_cursor, + waited_so, + 0x7FFF); #endif } else { control_pdu_info.ack_sn = previous_sn_cursor; @@ -535,16 +653,22 @@ void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) waited_so = 0; } else { waited_so = 0; - cursor = cursor->next; + cursor_p = cursor_p->next; previous_sn_cursor = sn_cursor; } } control_pdu_info.ack_sn = (previous_sn_cursor + 1) & RLC_AM_SN_MASK; } else { - control_pdu_info.ack_sn = rlcP->vr_r; + control_pdu_info.ack_sn = rlc_pP->vr_r; #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d = VR(R)\n", - frame, rlcP->module_id, rlcP->rb_id, __LINE__, control_pdu_info.ack_sn); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d = VR(R)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + control_pdu_info.ack_sn); #endif } @@ -552,40 +676,61 @@ end_push_nack: if (control_pdu_info.num_nack > 0) { control_pdu_info.nack_list[control_pdu_info.num_nack - 1].e1 = 0; } - //msg ("[FRAME %05d][RLC_AM][MOD %02d][RB %02d] nb_bits_to_transmit %d\n", - // rlcP->module_id, rlcP->rb_id, frame,nb_bits_to_transmit); + //msg ("[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] nb_bits_to_transmit %d\n", + // rlc_pP->module_id, rlc_pP->rb_id, frameP,nb_bits_to_transmit); #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d NUM NACK %d\n", - frame, rlcP->module_id, rlcP->rb_id, __LINE__, control_pdu_info.ack_sn, control_pdu_info.num_nack); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d PREPARE SENDING ACK %04d NUM NACK %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + control_pdu_info.ack_sn, + control_pdu_info.num_nack); #endif // encode the control pdu - pdu_size = rlcP->nb_bytes_requested_by_mac - ((nb_bits_to_transmit - 7 )>> 3); + pdu_size = rlc_pP->nb_bytes_requested_by_mac - ((nb_bits_to_transmit - 7 )>> 3); #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] LINE %d forecast pdu_size %d\n", - frame, rlcP->module_id, rlcP->rb_id, __LINE__, pdu_size); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] LINE %d forecast pdu_size %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + __LINE__, + pdu_size); #endif - tb = get_free_mem_block(sizeof(struct mac_tb_req) + pdu_size); - memset(tb->data, 0, sizeof(struct mac_tb_req) + pdu_size); - //estimation only ((struct mac_tb_req*)(tb->data))->tb_size = pdu_size; - ((struct mac_tb_req*)(tb->data))->data_ptr = (u8_t*)&(tb->data[sizeof(struct mac_tb_req)]); + tb_p = get_free_mem_block(sizeof(struct mac_tb_req) + pdu_size); + memset(tb_p->data, 0, sizeof(struct mac_tb_req) + pdu_size); + //estimation only ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; + ((struct mac_tb_req*)(tb_p->data))->data_ptr = (u8_t*)&(tb_p->data[sizeof(struct mac_tb_req)]); // warning reuse of pdu_size - pdu_size = rlc_am_write_status_pdu(frame,(rlc_am_pdu_sn_10_t*)(((struct mac_tb_req*)(tb->data))->data_ptr), &control_pdu_info); - ((struct mac_tb_req*)(tb->data))->tb_size = pdu_size; - //assert((((struct mac_tb_req*)(tb->data))->tb_size) < 3000); + pdu_size = rlc_am_write_status_pdu(frameP,(rlc_am_pdu_sn_10_t*)(((struct mac_tb_req*)(tb_p->data))->data_ptr), &control_pdu_info); + ((struct mac_tb_req*)(tb_p->data))->tb_size = pdu_size; + //assert((((struct mac_tb_req*)(tb_p->data))->tb_size) < 3000); #ifdef TRACE_STATUS_CREATION - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][SEND-STATUS] SEND STATUS PDU SIZE %d, rlcP->nb_bytes_requested_by_mac %d, nb_bits_to_transmit>>3 %d\n", frame, rlcP->module_id, rlcP->rb_id, pdu_size, rlcP->nb_bytes_requested_by_mac, nb_bits_to_transmit >> 3); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][SEND-STATUS] SEND STATUS PDU SIZE %d, rlc_pP->nb_bytes_requested_by_mac %d, nb_bits_to_transmit>>3 %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_size, + rlc_pP->nb_bytes_requested_by_mac, + nb_bits_to_transmit >> 3); #endif - assert(pdu_size == (rlcP->nb_bytes_requested_by_mac - (nb_bits_to_transmit >> 3))); + assert(pdu_size == (rlc_pP->nb_bytes_requested_by_mac - (nb_bits_to_transmit >> 3))); // remaining bytes to transmit for RLC (retrans pdus and new data pdus) - rlcP->nb_bytes_requested_by_mac = rlcP->nb_bytes_requested_by_mac - pdu_size; + rlc_pP->nb_bytes_requested_by_mac = rlc_pP->nb_bytes_requested_by_mac - pdu_size; // put pdu in trans - list_add_head(tb, &rlcP->control_pdu_list); - rlcP->stat_tx_control_pdu += 1; - rlcP->stat_tx_control_bytes += pdu_size; + list_add_head(tb_p, &rlc_pP->control_pdu_list); + rlc_pP->stat_tx_control_pdu += 1; + rlc_pP->stat_tx_control_bytes += pdu_size; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h index 619c34822f9efafe6299ccb2d3104c6f3c00f3b7..93f0485096e3a4c9c3eea3ee2e781c7626455b78 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_status_report.h @@ -106,7 +106,7 @@ protected_rlc_am_status_report( signed int rlc_am_get_control_pdu_infos (rlc_am_ */ protected_rlc_am_status_report( void rlc_am_display_control_pdu_infos(rlc_am_control_pdu_info_t* pdu_infoP);) -/*! \fn void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP, u8_t* first_byte, u16_t tb_size_in_bytes) +/*! \fn void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* tbP, u8_t* first_byte, u16_t tb_size_in_bytes) * \brief Process the informations contained in the control PDU. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. @@ -114,22 +114,22 @@ protected_rlc_am_status_report( void rlc_am_display_control_pdu_infos(rlc_am_con * \param[in] first_byte Pointer on first byte of control PDU. * \param[in] tb_size_in_bytes Pointer on size of serialized control PDU in bytes. */ -protected_rlc_am_status_report( void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, u32_t frame, mem_block_t* tbP, u8_t** first_byte, s16_t *tb_size_in_bytes);) +protected_rlc_am_status_report( void rlc_am_receive_process_control_pdu(rlc_am_entity_t* rlcP, frame_t frameP, mem_block_t* tbP, u8_t** first_byte, s16_t *tb_size_in_bytes);) -/*! \fn int rlc_am_write_status_pdu(u32_t frame,rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* pdu_infoP) +/*! \fn int rlc_am_write_status_pdu(frame_t frameP,rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* pdu_infoP) * \brief Remove all marked holes for PDU with sequence number "snP". * \param[in] frame Frame index. * \param[in] rlc_am_pdu_sn_10P Pointer on the header of the RLC AM control PDU. * \param[in] pdu_infoP Struct containing PDU control informations elements. * \return The number of bytes that have been written. */ -protected_rlc_am_status_report(int rlc_am_write_status_pdu(u32_t frame, rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* pdu_infoP);) +protected_rlc_am_status_report(int rlc_am_write_status_pdu(frame_t frameP, rlc_am_pdu_sn_10_t* rlc_am_pdu_sn_10P, rlc_am_control_pdu_info_t* pdu_infoP);) -/*! \fn void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame) +/*! \fn void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, frame_t frameP) * \brief Send a status PDU based on the receiver buffer content. * \param[in] rlcP RLC AM protocol instance pointer. * \param[in] frame Frame index. */ -protected_rlc_am_status_report(void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, u32_t frame);) +protected_rlc_am_status_report(void rlc_am_send_status_pdu(rlc_am_entity_t* rlcP, frame_t frameP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h index 2126303cae508c19dae396629c18c9b6a5b0996e..8ff378f705a766656764b0213e2c707d3465d2da 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_structs.h @@ -73,18 +73,14 @@ typedef struct sdu_management_flags { typedef struct rlc_am_tx_sdu_management { mem_block_t *mem_block; /*!< \brief SDU embedded in a mem_block_t. */ u8_t *first_byte; /*!< \brief Pointer on SDU payload. */ - s32_t sdu_creation_time; /*!< \brief Time stamped with mac_xface->frame. */ - u32_t mui; /*!< \brief Message Unit Identifier, still here for historical reasons (no LTE-PDCP compliant now). */ - u16_t sdu_remaining_size; /*!< \brief Remaining size in bytes to be filled in a PDU. */ - u16_t sdu_segmented_size; /*!< \brief Bytes already segmented in a/several PDU(s). */ - u16_t sdu_size; /*!< \brief SDU size in bytes. */ + frame_t sdu_creation_time; /*!< \brief Time stamped with mac_xface->frame. */ + mui_t mui; /*!< \brief Message Unit Identifier, still here for historical reasons (no LTE-PDCP compliant now). */ + sdu_size_t sdu_remaining_size; /*!< \brief Remaining size in bytes to be filled in a PDU. */ + sdu_size_t sdu_segmented_size; /*!< \brief Bytes already segmented in a/several PDU(s). */ + sdu_size_t sdu_size; /*!< \brief SDU size in bytes. */ s16_t pdus_index[RLC_AM_MAX_SDU_FRAGMENTS]; /*!< \brief Array containing the sequence numbers of the PDU in which the SDU has been segmented. */ u8_t nb_pdus; /*!< \brief Number of referenced PDUs in pdus_index[] array. */ - //u8_t nb_pdus_internal_use; // count the number of pdus transmitted to lower layers (used in mux procedure) u8_t nb_pdus_ack; /*!< \brief Number of referenced PDUs in pdus_index[] array that have been acknowledged. (used for confirmation and MaxDat discard)*/ - //u8_t nb_pdus_time; // counter used for timer based discard - - //s8_t li_index_for_discard; // indicates the li index in the last pdu of the sdu, marking the end of the sdu sdu_management_flags_t flags; /*!< \brief bit-field flags related to SDU segmentation and transmission */ } rlc_am_tx_sdu_management_t; @@ -114,15 +110,15 @@ typedef struct rlc_am_tx_data_pdu_management { u8_t *first_byte; /*!< \brief Pointer on the PDU including header, LIs, data */ u8_t *payload; /*!< \brief Pointer on the PDU payload */ s16_t sdus_index[RLC_AM_MAX_SDU_IN_PDU]; /*!< \brief Index of SDU(s) having segments in this pdu (index in rlc_am_entity.input_sdus[]) */ - u32_t last_nack_time; /*!< \brief Last frame this PDU was negative acknowledged, for not nacking several times in the same frame */ - u16_t hole_so_start [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the start segment offsets for marking a hole (negative acknowledged area) in the PDU. */ - u16_t hole_so_stop [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the stop segment offsets for marking a hole (negative acknowledged area) in the PDU. */ + frame_t last_nack_time; /*!< \brief Last frame this PDU was negative acknowledged, for not nacking several times in the same frame */ + sdu_size_t hole_so_start [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the start segment offsets for marking a hole (negative acknowledged area) in the PDU. */ + sdu_size_t hole_so_stop [RLC_AM_MAX_HOLES_REPORT_PER_PDU]; /*!< \brief Array containing the stop segment offsets for marking a hole (negative acknowledged area) in the PDU. */ u8_t num_holes; /*!< \brief Number of registereg holes in hole_so_start[], hole_so_stop[]. */ - s16_t header_and_payload_size; /*!< \brief Size of the PDU in bytes, including header and payload. */ - s16_t payload_size; /*!< \brief Size of the PDU payload in bytes. */ - s16_t sn; /*!< \brief Sequence number of the PDU. */ - s16_t nack_so_start; /*!< \brief Lowest NACK start segment offset, must be set to 0 if global NACK. */ - s16_t nack_so_stop; /*!< \brief Highest NACK stop segment offset, must be set to data_size if global NACK */ + sdu_ssize_t header_and_payload_size; /*!< \brief Size of the PDU in bytes, including header and payload. */ + sdu_ssize_t payload_size; /*!< \brief Size of the PDU payload in bytes. */ + rlc_sn_t sn; /*!< \brief Sequence number of the PDU. */ + sdu_ssize_t nack_so_start; /*!< \brief Lowest NACK start segment offset, must be set to 0 if global NACK. */ + sdu_ssize_t nack_so_stop; /*!< \brief Highest NACK stop segment offset, must be set to data_size if global NACK */ s8_t nb_sdus; /*!< \brief Number of sdu having segments in this pdu. */ s8_t retx_count; /*!< \brief Counts the number of retransmissions of an AMD PDU (see subclause 5.2.1). There is one RETX_COUNT counter per PDU that needs to be retransmitted. there is one VT(DAT) for each PDU and it is incremented each time the PDU is transmitted. */ @@ -137,12 +133,6 @@ typedef struct rlc_am_tx_data_pdu_management { * @{ */ -/*typedef struct rlc_am_tx_control_pdu_management { - mem_block_t *mem_block; //pointer on pdu queued in retransmission_buffer_to_send in order - u8_t *first_byte; // pointer on the pdu including header, LIs; - u16_t size; -} rlc_am_tx_control_pdu_management_t;*/ - /*! \struct nack_sn_t * \brief Structure containing Status PDU information element. */ @@ -227,12 +217,12 @@ typedef struct rlc_am_pdu_info { * \brief Generic structure for implementing a timer. */ typedef struct rlc_am_timer { - u32_t frame_time_out;/*!< \brief When set, indicate the frame number the timer will time-out. */ - u32_t frame_start; /*!< \brief indicate the frame number the timer has been started. */ - u32_t time_out; /*!< \brief Configured timer duration in frames. */ - u32_t running:1; /*!< \brief The timer is running. */ - u32_t timed_out:1; /*!< \brief The timer has timed-out. */ - u32_t dummy:30; /*!< \brief Bits not used. */ + frame_t frame_time_out;/*!< \brief When set, indicate the frame number the timer will time-out. */ + frame_t frame_start; /*!< \brief indicate the frame number the timer has been started. */ + frame_t time_out; /*!< \brief Configured timer duration in frames. */ + u32_t running:1; /*!< \brief The timer is running. */ + u32_t timed_out:1; /*!< \brief The timer has timed-out. */ + u32_t dummy:30; /*!< \brief Bits not used. */ } rlc_am_timer_t ; /** @} */ @@ -261,29 +251,16 @@ struct rlc_am_tx_data_pdu_allocation { struct rlc_am_tx_data_pdu_management rlc_am_tx_pdu_mngmnt; struct mac_tb_req tb_req; struct mac_tx_tb_management tb_mngt; -# ifdef BYPASS_L1 - struct rlc_am_rx_pdu_management dummy; - struct mac_tb_ind dummy2; - struct mac_rx_tb_management dummy3; - struct rlc_indication dummy4; -# endif } dummy; }; -struct rlc_am_tx_control_pdu_allocation { +/*struct rlc_am_tx_control_pdu_allocation { union { struct mac_tb_req tb_req; struct mac_tx_tb_management tb_mngt; - //struct rlc_am_tx_control_pdu_management rlc_am_tx_pdu_mngmnt; -# ifdef BYPASS_L1 - struct mac_tb_ind dummy2; - struct mac_rx_tb_management dummy3; - struct rlc_indication dummy4; -# endif } dummy; -}; +};*/ -// For test purpose struct rlc_am_data_req_alloc { // alloc enought bytes for sdu mngt also union { struct rlc_am_data_req dummy1; diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c index 8043517bdef67b97829a025dc1a7672cbdf083cb..40088576a096d1d4c9e20c85044f139ef966bee4 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.c @@ -37,7 +37,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { // 5.2.2.3 Expiry of t-PollRetransmit @@ -49,77 +49,85 @@ void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) // - consider any AMD PDU which has not been positively acknowledged for retransmission; // - include a poll in a RLC data PDU as described in section 5.2.2.1. - if (rlcP->t_poll_retransmit.running) { + if (rlc_pP->t_poll_retransmit.running) { if ( // CASE 1: start time out // +-----------+------------------+----------+ // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlcP->t_poll_retransmit.frame_start < rlcP->t_poll_retransmit.frame_time_out) && - ((frame >= rlcP->t_poll_retransmit.frame_time_out) || - (frame < rlcP->t_poll_retransmit.frame_start))) || + ((rlc_pP->t_poll_retransmit.frame_start < rlc_pP->t_poll_retransmit.frame_time_out) && + ((frameP >= rlc_pP->t_poll_retransmit.frame_time_out) || + (frameP < rlc_pP->t_poll_retransmit.frame_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlcP->t_poll_retransmit.frame_start > rlcP->t_poll_retransmit.frame_time_out) && - (frame < rlcP->t_poll_retransmit.frame_start) && (frame >= rlcP->t_poll_retransmit.frame_time_out)) + ((rlc_pP->t_poll_retransmit.frame_start > rlc_pP->t_poll_retransmit.frame_time_out) && + (frameP < rlc_pP->t_poll_retransmit.frame_start) && (frameP >= rlc_pP->t_poll_retransmit.frame_time_out)) ) { - //if (rlcP->t_poll_retransmit.frame_time_out <= frame) { - rlcP->t_poll_retransmit.running = 0; - rlcP->t_poll_retransmit.timed_out = 1; - rlcP->stat_timer_poll_retransmit_timed_out += 1; + //if (rlc_pP->t_poll_retransmit.frame_time_out <= frameP) { + rlc_pP->t_poll_retransmit.running = 0; + rlc_pP->t_poll_retransmit.timed_out = 1; + rlc_pP->stat_timer_poll_retransmit_timed_out += 1; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T_POLL_RETRANSMIT] TIME-OUT\n", frame, - rlcP->module_id, rlcP->rb_id); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_AM][MOD %02d][RB %02d][--- t-PollRetransmit Timed-out --->][RLC_AM][MOD %02d][RB %02d]\n", - frame, - rlcP->module_id, - rlcP->rb_id, - rlcP->module_id, - rlcP->rb_id); + LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] TIME-OUT\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #warning TO DO rlc_am_check_timer_poll_retransmit - rlcP->t_poll_retransmit.frame_time_out = frame + rlcP->t_poll_retransmit.time_out; + rlc_pP->t_poll_retransmit.frame_time_out = frameP + rlc_pP->t_poll_retransmit.time_out; } } } //----------------------------------------------------------------------------- -int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlcP) +int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlc_pP) //----------------------------------------------------------------------------- { - return rlcP->t_poll_retransmit.timed_out; + return rlc_pP->t_poll_retransmit.timed_out; } //----------------------------------------------------------------------------- -void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T_POLL_RETRANSMIT] STOPPED AND RESET\n", frame, - rlcP->module_id, rlcP->rb_id); - rlcP->t_poll_retransmit.running = 0; - rlcP->t_poll_retransmit.frame_time_out = 0; - rlcP->t_poll_retransmit.frame_start = 0; - rlcP->t_poll_retransmit.timed_out = 0; + LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] STOPPED AND RESET\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->t_poll_retransmit.running = 0; + rlc_pP->t_poll_retransmit.frame_time_out = 0; + rlc_pP->t_poll_retransmit.frame_start = 0; + rlc_pP->t_poll_retransmit.timed_out = 0; } //----------------------------------------------------------------------------- -void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - rlcP->t_poll_retransmit.running = 1; - rlcP->t_poll_retransmit.frame_time_out = frame + rlcP->t_poll_retransmit.time_out; - rlcP->t_poll_retransmit.frame_start = frame; - rlcP->t_poll_retransmit.timed_out = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T_POLL_RETRANSMIT] STARTED (TIME-OUT = FRAME %05d)\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->t_poll_retransmit.frame_time_out); + rlc_pP->t_poll_retransmit.running = 1; + rlc_pP->t_poll_retransmit.frame_time_out = frameP + rlc_pP->t_poll_retransmit.time_out; + rlc_pP->t_poll_retransmit.frame_start = frameP; + rlc_pP->t_poll_retransmit.timed_out = 0; + LOG_D(RLC, "[FRAME %05d][%s][RLC_AM][MOD %u/%u][RB %u][T_POLL_RETRANSMIT] STARTED (TIME-OUT = FRAME %05d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_poll_retransmit.frame_time_out); } //----------------------------------------------------------------------------- -void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlcP, u32_t time_outP) +void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlc_pP, u32_t time_outP) //----------------------------------------------------------------------------- { - rlcP->t_poll_retransmit.running = 0; - rlcP->t_poll_retransmit.frame_time_out = 0; - rlcP->t_poll_retransmit.frame_start = 0; - rlcP->t_poll_retransmit.time_out = time_outP; - rlcP->t_poll_retransmit.timed_out = 0; + rlc_pP->t_poll_retransmit.running = 0; + rlc_pP->t_poll_retransmit.frame_time_out = 0; + rlc_pP->t_poll_retransmit.frame_start = 0; + rlc_pP->t_poll_retransmit.time_out = time_outP; + rlc_pP->t_poll_retransmit.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h index d2f882427b1fb6219406e0ddf0380d5af4cffa76..840928bc4d2bb52b30bd548310cbc62655860828 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_poll_retransmit.h @@ -58,39 +58,39 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # endif # endif -/*! \fn void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Check if timer Poll-retransmit has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index */ -protected_rlc_am_timer_poll_retransmit(void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame)); +protected_rlc_am_timer_poll_retransmit(void rlc_am_check_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP)); -/*! \fn int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlcP) +/*! \fn int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlc_pP) * \brief Boolean function, check if timer Poll-retransmit has timed-out. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \return 1 if timer Poll-retransmit has timed-out, else 0. */ -protected_rlc_am_timer_poll_retransmit(int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlcP);) +protected_rlc_am_timer_poll_retransmit(int rlc_am_is_timer_poll_retransmit_timed_out(rlc_am_entity_t *rlc_pP);) -/*! \fn void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Stop and reset the timer Poll-retransmit. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index */ -protected_rlc_am_timer_poll_retransmit(void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_poll_retransmit(void rlc_am_stop_and_reset_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Re-arm (based on RLC AM config parameter) and start timer Poll-retransmit. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] frame Frame index */ -protected_rlc_am_timer_poll_retransmit(void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_poll_retransmit(void rlc_am_start_timer_poll_retransmit(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlcP, u32_t time_outP) +/*! \fn void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlc_pP, u32_t time_outP) * \brief Initialize the timer Poll-retransmit with RLC AM time-out config parameter. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] time_outP Time-out in frame units. */ -protected_rlc_am_timer_poll_retransmit(void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlcP, u32_t time_outP);) +protected_rlc_am_timer_poll_retransmit(void rlc_am_init_timer_poll_retransmit(rlc_am_entity_t *rlc_pP, u32_t time_outP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c index 23054447d7e9553d8dfd3c1744c63ed1422a91d4..0117326cf4080085289cda1a7bc9d79dcfd1e708 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.c @@ -37,31 +37,31 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -void rlc_am_check_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_check_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { return ; // for debug - if (rlcP->t_reordering.running) { + if (rlc_pP->t_reordering.running) { if ( // CASE 1: start time out // +-----------+------------------+----------+ // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlcP->t_reordering.frame_start < rlcP->t_reordering.frame_time_out) && - ((frame >= rlcP->t_reordering.frame_time_out) || - (frame < rlcP->t_reordering.frame_start))) || + ((rlc_pP->t_reordering.frame_start < rlc_pP->t_reordering.frame_time_out) && + ((frameP >= rlc_pP->t_reordering.frame_time_out) || + (frameP < rlc_pP->t_reordering.frame_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlcP->t_reordering.frame_start > rlcP->t_reordering.frame_time_out) && - (frame < rlcP->t_reordering.frame_start) && (frame >= rlcP->t_reordering.frame_time_out)) + ((rlc_pP->t_reordering.frame_start > rlc_pP->t_reordering.frame_time_out) && + (frameP < rlc_pP->t_reordering.frame_start) && (frameP >= rlc_pP->t_reordering.frame_time_out)) ) { - //if (rlcP->t_reordering.frame_time_out == frame) { + //if (rlc_pP->t_reordering.frame_time_out == frameP) { // 5.1.3.2.4 Actions when t-Reordering expires // When t-Reordering expires, the receiving side of an AM RLC entity shall: // - update VR(MS) to the SN of the first AMD PDU with SN >= VR(X) for which not all byte segments have been @@ -71,71 +71,92 @@ void rlc_am_check_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) // - set VR(X) to VR(H). - rlcP->t_reordering.running = 0; - rlcP->t_reordering.timed_out = 1; - rlcP->stat_timer_reordering_timed_out += 1; + rlc_pP->t_reordering.running = 0; + rlc_pP->t_reordering.timed_out = 1; + rlc_pP->stat_timer_reordering_timed_out += 1; rlc_am_pdu_info_t* pdu_info; mem_block_t* cursor; - cursor = rlcP->receiver_buffer.head; + cursor = rlc_pP->receiver_buffer.head; if (cursor) { do { pdu_info = &((rlc_am_rx_pdu_management_t*)(cursor->data))->pdu_info; // NOT VERY SURE ABOUT THAT, THINK ABOUT IT - rlcP->vr_ms = (pdu_info->sn + 1) & RLC_AM_SN_MASK; + rlc_pP->vr_ms = (pdu_info->sn + 1) & RLC_AM_SN_MASK; - if (rlc_am_sn_gte_vr_x(rlcP, pdu_info->sn)) { + if (rlc_am_sn_gte_vr_x(rlc_pP, pdu_info->sn)) { if (((rlc_am_rx_pdu_management_t*)(cursor->data))->all_segments_received == 0) { - rlcP->vr_ms = pdu_info->sn; + rlc_pP->vr_ms = pdu_info->sn; break; } } cursor = cursor->next; } while (cursor != NULL); - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] TIME-OUT UPDATED VR(MS) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_ms); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] TIME-OUT UPDATED VR(MS) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ms); } - if (rlc_am_sn_gt_vr_ms(rlcP, rlcP->vr_h)) { - rlcP->vr_x = rlcP->vr_h; - rlcP->t_reordering.frame_time_out = frame + rlcP->t_reordering.time_out; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] TIME-OUT, RESTARTED T-REORDERING, UPDATED VR(X) to VR(R) %04d\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->vr_x); + if (rlc_am_sn_gt_vr_ms(rlc_pP, rlc_pP->vr_h)) { + rlc_pP->vr_x = rlc_pP->vr_h; + rlc_pP->t_reordering.frame_time_out = frameP + rlc_pP->t_reordering.time_out; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] TIME-OUT, RESTARTED T-REORDERING, UPDATED VR(X) to VR(R) %04d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_x); } - rlcP->status_requested = 1; + rlc_pP->status_requested = 1; } } } //----------------------------------------------------------------------------- -void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] STOPPED AND RESET\n", frame, - rlcP->module_id, rlcP->rb_id); - rlcP->t_reordering.running = 0; - rlcP->t_reordering.frame_time_out = 0; - rlcP->t_reordering.frame_start = 0; - rlcP->t_reordering.timed_out = 0; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] STOPPED AND RESET\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->t_reordering.running = 0; + rlc_pP->t_reordering.frame_time_out = 0; + rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- -void rlc_am_start_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_start_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - rlcP->t_reordering.running = 1; - rlcP->t_reordering.frame_time_out = frame + rlcP->t_reordering.time_out; - rlcP->t_reordering.frame_start = frame; - rlcP->t_reordering.timed_out = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] STARTED (TIME-OUT = FRAME %05d)\n", - frame, rlcP->module_id, rlcP->rb_id, rlcP->t_reordering.frame_time_out); + rlc_pP->t_reordering.running = 1; + rlc_pP->t_reordering.frame_time_out = frameP + rlc_pP->t_reordering.time_out; + rlc_pP->t_reordering.frame_start = frameP; + rlc_pP->t_reordering.timed_out = 0; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-REORDERING] STARTED (TIME-OUT = FRAME %5u)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_reordering.frame_time_out); } //----------------------------------------------------------------------------- -void rlc_am_init_timer_reordering(rlc_am_entity_t *rlcP, u32_t time_outP) +void rlc_am_init_timer_reordering(rlc_am_entity_t *rlc_pP, u32_t time_outP) //----------------------------------------------------------------------------- { - rlcP->t_reordering.running = 0; - rlcP->t_reordering.frame_time_out = 0; - rlcP->t_reordering.frame_start = 0; - rlcP->t_reordering.time_out = time_outP; - rlcP->t_reordering.timed_out = 0; + rlc_pP->t_reordering.running = 0; + rlc_pP->t_reordering.frame_time_out = 0; + rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.time_out = time_outP; + rlc_pP->t_reordering.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h index d53070914c8d86787f88d786e1d87e69762b165c..622fdf02619396c57aaee2838a9960797b9a8c69 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_reordering.h @@ -57,32 +57,32 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # endif # endif -/*! \fn void rlc_am_check_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_check_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Check if timer reordering has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index */ -protected_rlc_am_timer_reordering(void rlc_am_check_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame)); +protected_rlc_am_timer_reordering(void rlc_am_check_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP)); -/*! \fn void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Stop and reset the timer reordering. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index. */ -protected_rlc_am_timer_reordering(void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_reordering(void rlc_am_stop_and_reset_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_start_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_start_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Re-arm (based on RLC AM config parameter) and start timer reordering. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index. */ -protected_rlc_am_timer_reordering(void rlc_am_start_timer_reordering(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_reordering(void rlc_am_start_timer_reordering(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_init_timer_reordering(rlc_am_entity_t *rlcP, u32_t time_outP) +/*! \fn void rlc_am_init_timer_reordering(rlc_am_entity_t *rlc_pP, u32_t time_outP) * \brief Initialize the timer reordering with RLC AM time-out config parameter. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] time_outP Time-out in frame units. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] time_outP Time-out in frameP units. */ -protected_rlc_am_timer_reordering(void rlc_am_init_timer_reordering(rlc_am_entity_t *rlcP, u32_t time_outP);) +protected_rlc_am_timer_reordering(void rlc_am_init_timer_reordering(rlc_am_entity_t *rlc_pP, u32_t time_outP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c index 69d5250826f2605ce9095f9ecffec7caebf1be22..c73bcb543c7e2c21c55acfc3b1eea2c5f4b8539e 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.c @@ -37,82 +37,90 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - if (rlcP->t_status_prohibit.time_out > 0) { - if (rlcP->t_status_prohibit.running) { + if (rlc_pP->t_status_prohibit.time_out > 0) { + if (rlc_pP->t_status_prohibit.running) { if ( // CASE 1: start time out // +-----------+------------------+----------+ // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlcP->t_status_prohibit.frame_start < rlcP->t_status_prohibit.frame_time_out) && - ((frame >= rlcP->t_status_prohibit.frame_time_out) || - (frame < rlcP->t_status_prohibit.frame_start))) || + ((rlc_pP->t_status_prohibit.frame_start < rlc_pP->t_status_prohibit.frame_time_out) && + ((frameP >= rlc_pP->t_status_prohibit.frame_time_out) || + (frameP < rlc_pP->t_status_prohibit.frame_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlcP->t_status_prohibit.frame_start > rlcP->t_status_prohibit.frame_time_out) && - (frame < rlcP->t_status_prohibit.frame_start) && (frame >= rlcP->t_status_prohibit.frame_time_out)) + ((rlc_pP->t_status_prohibit.frame_start > rlc_pP->t_status_prohibit.frame_time_out) && + (frameP < rlc_pP->t_status_prohibit.frame_start) && (frameP >= rlc_pP->t_status_prohibit.frame_time_out)) ) { - //if ((rlcP->t_status_prohibit.frame_time_out <= frame) && (rlcP->t_status_prohibit.frame_start)) { - rlcP->t_status_prohibit.running = 0; - rlcP->t_status_prohibit.timed_out = 1; - rlcP->stat_timer_status_prohibit_timed_out += 1; + //if ((rlc_pP->t_status_prohibit.frame_time_out <= frameP) && (rlc_pP->t_status_prohibit.frame_start)) { + rlc_pP->t_status_prohibit.running = 0; + rlc_pP->t_status_prohibit.timed_out = 1; + rlc_pP->stat_timer_status_prohibit_timed_out += 1; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-STATUS-PROHIBIT] TIME-OUT\n", frame, - rlcP->module_id, rlcP->rb_id); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_AM][MOD %02d][RB %02d][--- t-StatusProhibit Timed-out --->][RLC_AM][MOD %02d][RB %02d]\n", - frame, - rlcP->module_id, - rlcP->rb_id, - rlcP->module_id, - rlcP->rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] TIME-OUT\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #warning TO DO rlc_am_check_timer_status_prohibit - rlc_am_stop_and_reset_timer_status_prohibit(rlcP, frame); - //rlcP->t_status_prohibit.frame_time_out = frame + rlcP->t_status_prohibit.time_out; + rlc_am_stop_and_reset_timer_status_prohibit(rlc_pP, frameP); + //rlc_pP->t_status_prohibit.frame_time_out = frameP + rlc_pP->t_status_prohibit.time_out; } } } } //----------------------------------------------------------------------------- -void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - if (rlcP->t_status_prohibit.time_out > 0) { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-STATUS-PROHIBIT] STOPPED AND RESET\n", frame, - rlcP->module_id, rlcP->rb_id); - rlcP->t_status_prohibit.running = 0; - rlcP->t_status_prohibit.frame_time_out = 0; - rlcP->t_status_prohibit.frame_start = 0; - rlcP->t_status_prohibit.timed_out = 0; + if (rlc_pP->t_status_prohibit.time_out > 0) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] STOPPED AND RESET\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->t_status_prohibit.running = 0; + rlc_pP->t_status_prohibit.frame_time_out = 0; + rlc_pP->t_status_prohibit.frame_start = 0; + rlc_pP->t_status_prohibit.timed_out = 0; } } //----------------------------------------------------------------------------- -void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame) +void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - if (rlcP->t_status_prohibit.time_out > 0) { - rlcP->t_status_prohibit.running = 1; - rlcP->t_status_prohibit.frame_time_out = rlcP->t_status_prohibit.time_out + frame; - rlcP->t_status_prohibit.frame_start = frame; - rlcP->t_status_prohibit.timed_out = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-STATUS-PROHIBIT] STARTED (TIME-OUT = FRAME %05d)\n", frame, rlcP->module_id, rlcP->rb_id, rlcP->t_status_prohibit.frame_time_out); - LOG_D(RLC, "TIME-OUT = FRAME %05d\n", rlcP->t_status_prohibit.frame_time_out); + if (rlc_pP->t_status_prohibit.time_out > 0) { + rlc_pP->t_status_prohibit.running = 1; + rlc_pP->t_status_prohibit.frame_time_out = rlc_pP->t_status_prohibit.time_out + frameP; + rlc_pP->t_status_prohibit.frame_start = frameP; + rlc_pP->t_status_prohibit.timed_out = 0; + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u][T-STATUS-PROHIBIT] STARTED (TIME-OUT = FRAME %5u)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_status_prohibit.frame_time_out); + LOG_D(RLC, "TIME-OUT = FRAME %5u\n", rlc_pP->t_status_prohibit.frame_time_out); } } //----------------------------------------------------------------------------- -void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlcP, u32_t time_outP) +void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlc_pP, u32_t time_outP) //----------------------------------------------------------------------------- { - rlcP->t_status_prohibit.running = 0; - rlcP->t_status_prohibit.frame_time_out = 0; - rlcP->t_status_prohibit.frame_start = 0; - rlcP->t_status_prohibit.time_out = time_outP; - rlcP->t_status_prohibit.timed_out = 0; + rlc_pP->t_status_prohibit.running = 0; + rlc_pP->t_status_prohibit.frame_time_out = 0; + rlc_pP->t_status_prohibit.frame_start = 0; + rlc_pP->t_status_prohibit.time_out = time_outP; + rlc_pP->t_status_prohibit.timed_out = 0; } diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h index 950a25b07102afcea9003fbb3ead67e562939a5a..842e1855f038b65c52f0c7631e2d30461919b440 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_timer_status_prohibit.h @@ -57,32 +57,32 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # endif # endif -/*! \fn void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Check if timer status-prohibit has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index */ -protected_rlc_am_timer_status_prohibit(void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame)); +protected_rlc_am_timer_status_prohibit(void rlc_am_check_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP)); -/*! \fn void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlcP) +/*! \fn void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlc_pP) * \brief Stop and reset the timer status-prohibit. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index */ -protected_rlc_am_timer_status_prohibit(void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_status_prohibit(void rlc_am_stop_and_reset_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP) * \brief Re-arm (based on RLC AM config parameter) and start timer status-prohibit. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] frameP Frame index */ -protected_rlc_am_timer_status_prohibit(void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlcP,u32_t frame);) +protected_rlc_am_timer_status_prohibit(void rlc_am_start_timer_status_prohibit(rlc_am_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlcP, u32_t time_outP) +/*! \fn void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlc_pP, u32_t time_outP) * \brief Initialize the timer status-prohibit with RLC AM time-out config parameter. -* \param[in] rlcP RLC AM protocol instance pointer. -* \param[in] time_outP Time-out in frame units. +* \param[in] rlc_pP RLC AM protocol instance pointer. +* \param[in] time_outP Time-out in frameP units. */ -protected_rlc_am_timer_status_prohibit(void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlcP, u32_t time_outP);) +protected_rlc_am_timer_status_prohibit(void rlc_am_init_timer_status_prohibit(rlc_am_entity_t *rlc_pP, u32_t time_outP);) /** @} */ #endif diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c index a7e4adce0692b333d6ba3b20fa38ab2d7500b3bb..6a8f81b7a604ea339abd2d843befcd8c8f76a576 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.c @@ -39,17 +39,17 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "rlc_am.h" #include "UTIL/LOG/log.h" //----------------------------------------------------------------------------- -signed int rlc_am_in_tx_window(rlc_am_entity_t* rlcP, u16_t snP) +signed int rlc_am_in_tx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if (snP >= RLC_AM_SN_MODULO) { return 0; } - shifted_sn = ((u16_t)(snP - rlcP->vt_a)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(rlcP->vt_ms - rlcP->vt_a)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(rlc_pP->vt_ms - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; if ((shifted_sn >= 0) && (shifted_sn < upper_bound)) { return 1; } else { @@ -57,17 +57,17 @@ signed int rlc_am_in_tx_window(rlc_am_entity_t* rlcP, u16_t snP) } } //----------------------------------------------------------------------------- -signed int rlc_am_in_rx_window(rlc_am_entity_t* rlcP, u16_t snP) +signed int rlc_am_in_rx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if (snP >= RLC_AM_SN_MODULO) { return 0; } - shifted_sn = ((u16_t)(snP - rlcP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(rlcP->vr_mr - rlcP->vr_r)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(rlc_pP->vr_mr - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; if ((shifted_sn >= 0) && (shifted_sn < upper_bound)) { return 1; } else { @@ -75,17 +75,17 @@ signed int rlc_am_in_rx_window(rlc_am_entity_t* rlcP, u16_t snP) } } //----------------------------------------------------------------------------- -signed int rlc_am_sn_gte_vr_h(rlc_am_entity_t* rlcP, u16_t snP) +signed int rlc_am_sn_gte_vr_h(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if (snP >= RLC_AM_SN_MODULO) { return 0; } - shifted_sn = ((u16_t)(snP - rlcP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(rlcP->vr_h - rlcP->vr_r)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(rlc_pP->vr_h - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; if (shifted_sn >= upper_bound) { return 1; } else { @@ -93,17 +93,17 @@ signed int rlc_am_sn_gte_vr_h(rlc_am_entity_t* rlcP, u16_t snP) } } //----------------------------------------------------------------------------- -signed int rlc_am_sn_gte_vr_x(rlc_am_entity_t* rlcP, u16_t snP) +signed int rlc_am_sn_gte_vr_x(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if (snP >= RLC_AM_SN_MODULO) { return 0; } - shifted_sn = ((u16_t)(snP - rlcP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(rlcP->vr_x - rlcP->vr_r)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(rlc_pP->vr_x - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; if (shifted_sn >= upper_bound) { return 1; } else { @@ -111,17 +111,17 @@ signed int rlc_am_sn_gte_vr_x(rlc_am_entity_t* rlcP, u16_t snP) } } //----------------------------------------------------------------------------- -signed int rlc_am_sn_gt_vr_ms(rlc_am_entity_t* rlcP, u16_t snP) +signed int rlc_am_sn_gt_vr_ms(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if (snP >= RLC_AM_SN_MODULO) { return 0; } - shifted_sn = ((u16_t)(snP - rlcP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(rlcP->vr_ms - rlcP->vr_r)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(snP - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(rlc_pP->vr_ms - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; if (shifted_sn > upper_bound) { return 1; } else { @@ -129,17 +129,17 @@ signed int rlc_am_sn_gt_vr_ms(rlc_am_entity_t* rlcP, u16_t snP) } } //----------------------------------------------------------------------------- -signed int rlc_am_tx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P) +signed int rlc_am_tx_sn1_gt_sn2(rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if ((sn1P >= RLC_AM_SN_MODULO) || (sn2P >= RLC_AM_SN_MODULO)) { return 0; } - shifted_sn = ((u16_t)(sn1P - rlcP->vt_a)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(sn2P - rlcP->vt_a)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(sn1P - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(sn2P - rlc_pP->vt_a)) % RLC_AM_SN_MODULO; if (shifted_sn > upper_bound) { return 1; } else { @@ -147,17 +147,17 @@ signed int rlc_am_tx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P) } } //----------------------------------------------------------------------------- -signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P) +signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P) //----------------------------------------------------------------------------- { - u16_t shifted_sn; - u16_t upper_bound; + rlc_usn_t shifted_sn; + rlc_usn_t upper_bound; if ((sn1P >= RLC_AM_SN_MODULO) || (sn2P >= RLC_AM_SN_MODULO)) { return 0; } - shifted_sn = ((u16_t)(sn1P - rlcP->vr_r)) % RLC_AM_SN_MODULO; - upper_bound = ((u16_t)(sn2P - rlcP->vr_r)) % RLC_AM_SN_MODULO; + shifted_sn = ((rlc_usn_t)(sn1P - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; + upper_bound = ((rlc_usn_t)(sn2P - rlc_pP->vr_r)) % RLC_AM_SN_MODULO; if (shifted_sn > upper_bound) { return 1; } else { diff --git a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h index cafaa47ae9963bd9636963bcd504c39fa2e7c7a7..873cf727d564ea2227cf22ee80160c2b57d26009 100755 --- a/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h +++ b/openair2/LAYER2/RLC/AM_v9.3.0/rlc_am_windows.h @@ -58,62 +58,62 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # endif # endif -/*! \fn signed int rlc_am_in_tx_window(rlc_am_entity_t* rlcP, u16_t snP) +/*! \fn signed int rlc_am_in_tx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) * \brief Boolean function, check if sequence number is VT(A) <= snP < VT(MS). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] snP Sequence number. * \return 1 if snP in tx window, else 0. */ -protected_rlc_am_windows(signed int rlc_am_in_tx_window(rlc_am_entity_t* rlcP, u16_t snP);) +protected_rlc_am_windows(signed int rlc_am_in_tx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP);) -/*! \fn signed int rlc_am_in_rx_window(rlc_am_entity_t* rlcP, u16_t snP) +/*! \fn signed int rlc_am_in_rx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP) * \brief Boolean function, check if sequence number is VR(R) <= snP < VR(MR). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] snP Sequence number. * \return 1 if snP in rx window, else 0. */ -protected_rlc_am_windows(signed int rlc_am_in_rx_window(rlc_am_entity_t* rlcP, u16_t snP);) +protected_rlc_am_windows(signed int rlc_am_in_rx_window(rlc_am_entity_t* rlc_pP, rlc_sn_t snP);) -/*! \fn signed int rlc_am_sn_gte_vr_h (rlc_am_entity_t* rlcP, u16_t snP) +/*! \fn signed int rlc_am_sn_gte_vr_h (rlc_am_entity_t* rlc_pP, rlc_sn_t snP) * \brief Boolean function, check if sequence number is greater than or equal VR(R). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] snP Sequence number. * \return 1 if sequence number is greater than or equal VR(R), else 0. */ -protected_rlc_am_windows(signed int rlc_am_sn_gte_vr_h (rlc_am_entity_t* rlcP, u16_t snP);) +protected_rlc_am_windows(signed int rlc_am_sn_gte_vr_h (rlc_am_entity_t* rlc_pP, rlc_sn_t snP);) -/*! \fn signed int rlc_am_sn_gte_vr_x (rlc_am_entity_t* rlcP, u16_t snP) +/*! \fn signed int rlc_am_sn_gte_vr_x (rlc_am_entity_t* rlc_pP, rlc_sn_t snP) * \brief Boolean function, check if sequence number is greater than or equal VR(X). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] snP Sequence number. * \return 1 if sequence number is greater than or equal VR(X), else 0. */ -protected_rlc_am_windows(signed int rlc_am_sn_gte_vr_x (rlc_am_entity_t* rlcP, u16_t snP);) +protected_rlc_am_windows(signed int rlc_am_sn_gte_vr_x (rlc_am_entity_t* rlc_pP, rlc_sn_t snP);) -/*! \fn signed int rlc_am_sn_gt_vr_ms (rlc_am_entity_t* rlcP, u16_t snP) +/*! \fn signed int rlc_am_sn_gt_vr_ms (rlc_am_entity_t* rlc_pP, rlc_sn_t snP) * \brief Boolean function, check if sequence number is greater than VR(MS). -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] snP Sequence number. * \return 1 if sequence number is greater than VR(MS), else 0. */ -protected_rlc_am_windows(signed int rlc_am_sn_gt_vr_ms(rlc_am_entity_t* rlcP, u16_t snP);) +protected_rlc_am_windows(signed int rlc_am_sn_gt_vr_ms(rlc_am_entity_t* rlc_pP, rlc_sn_t snP);) -/*! \fn signed int rlc_am_tx_sn1_gt_sn2 (rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P) +/*! \fn signed int rlc_am_tx_sn1_gt_sn2 (rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P) * \brief Boolean function, in the context of the tx window, check if sn1P is greater than sn2P. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] sn1P Sequence number. * \param[in] sn2P Sequence number. * \return 1 if sn1P is greater than sn2P, else 0. */ -protected_rlc_am_windows(signed int rlc_am_tx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P);) +protected_rlc_am_windows(signed int rlc_am_tx_sn1_gt_sn2(rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P);) -/*! \fn signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P) +/*! \fn signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P) * \brief Boolean function, in the context of the rx window, check if sn1P is greater than sn2P. -* \param[in] rlcP RLC AM protocol instance pointer. +* \param[in] rlc_pP RLC AM protocol instance pointer. * \param[in] sn1P Sequence number. * \param[in] sn2P Sequence number. * \return 1 if sn1P is greater than sn2P, else 0. */ -protected_rlc_am_windows(signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlcP, u16_t sn1P, u16_t sn2P);) +protected_rlc_am_windows(signed int rlc_am_rx_sn1_gt_sn2(rlc_am_entity_t* rlc_pP, rlc_sn_t sn1P, rlc_sn_t sn2P);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c index 3d06f81260843a5b3ed87aeb40d9e0cd38ba364b..fda4a636968cd508eb0d7bda82747537c42acc37 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm.c @@ -54,16 +54,6 @@ rlc_tm_send_sdu (rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flag, u8_t error_i rlcP->output_sdu_in_construction = get_free_mem_block (length_in_bytes); } if ((rlcP->output_sdu_in_construction)) { - u8_t eNB_id; - u8_t UE_id; - if (eNB_flag == 0) { - /* FIXME: force send on first eNB */ - eNB_id = 0; - UE_id = rlcP->module_id - NB_eNB_INST; - } else { - UE_id = rlcP->rb_id / NB_RB_MAX; - eNB_id = rlcP->module_id; - } #ifdef DEBUG_RLC_TM_DISPLAY_ASCII_DATA msg ("[RLC_TM %p][SEND_SDU] DATA :", rlcP); for (index = 0; index < length_in_bytes; index++) { @@ -74,7 +64,7 @@ rlc_tm_send_sdu (rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flag, u8_t error_i memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, length_in_bytes); - rlc_data_ind (rlcP->module_id, eNB_id, UE_id, frame, eNB_flag, RLC_MBMS_NO, rlcP->rb_id, length_in_bytes, rlcP->output_sdu_in_construction, rlcP->is_data_plane); + rlc_data_ind (rlcP->enb_module_id, rlcP->ue_module_id, frame, eNB_flag, RLC_MBMS_NO, rlcP->rb_id, length_in_bytes, rlcP->output_sdu_in_construction, rlcP->is_data_plane); rlcP->output_sdu_in_construction = NULL; } else { msg ("[RLC_TM %p][SEND_SDU] ERROR OUTPUT SDU IS NULL\n", rlcP); @@ -174,26 +164,13 @@ rlc_tm_mac_data_request (void *rlcP, u32_t frame) data_req.buffer_occupancy_in_pdus = data_req.buffer_occupancy_in_bytes / l_rlc->rlc_pdu_size; data_req.rlc_info.rlc_protocol_state = l_rlc->protocol_state; if (data_req.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_TM][MOD %d][RB %d][FRAME %05d] MAC_DATA_REQUEST %d TBs\n", l_rlc->module_id, l_rlc->rb_id, frame, data_req.data.nb_elements); - mem_block_t *tb; - rlc[l_rlc->module_id].m_mscgen_trace_length = sprintf(rlc[l_rlc->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][RLC_UM][MOD %02d][RB %02d][--- MAC_DATA_REQ/ %d TB(s) ", - frame, - l_rlc->module_id, - l_rlc->rb_id, - data_req.data.nb_elements); - - tb = data_req.data.head; - while (tb != NULL) { - rlc[l_rlc->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length], "%d Bytes ", - ((struct mac_tb_req *) (tb->data))->tb_size); - tb = tb->next; - } - rlc[l_rlc->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length], "BO=%d --->][MAC_%s][MOD %02d][]\n", - data_req.buffer_occupancy_in_bytes, - (l_rlc->is_enb) ? "eNB":"UE", - l_rlc->module_id); - rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length] = 0; - LOG_D(RLC, "%s", rlc[l_rlc->module_id].m_mscgen_trace); + LOG_D(RLC, "[RLC_TM][%s][MOD %02u/%02u][RB %d][FRAME %05d] MAC_DATA_REQUEST %d TBs\n", + (l_rlc->is_enb) ? "eNB" : "UE", + l_rlc->enb_module_id, + l_rlc->ue_module_id, + l_rlc->rb_id, + frame, + data_req.data.nb_elements); } return data_req; @@ -208,25 +185,13 @@ rlc_tm_mac_data_indication (void *rlcP, u32_t frame, u8_t eNB_flag, struct mac_d mem_block_t *tb; if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", l_rlc->module_id, l_rlc->rb_id, frame, data_indP.data.nb_elements); - rlc[l_rlc->module_id].m_mscgen_trace_length = sprintf(rlc[l_rlc->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", + LOG_D(RLC, "[RLC_TM][%s][MOD %02u/%02u][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", + (l_rlc->is_enb) ? "eNB" : "UE", + l_rlc->enb_module_id, + l_rlc->ue_module_id, + l_rlc->rb_id, frame, - (l_rlc->is_enb) ? "eNB":"UE", - l_rlc->module_id, data_indP.data.nb_elements); - - tb = data_indP.data.head; - while (tb != NULL) { - rlc[l_rlc->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length], "%d Bytes ", - ((struct mac_tb_ind *) (tb->data))->size); - tb = tb->next; - } - rlc[l_rlc->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length], " --->][RLC_TM][MOD %02d][RB %02d]\n", - l_rlc->module_id, - l_rlc->rb_id); - - rlc[l_rlc->module_id].m_mscgen_trace[rlc[l_rlc->module_id].m_mscgen_trace_length] = 0; - LOG_D(RLC, "%s", rlc[l_rlc->module_id].m_mscgen_trace); } rlc_tm_rx (rlcP, frame, eNB_flag, data_indP); } @@ -239,7 +204,15 @@ rlc_tm_data_req (void *rlcP, mem_block_t *sduP) rlc_tm_entity_t *rlc = (rlc_tm_entity_t *) rlcP; #ifdef DEBUG_RLC_TM_DATA_REQUEST - msg ("[RLC_TM %p] RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", rlc, ((struct rlc_um_data_req *) (sduP->data))->data_size, rlc->buffer_occupancy, rlc->nb_sdu, rlc->current_sdu_index, rlc->next_sdu_index); + LOG_D (RLC, "[RLC_TM][%s][MOD %02u/%02u] RLC_TM_DATA_REQ size %d Bytes, BO %ld , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", + (l_rlc->is_enb) ? "eNB" : "UE", + l_rlc->enb_module_id, + l_rlc->ue_module_id, + ((struct rlc_um_data_req *) (sduP->data))->data_size, + rlc->buffer_occupancy, + rlc->nb_sdu, + rlc->current_sdu_index, + rlc->next_sdu_index); #endif // not in 3GPP specification but the buffer may be full if not correctly configured diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h index bb3066ceafa5bc691c4b95df8767581cf2a73e24..203af010376d594c03649ba86c173e354d57e35c 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_entity.h @@ -47,13 +47,15 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis * \brief Structure containing a RLC TM instance protocol variables, allocation variables, buffers and other miscellaneous variables. */ typedef struct rlc_tm_entity { - module_id_t module_id; /*!< \brief Virtualization index for this protocol instance, means handset or eNB index.*/ + module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */ + module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance. */ u8_t allocation; /*!< \brief Boolean for rlc_tm_entity_t struct allocation. */ u8_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ - u8_t is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ - u16_t is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ + boolean_t is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ + boolean_t is_data_plane; /*!< \brief To know if the RLC belongs to a data radio bearer or a signalling radio bearer, for statistics and trace purpose. */ // for stats and trace purpose : - u16_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ + logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ + rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ boolean_t is_enb; /*!< \brief To know if the RLC belongs to a eNB or UE. */ //----------------------------- // tranmission @@ -66,7 +68,7 @@ typedef struct rlc_tm_entity { u16_t next_sdu_index; /*!< \brief Next SDU index for a new incomin SDU in input_sdus[]. */ u16_t current_sdu_index; /*!< \brief Current SDU index in input_sdus array to be segmented. */ list_t pdus_to_mac_layer; /*!< \brief PDUs buffered for transmission to MAC layer. */ - u16_t rlc_pdu_size; + sdu_size_t rlc_pdu_size; u32_t buffer_occupancy; /*!< \brief Number of bytes contained in input_sdus buffer.*/ //----------------------------- // receiver diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c index 9c243cc56736842eacee7749db7dc467d53e3eea..6ef48e20ec3fcf28307fda3b902590212ee11cc6 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.c @@ -32,13 +32,30 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "rlc_tm.h" #include "LAYER2/MAC/extern.h" //----------------------------------------------------------------------------- -void config_req_rlc_tm (rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP) +void config_req_rlc_tm ( u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP) { //----------------------------------------------------------------------------- - rlc_tm_init(rlcP); - rlcP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; - rlc_tm_set_debug_infos(rlcP, frame, eNB_flagP, module_idP, rb_idP, rb_typeP); - rlc_tm_configure(rlcP, config_tmP->is_uplink_downlink); + rlc_tm_entity_t *rlc = NULL; + + LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ (is_uplink_downlink=%d) --->][RLC_TM][MOD %u/%u][RB %u]\n", + frame, + ( eNB_flagP > 0) ? "eNB":"UE", + enb_module_idP, + ue_module_idP, + config_tmP->is_uplink_downlink, + enb_module_idP, + ue_module_idP, + rb_idP); + + if (eNB_flagP) { + rlc = &rlc_array_eNB[enb_module_idP][ue_module_idP][rb_idP].rlc.tm; + } else { + rlc = &rlc_array_ue[ue_module_idP][rb_idP].rlc.tm; + } + rlc_tm_init(rlc); + rlc->protocol_state = RLC_DATA_TRANSFER_READY_STATE; + rlc_tm_set_debug_infos(rlc, frame, eNB_flagP, enb_module_idP, ue_module_idP, rb_idP, rb_typeP); + rlc_tm_configure(rlc, config_tmP->is_uplink_downlink); } //----------------------------------------------------------------------------- @@ -101,6 +118,7 @@ rlc_tm_cleanup (rlc_tm_entity_t *rlcP) if ((rlcP->output_sdu_in_construction)) { free_mem_block (rlcP->output_sdu_in_construction); } + memset(rlcP, 0, sizeof(rlc_tm_entity_t)); } //----------------------------------------------------------------------------- @@ -112,12 +130,22 @@ void rlc_tm_configure(rlc_tm_entity_t *rlcP, u8_t is_uplink_downlinkP) } //----------------------------------------------------------------------------- -void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) //----------------------------------------------------------------------------- { - msg ("[FRAME %05d][RLC_TM][MOD %02d][RB %02d][SET DEBUG INFOS] module_id %d rb_id %d rb_type %d\n", frame, module_idP, rb_idP, module_idP, rb_idP, rb_typeP); - - rlcP->module_id = module_idP; + msg ("[FRAME %05d][%s][RLC_TM][MOD %02u/%02u][RB %u][SET DEBUG INFOS] enb module_id %d ue module_id %d rb_id %d rb_type %d\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_module_idP, + ue_module_idP, + rb_idP, + enb_module_idP, + ue_module_idP, + rb_idP, + rb_typeP); + + rlcP->enb_module_id = enb_module_idP; + rlcP->ue_module_id = ue_module_idP; rlcP->rb_id = rb_idP; if (rb_typeP != SIGNALLING_RADIO_BEARER) { rlcP->is_data_plane = 1; diff --git a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h index 409ac93c69b07d67507bdd965750aeb84e0caafc..37f51e1d5a6acd316410a91c810b3b4d93c2b8c4 100755 --- a/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h +++ b/openair2/LAYER2/RLC/TM_v9.3.0/rlc_tm_init.h @@ -70,17 +70,17 @@ typedef volatile struct { } rlc_tm_info_t; -/*! \fn void config_req_rlc_tm (rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void config_req_rlc_tm (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Allocate memory for RLC TM instance, reset protocol variables, and set protocol parameters. -* \param[in] rlcP RLC TM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] config_tmP Configuration parameters for RLC TM instance. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -public_rlc_tm_init( void config_req_rlc_tm (rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_tm_init( void config_req_rlc_tm (u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_tm_info_t * config_tmP, rb_id_t rb_idP, rb_type_t rb_typeP);) /*! \fn void rlc_tm_init (rlc_tm_entity_t *rlcP) * \brief Initialize a RLC TM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC TM protocol instance will be in RLC_NULL_STATE state. @@ -108,15 +108,16 @@ RECEIVER_ONLY, or TRANSMITTER_AND_RECEIVER. */ protected_rlc_tm_init(void rlc_tm_configure(rlc_tm_entity_t *rlcP, u8_t is_uplink_downlinkP);) -/*! \fn void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Set debug informations for a RLC TM protocol instance, these informations are only for trace purpose. * \param[in] rlcP RLC TM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -protected_rlc_tm_init(void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) +protected_rlc_tm_init(void rlc_tm_set_debug_infos(rlc_tm_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM/rlc_um_receiver.c index dc70fdf53af3f17360e29a313ff682fff0644700..6fb3627ff0f4c073cec847417336cb63ec655e50 100755 --- a/openair2/LAYER2/RLC/UM/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM/rlc_um_receiver.c @@ -43,72 +43,75 @@ #endif //----------------------------------------------------------------------------- inline void -rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_management *pdu_mngt, struct rlc_um_rx_data_pdu_struct *dataP, u16_t tb_sizeP) +rlc_um_receive_15_process_waited_pdu (struct rlc_um_entity *rlc_pP, + struct rlc_um_rx_pdu_management *pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct *data_pP, + sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - u8_t *data_pdu; - int nb_li = 0; - int li_index = 0; - int remaining_data_size; - u16_t li[32]; - - if ((dataP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { - rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP); + u8_t *data_pdu_p = NULL; + sdu_size_t remaining_data_size = 0; + int nb_li = 0; + int li_index = 0; + sdu_size_t li[32]; + + if ((data_pP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { + rlc_um_reassembly ((u8_t *) (&data_pP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); } else { - while ((li[nb_li] = ((((u16_t) dataP->li_data_7[nb_li << 1]) << 8) + dataP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { + while ((li[nb_li] = ((((u16_t) data_pP->li_data_7[nb_li << 1]) << 8) + data_pP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(u16_t) RLC_E_NEXT_FIELD_IS_LI_E); nb_li++; } nb_li++; // count the last li remaining_data_size = tb_sizeP - 1 - (nb_li << 1); - data_pdu = (u8_t *) (&dataP->li_data_7[nb_li << 1]); + data_pdu_p = (u8_t *) (&data_pP->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { case RLC_LI_LAST_PDU_EXACTLY_FILLED: - rlc_um_send_sdu (rlcP); + rlc_um_send_sdu (rlc_pP); break; case RLC_LI_LAST_PDU_ONE_BYTE_SHORT: - rlcP->output_sdu_size_to_write -= 1; - rlc_um_send_sdu (rlcP); + rlc_pP->output_sdu_size_to_write -= 1; + rlc_um_send_sdu (rlc_pP); break; case RLC_LI_PDU_PIGGY_BACKED_STATUS: // ignore case RLC_LI_PDU_PADDING: remaining_data_size = 0; break; case RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU: - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; break; default: // li is length remaining_data_size = remaining_data_size - (li[li_index] >> 1); - rlc_um_reassembly (data_pdu, (li[li_index] >> 1), rlcP); - data_pdu = (u8_t *) ((u32_t) data_pdu + (li[li_index] >> 1)); - rlc_um_send_sdu (rlcP); + rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP); + data_pdu_p = (u8_t *) ((u64_t) data_pdu_p + (li[li_index] >> 1)); + rlc_um_send_sdu (rlc_pP); } li_index++; } if ((remaining_data_size)) { - rlc_um_reassembly (data_pdu, remaining_data_size, rlcP); + rlc_um_reassembly (data_pdu_p, remaining_data_size, rlc_pP); remaining_data_size = 0; } } - rlcP->vr_us = (rlcP->vr_us + 1) & 127; + rlc_pP->vr_us = (rlc_pP->vr_us + 1) & 127; } //----------------------------------------------------------------------------- inline void -rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_management *pdu_mngtP, struct rlc_um_rx_data_pdu_struct *dataP, u16_t tb_sizeP) +rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlc_pP, struct rlc_um_rx_pdu_management *pdu_mngtP, struct rlc_um_rx_data_pdu_struct *dataP, u16_t tb_sizeP) { //----------------------------------------------------------------------------- - u8_t *data_pdu; - int remaining_data_size; - int nb_li = 0; - int li_index = 0; - u16_t li[32]; + u8_t *data_pdu_p = NULL; + sdu_size_t remaining_data_size = 0; + int nb_li = 0; + int li_index = 0; + sdu_size_t li[32]; if ((dataP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { - rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP); + rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlc_pP, 0); } else { while ((li[nb_li] = ((u16_t) dataP->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(u8_t) RLC_E_NEXT_FIELD_IS_LI_E); @@ -117,74 +120,77 @@ rlc_um_receive_7_process_waited_pdu (struct rlc_um_entity *rlcP, struct rlc_um_r nb_li++; // count the last li remaining_data_size = tb_sizeP - 1 - nb_li; - data_pdu = (u8_t *) (&dataP->li_data_7[nb_li]); + data_pdu_p = (u8_t *) (&dataP->li_data_7[nb_li]); while (li_index < nb_li) { switch (li[li_index]) { case (u8_t) RLC_LI_LAST_PDU_EXACTLY_FILLED: - PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_LAST_PDU_EXACTLY_FILLED\n", rlcP, pdu_mngtP); - rlc_um_send_sdu (rlcP); + PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_LAST_PDU_EXACTLY_FILLED\n", rlc_pP, pdu_mngtP); + rlc_um_send_sdu (rlc_pP); break; case (u8_t) RLC_LI_LAST_PDU_ONE_BYTE_SHORT: - PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_LAST_PDU_ONE_BYTE_SHORT\n", rlcP, pdu_mngtP); - rlcP->output_sdu_size_to_write -= 1; - rlc_um_send_sdu (rlcP); + PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_LAST_PDU_ONE_BYTE_SHORT\n", rlc_pP, pdu_mngtP); + rlc_pP->output_sdu_size_to_write -= 1; + rlc_um_send_sdu (rlc_pP); break; case (u8_t) RLC_LI_PDU_PIGGY_BACKED_STATUS: // ignore case (u8_t) RLC_LI_PDU_PADDING: - PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_PDU_PADDING\n", rlcP, pdu_mngtP); + PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_PDU_PADDING\n", rlc_pP, pdu_mngtP); remaining_data_size = 0; break; case (u8_t) RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU: - PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU\n", rlcP, pdu_mngtP); - rlcP->output_sdu_size_to_write = 0; + PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU\n", rlc_pP, pdu_mngtP); + rlc_pP->output_sdu_size_to_write = 0; break; default: // li is length - PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li LI_SIZE %d Bytes\n", rlcP, pdu_mngtP, li[li_index] >> 1); + PRINT_RLC_UM_RX_DECODE_LI ("[RLC_UM %p] RX_7 PDU %p Li LI_SIZE %d Bytes\n", rlc_pP, pdu_mngtP, li[li_index] >> 1); remaining_data_size = remaining_data_size - (li[li_index] >> 1); - rlc_um_reassembly (data_pdu, (li[li_index] >> 1), rlcP); - data_pdu = (u8_t *) ((u32_t) data_pdu + (li[li_index] >> 1)); - rlc_um_send_sdu (rlcP); + rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP); + data_pdu_p = (u8_t *) ((u64_t) data_pdu_p + (li[li_index] >> 1)); + rlc_um_send_sdu (rlc_pP); } li_index++; } if ((remaining_data_size)) { - rlc_um_reassembly (data_pdu, remaining_data_size, rlcP); + rlc_um_reassembly (data_pdu_p, remaining_data_size, rlc_pP); remaining_data_size = 0; } } - rlcP->vr_us = (rlcP->vr_us + 1) & 127; + rlc_pP->vr_us = (rlc_pP->vr_us + 1) & 127; } //----------------------------------------------------------------------------- inline void -rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_management *pdu_mngt, struct rlc_um_rx_data_pdu_struct *dataP, u16_t tb_sizeP) +rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity *rlc_pP, + struct rlc_um_rx_pdu_management *pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct *data_pP, + sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - u8_t *data_pdu; - int nb_li = 0; - int li_index = 0; - int remaining_data_size; - u16_t li[32]; - u8_t start_processing = 0; + u8_t *data_pdu_p = NULL; + int nb_li = 0; + int li_index = 0; + sdu_size_t remaining_data_size = 0; + sdu_size_t li[32]; + u8_t start_processing = 0; - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; - if ((dataP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { + if ((data_pP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { return; } else { - while ((li[nb_li] = ((((u16_t) dataP->li_data_7[nb_li << 1]) << 8) + dataP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { + while ((li[nb_li] = ((((u16_t) data_pP->li_data_7[nb_li << 1]) << 8) + data_pP->li_data_7[(nb_li << 1) + 1])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(u16_t) RLC_E_NEXT_FIELD_IS_LI_E); nb_li++; } nb_li++; // count the last li remaining_data_size = tb_sizeP - 1 - (nb_li << 1); - data_pdu = (u8_t *) (&dataP->li_data_7[nb_li << 1]); + data_pdu_p = (u8_t *) (&data_pP->li_data_7[nb_li << 1]); while (li_index < nb_li) { switch (li[li_index]) { @@ -198,45 +204,48 @@ rlc_um_receive_15_process_unsynchronized_pdu (struct rlc_um_entity *rlcP, struct break; case RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU: start_processing = 1; - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; break; default: // li is length remaining_data_size = remaining_data_size - (li[li_index] >> 1); if ((start_processing)) { - rlc_um_reassembly (data_pdu, (li[li_index] >> 1), rlcP); - rlc_um_send_sdu (rlcP); + rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP, 0); + rlc_um_send_sdu (rlc_pP); } start_processing = 1; - data_pdu = (u8_t *) ((u32_t) data_pdu + (li[li_index] >> 1)); + data_pdu_p = (u8_t *) ((u64_t) data_pdu_p + (li[li_index] >> 1)); } li_index++; } if ((remaining_data_size)) { - rlc_um_reassembly (data_pdu, remaining_data_size, rlcP); + rlc_um_reassembly (data_pdu_p, remaining_data_size, rlc_pP); remaining_data_size = 0; } } - rlcP->vr_us = (pdu_mngt->sn + 1) & 127; + rlc_pP->vr_us = (pdu_mngt_pP->sn + 1) & 127; } //----------------------------------------------------------------------------- inline void -rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_management *pdu_mngt, struct rlc_um_rx_data_pdu_struct *dataP, u16_t tb_sizeP) +rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rlc_pP, + struct rlc_um_rx_pdu_management *pdu_mngt_pP, + struct rlc_um_rx_data_pdu_struct *data_pP, + sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- - u8_t *data_pdu; - int nb_li = 0; - int li_index = 0; - int remaining_data_size; - u16_t li[32]; - u8_t start_processing = 0; + u8_t *data_pdu_p = NULL; + int nb_li = 0; + int li_index = 0; + sdu_size_t remaining_data_size = 0; + sdu_size_t li[32]; + u8_t start_processing = 0; - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; - if ((dataP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { + if ((data_pP->byte1 & RLC_E_MASK) == (u8_t) RLC_E_NEXT_FIELD_IS_DATA) { return; } else { - while ((li[nb_li] = ((u16_t) dataP->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { + while ((li[nb_li] = ((u16_t) data_pP->li_data_7[nb_li])) & RLC_E_NEXT_FIELD_IS_LI_E) { li[nb_li] = li[nb_li] & (~(u8_t) RLC_E_NEXT_FIELD_IS_LI_E); nb_li++; } @@ -244,7 +253,7 @@ rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rlcP, struct remaining_data_size = tb_sizeP - 1 - nb_li; - data_pdu = (u8_t *) (&dataP->li_data_7[nb_li]); + data_pdu_p = (u8_t *) (&data_pP->li_data_7[nb_li]); while (li_index < nb_li) { switch (li[li_index]) { @@ -258,148 +267,139 @@ rlc_um_receive_7_process_unsynchronized_pdu (struct rlc_um_entity *rlcP, struct break; case (u8_t) RLC_LI_1ST_BYTE_SDU_IS_1ST_BYTE_PDU: start_processing = 1; - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; break; default: // li is length remaining_data_size = remaining_data_size - (li[li_index] >> 1); if ((start_processing)) { - rlc_um_reassembly (data_pdu, (li[li_index] >> 1), rlcP); - rlc_um_send_sdu (rlcP); + rlc_um_reassembly (data_pdu_p, (li[li_index] >> 1), rlc_pP, 0); + rlc_um_send_sdu (rlc_pP); } start_processing = 1; - data_pdu = (u8_t *) ((u32_t) data_pdu + (li[li_index] >> 1)); + data_pdu_p = (u8_t *) ((u64_t) data_pdu_p + (li[li_index] >> 1)); } li_index++; } if ((remaining_data_size)) { - rlc_um_reassembly (data_pdu, remaining_data_size, rlcP); + rlc_um_reassembly (data_pdu_p, remaining_data_size, rlc_pP); remaining_data_size = 0; } } - rlcP->vr_us = (pdu_mngt->sn + 1) & 127; + rlc_pP->vr_us = (pdu_mngt_pP->sn + 1) & 127; } //----------------------------------------------------------------------------- void -rlc_um_receive_15 (struct rlc_um_entity *rlcP, struct mac_data_ind data_indP) +rlc_um_receive_15 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - struct rlc_um_rx_data_pdu_struct *data; - struct rlc_um_rx_pdu_management *pdu_mngt; - struct mem_block *tb; - u8_t *first_byte; - u8_t tb_size_in_bytes; - u8_t first_bit; - u8_t bits_to_shift; - u8_t bits_to_shift_last_loop; + struct rlc_um_rx_data_pdu_struct *data_p = NULL; + struct rlc_um_rx_pdu_management *pdu_mngt_p = NULL; + struct mem_block *tb_p = NULL; + u8_t *first_byte_p = NULL; + sdu_size_t tb_size_in_bytes = 0; + u8_t first_bit = 0; + u8_t bits_to_shift = 0; + u8_t bits_to_shift_last_loop = 0; - while ((tb = remove_up_head (&data_indP.data))) { + while ((tb_p = remove_up_head (&data_indP.data))) { - if (!(((struct mac_tb_ind *) (tb->data))->error_indication)) { + if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) { - first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr; - pdu_mngt = (struct rlc_um_rx_pdu_management *) (tb->data); + first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; + pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb_p->data); tb_size_in_bytes = data_indP.tb_size; - first_bit = ((struct mac_tb_ind *) (tb->data))->first_bit; + first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK bits_to_shift_last_loop = 0; while ((tb_size_in_bytes)) { - bits_to_shift = first_byte[tb_size_in_bytes] >> (8 - first_bit); - first_byte[tb_size_in_bytes] = (first_byte[tb_size_in_bytes] << first_bit) | (bits_to_shift_last_loop); + bits_to_shift = first_byte_p[tb_size_in_bytes] >> (8 - first_bit); + first_byte_p[tb_size_in_bytes] = (first_byte_p[tb_size_in_bytes] << first_bit) | (bits_to_shift_last_loop); tb_size_in_bytes -= 1; bits_to_shift_last_loop = bits_to_shift; } - first_byte[0] = (first_byte[0] << first_bit) | (bits_to_shift_last_loop); + first_byte_p[0] = (first_byte_p[0] << first_bit) | (bits_to_shift_last_loop); } - pdu_mngt->first_byte = first_byte; - data = (struct rlc_um_rx_data_pdu_struct *) (first_byte); - pdu_mngt->sn = data->byte1 >> 1; -#ifdef BENCH_QOS_L2 - fprintf (bench_l2, "[PDU RX] FRAME %d SN %d RLC-UM %p\n", mac_xface->frame, pdu_mngt->sn, rlcP); -#endif - PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU SN %02X hex\n", rlcP->rb_id, pdu_mngt->sn); + pdu_mngt_p->first_byte = first_byte_p; + data_p = (struct rlc_um_rx_data_pdu_struct *) (first_byte_p); + pdu_mngt_p->sn = data_p->byte1 >> 1; + PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU SN %02X hex\n", rlc_pP->rb_id, pdu_mngt_p->sn); - if (pdu_mngt->sn == rlcP->vr_us) { - rlc_um_receive_15_process_waited_pdu (rlcP, pdu_mngt, data, data_indP.tb_size); + if (pdu_mngt_p->sn == rlc_pP->vr_us) { + rlc_um_receive_15_process_waited_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } else { - rlc_um_receive_15_process_unsynchronized_pdu (rlcP, pdu_mngt, data, data_indP.tb_size); + rlc_um_receive_15_process_unsynchronized_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } } else { - PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlcP->rb_id); + PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX PDU WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlc_pP->rb_id); } - free_mem_block (tb); + free_mem_block (tb_p); } } //----------------------------------------------------------------------------- void -rlc_um_receive_7 (struct rlc_um_entity *rlcP, struct mac_data_ind data_indP) +rlc_um_receive_7 (struct rlc_um_entity *rlc_pP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - struct rlc_um_rx_data_pdu_struct *data; - struct rlc_um_rx_pdu_management *pdu_mngt; - struct mem_block *tb; - u8_t *first_byte; - u8_t tb_size_in_bytes; - u8_t first_bit; - u8_t bits_to_shift; - u8_t bits_to_shift_last_loop; + struct rlc_um_rx_data_pdu_struct *data_p = NULL; + struct rlc_um_rx_pdu_management *pdu_mngt_p = NULL; + struct mem_block *tb_p = NULL; + u8_t *first_byte_p = NULL; + sdu_size_t tb_size_in_bytes = 0; + u8_t first_bit = 0; + u8_t bits_to_shift = 0; + u8_t bits_to_shift_last_loop = 0; - while ((tb = remove_up_head (&data_indP.data))) { + while ((tb_p = remove_up_head (&data_indP.data))) { - if (!(((struct mac_tb_ind *) (tb->data))->error_indication)) { + if (!(((struct mac_tb_ind *) (tb_p->data))->error_indication)) { #ifdef DEBUG_RLC_STATS - rlcP->rx_pdus += 1; + rlc_pP->rx_pdus += 1; #endif - first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr; - pdu_mngt = (struct rlc_um_rx_pdu_management *) (tb->data); + first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; + pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb_p->data); tb_size_in_bytes = data_indP.tb_size; - first_bit = ((struct mac_tb_ind *) (tb->data))->first_bit; + first_bit = ((struct mac_tb_ind *) (tb_p->data))->first_bit; if (first_bit > 0) { // shift data of transport_block TO CHECK bits_to_shift_last_loop = 0; while ((tb_size_in_bytes)) { - bits_to_shift = first_byte[tb_size_in_bytes] >> (8 - first_bit); - first_byte[tb_size_in_bytes] = (first_byte[tb_size_in_bytes] << first_bit) | (bits_to_shift_last_loop); + bits_to_shift = first_byte_p[tb_size_in_bytes] >> (8 - first_bit); + first_byte_p[tb_size_in_bytes] = (first_byte_p[tb_size_in_bytes] << first_bit) | (bits_to_shift_last_loop); tb_size_in_bytes -= 1; bits_to_shift_last_loop = bits_to_shift; } - first_byte[0] = (first_byte[0] << first_bit) | (bits_to_shift_last_loop); + first_byte_p[0] = (first_byte_p[0] << first_bit) | (bits_to_shift_last_loop); } - pdu_mngt->first_byte = first_byte; - data = (struct rlc_um_rx_data_pdu_struct *) (first_byte); - pdu_mngt->sn = data->byte1 >> 1; - PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %d VR(US) %d\n", rlcP->rb_id, pdu_mngt->sn, rlcP->vr_us); -#ifdef BENCH_QOS_L2 - fprintf (bench_l2, "[PDU RX] FRAME %d SN %d RLC-UM %p\n", mac_xface->frame, pdu_mngt->sn, rlcP); -#endif + pdu_mngt_p->first_byte = first_byte_p; + data_p = (struct rlc_um_rx_data_pdu_struct *) (first_byte_p); + pdu_mngt_p->sn = data_p->byte1 >> 1; + PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %d VR(US) %d\n", rlc_pP->rb_id, pdu_mngt_p->sn, rlc_pP->vr_us); - if (pdu_mngt->sn == rlcP->vr_us) { - rlc_um_receive_7_process_waited_pdu (rlcP, pdu_mngt, data, data_indP.tb_size); + if (pdu_mngt_p->sn == rlc_pP->vr_us) { + rlc_um_receive_7_process_waited_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } else { - rlc_um_receive_7_process_unsynchronized_pdu (rlcP, pdu_mngt, data, data_indP.tb_size); + rlc_um_receive_7_process_unsynchronized_pdu (rlc_pP, pdu_mngt_p, data_p, data_indP.tb_size); } } else { #ifdef DEBUG_RLC_STATS - rlcP->rx_pdus_in_error += 1; -#endif -#ifdef BENCH_QOS_L2 - fprintf (bench_l2, "[PDU RX ERROR] FRAME %d RLC-UM %p\n", mac_xface->frame, rlcP); + rlc_pP->rx_pdus_in_error += 1; #endif #ifdef DEBUG_RLC_UM_RX - pdu_mngt = (struct rlc_um_rx_pdu_management *) (tb->data); - PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %02X hex??? WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlcP->rb_id, pdu_mngt->sn); + pdu_mngt_p = (struct rlc_um_rx_pdu_management *) (tb->data); + PRINT_RLC_UM_RX ("[RLC_UM][RB %d] RX7 PDU SN %02X hex??? WITH ERROR INDICATED BY LOWER LAYERS -> GARBAGE\n", rlc_pP->rb_id, pdu_mngt_p->sn); #endif } - free_mem_block (tb); + free_mem_block (tb_p); } } diff --git a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c index 225e15fee9ea8508c2a187ea083ff329f9bd05ad..1b07da1ab72042b1ed018de658ed3eaf82b49749 100755 --- a/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM_v6.1.0_LITE/rlc_um_receiver.c @@ -97,9 +97,9 @@ rlc_um_receive_process_pdu (struct rlc_um_entity *rlcP, struct rlc_um_rx_pdu_man msg ("[RLC_UM_LITE][RB %d] GOOD CRC ON RLC HEADER 1 byte\n", rlcP->rb_id); } } - rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 2, rlcP); + rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 2, rlcP, 0); } else { - rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP); + rlc_um_reassembly ((u8_t *) (&dataP->li_data_7[0]), tb_sizeP - 1, rlcP, 0); } } //--------------------------------- diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c index 17c7419a9e0e35d2d97cb6fa11ea08fcaa1543f8..91387c8e048bd1cc41fb4687f0967e5a03d494f2 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um.c @@ -47,14 +47,14 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "rlc_um_very_simple_test.h" -//#define DEBUG_RLC_UM_TX_STATUS 1 +#define DEBUG_RLC_UM_TX_STATUS 1 #define TRACE_RLC_UM_PDU 1 #ifdef TRACE_RLC_UM_PDU char message_string[10000]; #endif //----------------------------------------------------------------------------- -void rlc_um_stat_req (rlc_um_entity_t *rlcP, +void rlc_um_stat_req (rlc_um_entity_t *rlc_pP, unsigned int* stat_tx_pdcp_sdu, unsigned int* stat_tx_pdcp_bytes, unsigned int* stat_tx_pdcp_sdu_discarded, @@ -73,43 +73,43 @@ void rlc_um_stat_req (rlc_um_entity_t *rlcP, unsigned int* stat_rx_data_bytes_out_of_window, unsigned int* stat_timer_reordering_timed_out) { //----------------------------------------------------------------------------- - *stat_tx_pdcp_sdu = rlcP->stat_tx_pdcp_sdu; - *stat_tx_pdcp_bytes = rlcP->stat_tx_pdcp_bytes; - *stat_tx_pdcp_sdu_discarded = rlcP->stat_tx_pdcp_sdu_discarded; - *stat_tx_pdcp_bytes_discarded = rlcP->stat_tx_pdcp_bytes_discarded; - *stat_tx_data_pdu = rlcP->stat_tx_data_pdu; - *stat_tx_data_bytes = rlcP->stat_tx_data_bytes; - *stat_rx_pdcp_sdu = rlcP->stat_rx_pdcp_sdu; - *stat_rx_pdcp_bytes = rlcP->stat_rx_pdcp_bytes; - *stat_rx_data_pdus_duplicate = rlcP->stat_rx_data_pdus_duplicate; - *stat_rx_data_bytes_duplicate = rlcP->stat_rx_data_bytes_duplicate; - *stat_rx_data_pdu = rlcP->stat_rx_data_pdu; - *stat_rx_data_bytes = rlcP->stat_rx_data_bytes; - *stat_rx_data_pdu_dropped = rlcP->stat_rx_data_pdu_dropped; - *stat_rx_data_bytes_dropped = rlcP->stat_rx_data_bytes_dropped; - *stat_rx_data_pdu_out_of_window = rlcP->stat_rx_data_pdu_out_of_window; - *stat_rx_data_bytes_out_of_window = rlcP->stat_rx_data_bytes_out_of_window; - *stat_timer_reordering_timed_out = rlcP->stat_timer_reordering_timed_out; + *stat_tx_pdcp_sdu = rlc_pP->stat_tx_pdcp_sdu; + *stat_tx_pdcp_bytes = rlc_pP->stat_tx_pdcp_bytes; + *stat_tx_pdcp_sdu_discarded = rlc_pP->stat_tx_pdcp_sdu_discarded; + *stat_tx_pdcp_bytes_discarded = rlc_pP->stat_tx_pdcp_bytes_discarded; + *stat_tx_data_pdu = rlc_pP->stat_tx_data_pdu; + *stat_tx_data_bytes = rlc_pP->stat_tx_data_bytes; + *stat_rx_pdcp_sdu = rlc_pP->stat_rx_pdcp_sdu; + *stat_rx_pdcp_bytes = rlc_pP->stat_rx_pdcp_bytes; + *stat_rx_data_pdus_duplicate = rlc_pP->stat_rx_data_pdus_duplicate; + *stat_rx_data_bytes_duplicate = rlc_pP->stat_rx_data_bytes_duplicate; + *stat_rx_data_pdu = rlc_pP->stat_rx_data_pdu; + *stat_rx_data_bytes = rlc_pP->stat_rx_data_bytes; + *stat_rx_data_pdu_dropped = rlc_pP->stat_rx_data_pdu_dropped; + *stat_rx_data_bytes_dropped = rlc_pP->stat_rx_data_bytes_dropped; + *stat_rx_data_pdu_out_of_window = rlc_pP->stat_rx_data_pdu_out_of_window; + *stat_rx_data_bytes_out_of_window = rlc_pP->stat_rx_data_bytes_out_of_window; + *stat_timer_reordering_timed_out = rlc_pP->stat_timer_reordering_timed_out; } //----------------------------------------------------------------------------- u32_t -rlc_um_get_buffer_occupancy (rlc_um_entity_t *rlcP) +rlc_um_get_buffer_occupancy (rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- - if (rlcP->buffer_occupancy > 0) { - return rlcP->buffer_occupancy; + if (rlc_pP->buffer_occupancy > 0) { + return rlc_pP->buffer_occupancy; } else { return 0; } } //----------------------------------------------------------------------------- void -rlc_um_get_pdus (void *argP,u32_t frame) +rlc_um_get_pdus (void *argP, frame_t frameP) { //----------------------------------------------------------------------------- - rlc_um_entity_t *rlc = (rlc_um_entity_t *) argP; + rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) argP; - switch (rlc->protocol_state) { + switch (rlc_p->protocol_state) { case RLC_NULL_STATE: // from 3GPP TS 25.322 V9.2.0 p43 @@ -139,11 +139,11 @@ rlc_um_get_pdus (void *argP,u32_t frame) // - enters the LOCAL_SUSPEND state. // SEND DATA TO MAC - if (rlc->tx_sn_length == 10) { - rlc_um_segment_10 (rlc,frame); + if (rlc_p->tx_sn_length == 10) { + rlc_um_segment_10 (rlc_p,frameP); } - if (rlc->tx_sn_length == 5) { - rlc_um_segment_5 (rlc,frame); + if (rlc_p->tx_sn_length == 5) { + rlc_um_segment_5 (rlc_p,frameP); } break; @@ -169,13 +169,19 @@ rlc_um_get_pdus (void *argP,u32_t frame) break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_REQ UNKNOWN PROTOCOL STATE %02X hex\n", rlc->module_id, rlc->rb_id, frame, rlc->protocol_state); + LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_REQ UNKNOWN PROTOCOL STATE %02X hex\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + rlc_p->protocol_state); } } //----------------------------------------------------------------------------- void -rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP) +rlc_um_rx (void *argP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) argP; @@ -200,19 +206,19 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP // establishment, the RLC entity: // - is created; and // - enters the DATA_TRANSFER_READY state. - LOG_N(RLC, "[RLC_UM][MOD %d] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", l_rlc_p->module_id); + LOG_N(RLC, "[RLC_UM][MOD %02u/%02u] ERROR MAC_DATA_IND IN RLC_NULL_STATE\n", l_rlc_p->enb_module_id, l_rlc_p->ue_module_id); /*if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame, data_indP.data.nb_elements); - rlc[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", - frame, + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frameP, data_indP.data.nb_elements); + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc_p[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", + frameP, (l_rlc_p->is_enb) ? "eNB":"UE", l_rlc_p->module_id, data_indP.data.nb_elements); tb = data_indP.data.head; while (tb != NULL) { - rlc[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length], " SN %d %c%c%c %d Bytes ", + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " SN %d %c%c%c %d Bytes ", (((struct mac_tb_ind *) (tb->data))->data_ptr[1]) + (((u16_t)((((struct mac_tb_ind *) (tb->data))->data_ptr[0]) & 0x03)) << 8), (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x10) ? '}':'{', (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x08) ? '{':'}', @@ -220,12 +226,12 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP ((struct mac_tb_ind *) (tb->data))->size); tb = tb->next; } - rlc[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length], " DROPPED RLC NULL STATE ---X][RLC_UM][MOD %02d][RB %02d]\n", + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " DROPPED RLC NULL STATE ---X][RLC_UM][MOD %02d][RB %02d]\n", l_rlc_p->module_id, l_rlc_p->rb_id); - rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length] = 0; - LOG_D(RLC, "%s", rlc[l_rlc_p->module_id].m_mscgen_trace); + rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length] = 0; + LOG_D(RLC, "%s", rlc_p[l_rlc_p->module_id].m_mscgen_trace); }*/ list_free (&data_indP.data); break; @@ -250,13 +256,19 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP #ifdef TRACE_RLC_UM_PDU if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame, data_indP.data.nb_elements); + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_IND %d TBs\n", + frameP, + (l_rlc_p->is_enb) ? "eNB" : "UE", + l_rlc_p->enb_module_id, + l_rlc_p->ue_module_id, + l_rlc_p->rb_id, + data_indP.data.nb_elements); tb_p = data_indP.data.head; while (tb_p != NULL) { tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; - rlc_um_get_pdu_infos(frame,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); + rlc_um_get_pdu_infos(frameP,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -315,7 +327,7 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP } } #endif - rlc_um_receive (l_rlc_p, frame, eNB_flag, data_indP); + rlc_um_receive (l_rlc_p, frameP, eNB_flagP, data_indP); break; case RLC_LOCAL_SUSPEND_STATE: @@ -335,18 +347,23 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP // - stays in the LOCAL_SUSPEND state; // - modifies only the protocol parameters and timers as indicated by // upper layers. - LOG_N(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RLC_LOCAL_SUSPEND_STATE\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame); + LOG_N(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC_LOCAL_SUSPEND_STATE\n", + frameP, + (l_rlc_p->is_enb) ? "eNB" : "UE", + l_rlc_p->enb_module_id, + l_rlc_p->ue_module_id, + l_rlc_p->rb_id); /*if (data_indP.data.nb_elements > 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame, data_indP.data.nb_elements); - rlc[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", - frame, + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_IND %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frameP, data_indP.data.nb_elements); + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length = sprintf(rlc_p[l_rlc_p->module_id].m_mscgen_trace, "[MSC_MSG][FRAME %05d][MAC_%s][MOD %02d][][--- MAC_DATA_IND/ %d TB(s) ", + frameP, (l_rlc_p->is_enb) ? "eNB":"UE", l_rlc_p->module_id, data_indP.data.nb_elements); tb = data_indP.data.head; while (tb != NULL) { - rlc[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length], " SN %d %c%c%c %d Bytes ", + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " SN %d %c%c%c %d Bytes ", (((struct mac_tb_ind *) (tb->data))->data_ptr[1]) + (((u16_t)((((struct mac_tb_ind *) (tb->data))->data_ptr[0]) & 0x03)) << 8), (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x10) ? '}':'{', (((struct mac_tb_ind *) (tb->data))->data_ptr[0] & 0x08) ? '{':'}', @@ -354,57 +371,63 @@ rlc_um_rx (void *argP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP ((struct mac_tb_ind *) (tb->data))->size); tb = tb->next; } - rlc[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length], " DROPPED RLC LOCAL SUSPEND STATE ---X][RLC_UM][MOD %02d][RB %02d]\n", + rlc_p[l_rlc_p->module_id].m_mscgen_trace_length += sprintf(&rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length], " DROPPED RLC LOCAL SUSPEND STATE ---X][RLC_UM][MOD %02d][RB %02d]\n", l_rlc_p->module_id, l_rlc_p->rb_id); - rlc[l_rlc_p->module_id].m_mscgen_trace[rlc[l_rlc_p->module_id].m_mscgen_trace_length] = 0; - LOG_D(RLC, "%s", rlc[l_rlc_p->module_id].m_mscgen_trace); + rlc_p[l_rlc_p->module_id].m_mscgen_trace[rlc_p[l_rlc_p->module_id].m_mscgen_trace_length] = 0; + LOG_D(RLC, "%s", rlc_p[l_rlc_p->module_id].m_mscgen_trace); }*/ list_free (&data_indP.data); break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TX UNKNOWN PROTOCOL STATE %02X hex\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame, l_rlc_p->protocol_state); + LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] TX UNKNOWN PROTOCOL STATE %02X hex\n", + frameP, + (l_rlc_p->is_enb) ? "eNB" : "UE", + l_rlc_p->enb_module_id, + l_rlc_p->ue_module_id, + l_rlc_p->rb_id, + l_rlc_p->protocol_state); } } //----------------------------------------------------------------------------- struct mac_status_resp -rlc_um_mac_status_indication (void *rlcP, u32_t frame, u8_t eNB_flag, u16_t tbs_sizeP, struct mac_status_ind tx_statusP) +rlc_um_mac_status_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, u16_t tbs_sizeP, struct mac_status_ind tx_statusP) { //----------------------------------------------------------------------------- struct mac_status_resp status_resp; u16_t sdu_size = 0; u16_t sdu_remaining_size = 0; s32_t diff_time=0; - rlc_um_entity_t *rlc = NULL; + rlc_um_entity_t *rlc_p = NULL; status_resp.buffer_occupancy_in_pdus = 0; status_resp.buffer_occupancy_in_bytes = 0; status_resp.head_sdu_remaining_size_to_send = 0; status_resp.head_sdu_creation_time = 0; status_resp.head_sdu_is_segmented = 0; - status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlcP)->protocol_state; + status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state; - if (rlcP) { - rlc = (rlc_um_entity_t *) rlcP; - rlc_um_check_timer_dar_time_out(rlc,frame,eNB_flag); + if (rlc_pP) { + rlc_p = (rlc_um_entity_t *) rlc_pP; + rlc_um_check_timer_dar_time_out(rlc_p,frameP,eNB_flagP); - rlc->nb_bytes_requested_by_mac = tbs_sizeP; + rlc_p->nb_bytes_requested_by_mac = tbs_sizeP; - status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy (rlc); + status_resp.buffer_occupancy_in_bytes = rlc_um_get_buffer_occupancy (rlc_p); if (status_resp.buffer_occupancy_in_bytes > 0) { - status_resp.buffer_occupancy_in_bytes += rlc->tx_header_min_length_in_bytes; - status_resp.buffer_occupancy_in_pdus = rlc->nb_sdu; + status_resp.buffer_occupancy_in_bytes += rlc_p->tx_header_min_length_in_bytes; + status_resp.buffer_occupancy_in_pdus = rlc_p->nb_sdu; - diff_time = frame - ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index])->data)->sdu_creation_time; - status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (u32_t) diff_time : (u32_t)(0xffffffff - diff_time + frame) ; - //msg("rlc status for frame %d diff time %d resp %d\n", frame, diff_time,status_resp.head_sdu_creation_time) ; + diff_time = frameP - ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_creation_time; + status_resp.head_sdu_creation_time = (diff_time > 0 ) ? (u32_t) diff_time : (u32_t)(0xffffffff - diff_time + frameP) ; + //msg("rlc_p status for frameP %d diff time %d resp %d\n", frameP, diff_time,status_resp.head_sdu_creation_time) ; - sdu_size = ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index])->data)->sdu_size; - sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) (rlc->input_sdus[rlc->current_sdu_index])->data)->sdu_remaining_size; + sdu_size = ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_size; + sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) (rlc_p->input_sdus[rlc_p->current_sdu_index])->data)->sdu_remaining_size; status_resp.head_sdu_remaining_size_to_send = sdu_remaining_size; if (sdu_size == sdu_remaining_size) { @@ -416,17 +439,37 @@ rlc_um_mac_status_indication (void *rlcP, u32_t frame, u8_t eNB_flag, u16_t tbs_ } else { } - //msg("[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_STATUS_INDICATION BO = %d\n", ((rlc_um_entity_t *) rlcP)->module_id, ((rlc_um_entity_t *) rlcP)->rb_id, status_resp.buffer_occupancy_in_bytes); + //msg("[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION BO = %d\n", ((rlc_um_entity_t *) rlc_pP)->module_id, ((rlc_um_entity_t *) rlc_pP)->rb_id, status_resp.buffer_occupancy_in_bytes); - status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlcP)->protocol_state; + status_resp.rlc_info.rlc_protocol_state = ((rlc_um_entity_t *) rlc_pP)->protocol_state; #ifdef DEBUG_RLC_UM_TX_STATUS - if ((((rlc_um_entity_t *) rlcP)->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", ((rlc_um_entity_t *) rlcP)->module_id, ((rlc_um_entity_t *) rlcP)->rb_id, frame, tbs_sizeP, status_resp.buffer_occupancy_in_bytes); + if ((((rlc_um_entity_t *) rlc_pP)->rb_id > 0) && (status_resp.buffer_occupancy_in_bytes > 0)) { + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION (DATA) %d bytes -> %d bytes\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + tbs_sizeP, + status_resp.buffer_occupancy_in_bytes); + if ((tx_statusP.tx_status == MAC_TX_STATUS_SUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n",((rlc_um_entity_t *) rlcP)->module_id, ((rlc_um_entity_t *) rlcP)->rb_id, frame, tx_statusP.no_pdu); + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION TX STATUS SUCCESSFUL %d PDUs\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + tx_statusP.no_pdu); } if ((tx_statusP.tx_status == MAC_TX_STATUS_UNSUCCESSFUL) && (tx_statusP.no_pdu)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n",((rlc_um_entity_t *) rlcP)->module_id, ((rlc_um_entity_t *) rlcP)->rb_id, frame, tx_statusP.no_pdu); + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_STATUS_INDICATION TX STATUS UNSUCCESSFUL %d PDUs\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + tx_statusP.no_pdu); } } #endif @@ -438,7 +481,7 @@ rlc_um_mac_status_indication (void *rlcP, u32_t frame, u8_t eNB_flag, u16_t tbs_ //----------------------------------------------------------------------------- struct mac_data_req -rlc_um_mac_data_request (void *rlcP,u32 frame) +rlc_um_mac_data_request (void *rlc_pP,frame_t frameP) { //----------------------------------------------------------------------------- struct mac_data_req data_req; @@ -452,9 +495,9 @@ rlc_um_mac_data_request (void *rlcP,u32 frame) rlc_um_pdu_info_t pdu_info; int octet_index, index; #endif - rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) rlcP; + rlc_um_entity_t *l_rlc_p = (rlc_um_entity_t *) rlc_pP; - rlc_um_get_pdus (rlcP,frame); + rlc_um_get_pdus (rlc_pP,frameP); list_init (&data_req.data, NULL); list_add_list (&l_rlc_p->pdus_to_mac_layer, &data_req.data); @@ -466,16 +509,16 @@ rlc_um_mac_data_request (void *rlcP,u32 frame) } data_req.rlc_info.rlc_protocol_state = l_rlc_p->protocol_state; if (data_req.data.nb_elements > 0) { - //LOG_I(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_REQUEST %d TBs\n", l_rlc_p->module_id, l_rlc_p->rb_id, frame, data_req.data.nb_elements); - tb_p = data_req.data.head; while (tb_p != NULL) { tb_size_in_bytes = ((struct mac_tb_req *) (tb_p->data))->tb_size; - LOG_I(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] MAC_DATA_REQUEST TB SIZE %u\n", - l_rlc_p->module_id, + LOG_I(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] MAC_DATA_REQUEST TB SIZE %u\n", + frameP, + (l_rlc_p->is_enb) ? "eNB" : "UE", + l_rlc_p->enb_module_id, + l_rlc_p->ue_module_id, l_rlc_p->rb_id, - frame, ((struct mac_tb_req *) (tb_p->data))->tb_size); l_rlc_p->stat_tx_data_pdu += 1; l_rlc_p->stat_tx_data_bytes += tb_size_in_bytes; @@ -483,7 +526,7 @@ rlc_um_mac_data_request (void *rlcP,u32 frame) AssertFatal( tb_size_in_bytes > 0 , "RLC UM PDU LENGTH %d", tb_size_in_bytes); #ifdef TRACE_RLC_UM_PDU - rlc_um_get_pdu_infos(frame,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); + rlc_um_get_pdu_infos(frameP,(rlc_um_pdu_sn_10_t*) ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size_in_bytes, &pdu_info, l_rlc_p->rx_sn_length); message_string_size += sprintf(&message_string[message_string_size], "Bearer : %u\n", l_rlc_p->rb_id); message_string_size += sprintf(&message_string[message_string_size], "PDU size : %u\n", tb_size_in_bytes); message_string_size += sprintf(&message_string[message_string_size], "Header size : %u\n", pdu_info.header_size); @@ -546,34 +589,36 @@ rlc_um_mac_data_request (void *rlcP,u32 frame) //----------------------------------------------------------------------------- void -rlc_um_mac_data_indication (void *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP) +rlc_um_mac_data_indication (void *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - rlc_um_rx (rlcP, frame, eNB_flag, data_indP); - rlc_um_check_timer_dar_time_out(rlcP,frame,eNB_flag); + rlc_um_rx (rlc_pP, frameP, eNB_flagP, data_indP); + rlc_um_check_timer_dar_time_out(rlc_pP,frameP,eNB_flagP); } //----------------------------------------------------------------------------- void -rlc_um_data_req (void *rlcP, u32_t frame, mem_block_t *sduP) +rlc_um_data_req (void *rlc_pP, frame_t frameP, mem_block_t *sdu_pP) { //----------------------------------------------------------------------------- - rlc_um_entity_t *rlc = (rlc_um_entity_t *) rlcP; + rlc_um_entity_t *rlc_p = (rlc_um_entity_t *) rlc_pP; #ifndef USER_MODE unsigned long int rlc_um_time_us; int min, sec, usec; #endif - LOG_I(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", - rlc->module_id, - rlc->rb_id, - frame, - ((struct rlc_um_data_req *) (sduP->data))->data_size, - rlc->buffer_occupancy, - rlc->nb_sdu, - rlc->current_sdu_index, - rlc->next_sdu_index); + LOG_I(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC_UM_DATA_REQ size %d Bytes, BO %d , NB SDU %d current_sdu_index=%d next_sdu_index=%d\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id, + ((struct rlc_um_data_req *) (sdu_pP->data))->data_size, + rlc_p->buffer_occupancy, + rlc_p->nb_sdu, + rlc_p->current_sdu_index, + rlc_p->next_sdu_index); /*#ifndef USER_MODE rlc_um_time_us = (unsigned long int)(rt_get_time_ns ()/(RTIME)1000); @@ -581,30 +626,43 @@ rlc_um_data_req (void *rlcP, u32_t frame, mem_block_t *sduP) min = (sec / 60) % 60; sec = sec % 60; usec = rlc_um_time_us % 1000000; - msg ("[RLC_UM_LITE][RB %d] at time %2d:%2d.%6d\n", rlc->rb_id, min, sec , usec); + msg ("[RLC_UM_LITE][RB %d] at time %2d:%2d.%6d\n", rlc_p->rb_id, min, sec , usec); #endif*/ - if (rlc->input_sdus[rlc->next_sdu_index] == NULL) { - rlc->input_sdus[rlc->next_sdu_index] = sduP; + if (rlc_p->input_sdus[rlc_p->next_sdu_index] == NULL) { + rlc_p->input_sdus[rlc_p->next_sdu_index] = sdu_pP; // IMPORTANT : do not change order of affectations - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size = ((struct rlc_um_data_req *) (sduP->data))->data_size; - rlc->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; - rlc->nb_sdu += 1; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->first_byte = (u8_t*)&sduP->data[sizeof (struct rlc_um_data_req_alloc)]; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) - (sduP->data))->sdu_size; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_segmented_size = 0; - ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_creation_time = frame; - rlc->next_sdu_index = (rlc->next_sdu_index + 1) % rlc->size_input_sdus_buffer; - - rlc->stat_tx_pdcp_sdu += 1; - rlc->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; + ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size = ((struct rlc_um_data_req *) (sdu_pP->data))->data_size; + rlc_p->buffer_occupancy += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; + rlc_p->nb_sdu += 1; + ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->first_byte = (u8_t*)&sdu_pP->data[sizeof (struct rlc_um_data_req_alloc)]; + ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_remaining_size = ((struct rlc_um_tx_sdu_management *) + (sdu_pP->data))->sdu_size; + ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_segmented_size = 0; + ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_creation_time = frameP; + rlc_p->next_sdu_index = (rlc_p->next_sdu_index + 1) % rlc_p->size_input_sdus_buffer; + + rlc_p->stat_tx_pdcp_sdu += 1; + rlc_p->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; } else { - LOG_W(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RLC-UM_DATA_REQ input buffer full SDU garbaged\n",rlc->module_id, rlc->rb_id, frame); - rlc->stat_tx_pdcp_sdu += 1; - rlc->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; - rlc->stat_tx_pdcp_sdu_discarded += 1; - rlc->stat_tx_pdcp_bytes_discarded += ((struct rlc_um_tx_sdu_management *) (sduP->data))->sdu_size; - free_mem_block (sduP); + LOG_W(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02u/%02u][RB %02d] RLC-UM_DATA_REQ input buffer full SDU garbaged\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id); + rlc_p->stat_tx_pdcp_sdu += 1; + rlc_p->stat_tx_pdcp_bytes += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; + rlc_p->stat_tx_pdcp_sdu_discarded += 1; + rlc_p->stat_tx_pdcp_bytes_discarded += ((struct rlc_um_tx_sdu_management *) (sdu_pP->data))->sdu_size; + free_mem_block (sdu_pP); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_AM][MOD %u/%u][RB %u] RLC_UM_DATA_REQ, SDU DROPPED, INPUT BUFFER OVERFLOW\n", + frameP, + (rlc_p->is_enb) ? "eNB" : "UE", + rlc_p->enb_module_id, + rlc_p->ue_module_id, + rlc_p->rb_id); +#endif } } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c index a27ffdcfcd78b58e2fa85cdcc1ea4fd4c41cd6ab..963123f0c2ef48458239df9fed18ebdaa03dcb98 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.c @@ -25,7 +25,7 @@ Openair Tech : openair_tech@eurecom.fr Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ #define RLC_UM_MODULE #define RLC_UM_CONTROL_PRIMITIVES_C //#include "rtos_header.h" @@ -42,270 +42,344 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "T-Reordering.h" //----------------------------------------------------------------------------- -void config_req_rlc_um (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_um_info_t * config_umP, rb_id_t rb_idP, rb_type_t rb_typeP) +void config_req_rlc_um (frame_t frameP, + eNB_flag_t eNB_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + rlc_um_info_t *config_um_pP, + rb_id_t rb_idP, + rb_type_t rb_typeP) { - //----------------------------------------------------------------------------- - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_%s][MOD %02d][][--- CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d --->][RLC_UM][MOD %02d][RB %02d] \n", - frame, - ( eNB_flagP == 1) ? "eNB":"UE", - module_idP, - config_umP->timer_reordering, - config_umP->sn_field_length, - config_umP->is_mXch, - module_idP, - rb_idP); - rlc_um_init(rlcP); - if (rlc_um_fsm_notify_event (rlcP, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(rlcP, frame, eNB_flagP, module_idP, rb_idP, rb_typeP); - rlc_um_configure(rlcP, - frame, - config_umP->timer_reordering, - config_umP->sn_field_length, - config_umP->sn_field_length, - config_umP->is_mXch); - } + //----------------------------------------------------------------------------- + rlc_um_entity_t *rlc = NULL; + + if (eNB_flagP) { + rlc = &rlc_array_eNB[enb_module_idP][ue_module_idP][rb_idP].rlc.um; + } else { + rlc = &rlc_array_ue[ue_module_idP][rb_idP].rlc.um; + } + LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ timer_reordering=%d sn_field_length=%d is_mXch=%d --->][RLC_UM][MOD %u/%u][RB %u] \n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_module_idP, + ue_module_idP, + config_um_pP->timer_reordering, + config_um_pP->sn_field_length, + config_um_pP->is_mXch, + enb_module_idP, + ue_module_idP, + rb_idP); + + rlc_um_init(rlc); + if (rlc_um_fsm_notify_event (rlc, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { + rlc_um_set_debug_infos(rlc, frame, eNB_flagP, enb_module_idP, ue_module_idP, rb_idP, rb_typeP); + rlc_um_configure(rlc, + frame, + config_um_pP->timer_reordering, + config_um_pP->sn_field_length, + config_um_pP->sn_field_length, + config_um_pP->is_mXch); + } } //----------------------------------------------------------------------------- u32_t t_Reordering_tab[T_Reordering_spare1] = {0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,110,120,130,140,150,160,170,180,190,200}; -void config_req_rlc_um_asn1 (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, u8_t mbms_flagP, module_id_t module_idP, UL_UM_RLC_t* ul_rlcP, DL_UM_RLC_t* dl_rlcP, rb_id_t rb_idP, rb_type_t rb_typeP) +void config_req_rlc_um_asn1 (frame_t frameP, + eNB_flag_t eNB_flagP, + u8_t mbms_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + UL_UM_RLC_t *ul_rlc_pP, + DL_UM_RLC_t *dl_rlc_pP, + rb_id_t rb_idP, + rb_type_t rb_typeP) { - u32_t ul_sn_FieldLength = 0; - u32_t dl_sn_FieldLength = 0; - u32_t t_Reordering; + u32_t ul_sn_FieldLength = 0; + u32_t dl_sn_FieldLength = 0; + u32_t t_Reordering; + rlc_um_entity_t *rlc = NULL; + + if (eNB_flagP) { + rlc = &rlc_array_eNB[enb_module_idP][ue_module_idP][rb_idP].rlc.um; + } else { + rlc = &rlc_array_ue[ue_module_idP][rb_idP].rlc.um; + } //----------------------------------------------------------------------------- - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_%s][MOD %02d][][--- CONFIG_REQ timer_reordering=%dms sn_field_length= --->][RLC_UM][MOD %02d][RB %02d] \n", - frame, - ( eNB_flagP == 1) ? "eNB":"UE", - module_idP, - (dl_rlcP->t_Reordering<31)?t_Reordering_tab[dl_rlcP->t_Reordering]:-1, - // (ul_rlcP->sn_FieldLength<2)?(5*(1+ul_rlcP->sn_FieldLength)):-1, - module_idP, - rb_idP); - - rlc_um_init(rlcP); - if (rlc_um_fsm_notify_event (rlcP, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { - rlc_um_set_debug_infos(rlcP, frame, eNB_flagP, module_idP, rb_idP, rb_typeP); - if (ul_rlcP != NULL) { - switch (ul_rlcP->sn_FieldLength) { + LOG_D(RLC, "[FRAME %05d][%s][RRC][MOD %u/%u][][--- CONFIG_REQ timer_reordering=%dms sn_field_length= --->][RLC_UM][MOD %u/%u][RB %u] \n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_module_idP, + ue_module_idP, + (dl_rlc_pP->t_Reordering<31)?t_Reordering_tab[dl_rlc_pP->t_Reordering]:-1, + enb_module_idP, + ue_module_idP, + rb_idP); + + rlc_um_init(rlc); + if (rlc_um_fsm_notify_event (rlc, RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT)) { + rlc_um_set_debug_infos(rlc, frame, eNB_flagP, enb_module_idP, ue_module_idP, rb_idP, rb_typeP); + if (ul_rlc_pP != NULL) { + switch (ul_rlc_pP->sn_FieldLength) { case SN_FieldLength_size5: - ul_sn_FieldLength = 5; - break; + ul_sn_FieldLength = 5; + break; case SN_FieldLength_size10: - ul_sn_FieldLength = 10; - break; + ul_sn_FieldLength = 10; + break; default: - LOG_E(RLC,"[FRAME %05d][RLC_UM][MOD %02d][RB %02d][CONFIGURE] INVALID Uplink sn_FieldLength %d, RLC NOT CONFIGURED\n", - frame, rlcP->module_id, rlcP->rb_id, ul_rlcP->sn_FieldLength); - return; + LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID Uplink sn_FieldLength %d, RLC NOT CONFIGURED\n", + frame, + (rlc->is_enb) ? "eNB" : "UE", + rlc->enb_module_id, + rlc->ue_module_id, + rlc->rb_id, + ul_rlc_pP->sn_FieldLength); + return; } } - - if (dl_rlcP != NULL) { - switch (dl_rlcP->sn_FieldLength) { + + if (dl_rlc_pP != NULL) { + switch (dl_rlc_pP->sn_FieldLength) { case SN_FieldLength_size5: - dl_sn_FieldLength = 5; - break; + dl_sn_FieldLength = 5; + break; case SN_FieldLength_size10: - dl_sn_FieldLength = 10; - break; + dl_sn_FieldLength = 10; + break; default: - LOG_E(RLC,"[FRAME %05d][RLC_UM][MOD %02d][RB %02d][CONFIGURE] INVALID Downlink sn_FieldLength %d, RLC NOT CONFIGURED\n", - frame, rlcP->module_id, rlcP->rb_id, dl_rlcP->sn_FieldLength); - return; + LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID Downlink sn_FieldLength %d, RLC NOT CONFIGURED\n", + frame, + (rlc->is_enb) ? "eNB" : "UE", + rlc->enb_module_id, + rlc->ue_module_id, + rlc->rb_id, + dl_rlc_pP->sn_FieldLength); + return; } - if (dl_rlcP->t_Reordering<T_Reordering_spare1) { - t_Reordering = t_Reordering_tab[dl_rlcP->t_Reordering]; + if (dl_rlc_pP->t_Reordering<T_Reordering_spare1) { + t_Reordering = t_Reordering_tab[dl_rlc_pP->t_Reordering]; } else { - LOG_E(RLC,"[FRAME %05d][RLC_UM][MOD %02d][RB %02d][CONFIGURE] INVALID T_Reordering %d, RLC NOT CONFIGURED\n", - frame, rlcP->module_id, rlcP->rb_id, dl_rlcP->t_Reordering); - return; + LOG_E(RLC,"[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID T_Reordering %d, RLC NOT CONFIGURED\n", + frame, + (rlc->is_enb) ? "eNB" : "UE", + rlc->enb_module_id, + rlc->ue_module_id, + rlc->rb_id, + dl_rlc_pP->t_Reordering); + return; } } if (eNB_flagP > 0) { - rlc_um_configure(rlcP, - frame, - t_Reordering, - ul_sn_FieldLength, - dl_sn_FieldLength, - mbms_flagP); + rlc_um_configure(rlc, + frame, + t_Reordering, + ul_sn_FieldLength, + dl_sn_FieldLength, + mbms_flagP); } else { - rlc_um_configure(rlcP, - frame, - t_Reordering, - dl_sn_FieldLength, - ul_sn_FieldLength, - mbms_flagP); + rlc_um_configure(rlc, + frame, + t_Reordering, + dl_sn_FieldLength, + ul_sn_FieldLength, + mbms_flagP); } - } + } } //----------------------------------------------------------------------------- void -rlc_um_init (rlc_um_entity_t *rlcP) +rlc_um_init (rlc_um_entity_t *rlc_pP) { -//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- - int saved_allocation = rlcP->allocation; - memset (rlcP, 0, sizeof (rlc_um_entity_t)); - rlcP->allocation = saved_allocation; + int saved_allocation = rlc_pP->allocation; + memset (rlc_pP, 0, sizeof (rlc_um_entity_t)); + rlc_pP->allocation = saved_allocation; // TX SIDE - list_init (&rlcP->pdus_to_mac_layer, NULL); + list_init (&rlc_pP->pdus_to_mac_layer, NULL); - rlcP->protocol_state = RLC_NULL_STATE; - //rlcP->nb_sdu = 0; - //rlcP->next_sdu_index = 0; - //rlcP->current_sdu_index = 0; + rlc_pP->protocol_state = RLC_NULL_STATE; + //rlc_pP->nb_sdu = 0; + //rlc_pP->next_sdu_index = 0; + //rlc_pP->current_sdu_index = 0; - //rlcP->vt_us = 0; + //rlc_pP->vt_us = 0; // RX SIDE - list_init (&rlcP->pdus_from_mac_layer, NULL); - //rlcP->vr_ur = 0; - //rlcP->vr_ux = 0; - //rlcP->vr_uh = 0; - //rlcP->output_sdu_size_to_write = 0; - //rlcP->output_sdu_in_construction = NULL; - - rlcP->rx_sn_length = 10; - rlcP->rx_header_min_length_in_bytes = 2; - rlcP->tx_sn_length = 10; - rlcP->tx_header_min_length_in_bytes = 2; + list_init (&rlc_pP->pdus_from_mac_layer, NULL); + //rlc_pP->vr_ur = 0; + //rlc_pP->vr_ux = 0; + //rlc_pP->vr_uh = 0; + //rlc_pP->output_sdu_size_to_write = 0; + //rlc_pP->output_sdu_in_construction = NULL; + + rlc_pP->rx_sn_length = 10; + rlc_pP->rx_header_min_length_in_bytes = 2; + rlc_pP->tx_sn_length = 10; + rlc_pP->tx_header_min_length_in_bytes = 2; // SPARE : not 3GPP - rlcP->size_input_sdus_buffer =128; + rlc_pP->size_input_sdus_buffer =128; - if ((rlcP->input_sdus_alloc == NULL) && (rlcP->size_input_sdus_buffer > 0)) { - rlcP->input_sdus_alloc = get_free_mem_block (rlcP->size_input_sdus_buffer * sizeof (void *)); - rlcP->input_sdus = (mem_block_t **) (rlcP->input_sdus_alloc->data); - memset (rlcP->input_sdus, 0, rlcP->size_input_sdus_buffer * sizeof (void *)); + if ((rlc_pP->input_sdus_alloc == NULL) && (rlc_pP->size_input_sdus_buffer > 0)) { + rlc_pP->input_sdus_alloc = get_free_mem_block (rlc_pP->size_input_sdus_buffer * sizeof (void *)); + rlc_pP->input_sdus = (mem_block_t **) (rlc_pP->input_sdus_alloc->data); + memset (rlc_pP->input_sdus, 0, rlc_pP->size_input_sdus_buffer * sizeof (void *)); } - if (rlcP->dar_buffer_alloc == NULL) { - rlcP->dar_buffer_alloc = get_free_mem_block (1024 * sizeof (void *)); - rlcP->dar_buffer = (mem_block_t **) (rlcP->dar_buffer_alloc->data); - memset (rlcP->dar_buffer, 0, 1024 * sizeof (void *)); + if (rlc_pP->dar_buffer_alloc == NULL) { + rlc_pP->dar_buffer_alloc = get_free_mem_block (1024 * sizeof (void *)); + rlc_pP->dar_buffer = (mem_block_t **) (rlc_pP->dar_buffer_alloc->data); + memset (rlc_pP->dar_buffer, 0, 1024 * sizeof (void *)); } - rlcP->first_pdu = 1; + rlc_pP->first_pdu = 1; } //----------------------------------------------------------------------------- void -rlc_um_reset_state_variables (rlc_um_entity_t *rlcP) +rlc_um_reset_state_variables (rlc_um_entity_t *rlc_pP) { -//----------------------------------------------------------------------------- - rlcP->buffer_occupancy = 0; - rlcP->nb_sdu = 0; - rlcP->next_sdu_index = 0; - rlcP->current_sdu_index = 0; + //----------------------------------------------------------------------------- + rlc_pP->buffer_occupancy = 0; + rlc_pP->nb_sdu = 0; + rlc_pP->next_sdu_index = 0; + rlc_pP->current_sdu_index = 0; // TX SIDE - rlcP->vt_us = 0; + rlc_pP->vt_us = 0; // RX SIDE - rlcP->vr_ur = 0; - rlcP->vr_ux = 0; - rlcP->vr_uh = 0; + rlc_pP->vr_ur = 0; + rlc_pP->vr_ux = 0; + rlc_pP->vr_uh = 0; } //----------------------------------------------------------------------------- void -rlc_um_cleanup (rlc_um_entity_t *rlcP) +rlc_um_cleanup (rlc_um_entity_t *rlc_pP) { -//----------------------------------------------------------------------------- + //----------------------------------------------------------------------------- int index; // TX SIDE - list_free (&rlcP->pdus_to_mac_layer); + list_free (&rlc_pP->pdus_to_mac_layer); - if (rlcP->input_sdus_alloc) { - for (index = 0; index < rlcP->size_input_sdus_buffer; index++) { - if (rlcP->input_sdus[index]) { - free_mem_block (rlcP->input_sdus[index]); + if (rlc_pP->input_sdus_alloc) { + for (index = 0; index < rlc_pP->size_input_sdus_buffer; index++) { + if (rlc_pP->input_sdus[index]) { + free_mem_block (rlc_pP->input_sdus[index]); + } } - } - free_mem_block (rlcP->input_sdus_alloc); - rlcP->input_sdus_alloc = NULL; + free_mem_block (rlc_pP->input_sdus_alloc); + rlc_pP->input_sdus_alloc = NULL; } // RX SIDE - list_free (&rlcP->pdus_from_mac_layer); - if ((rlcP->output_sdu_in_construction)) { - free_mem_block (rlcP->output_sdu_in_construction); + list_free (&rlc_pP->pdus_from_mac_layer); + if ((rlc_pP->output_sdu_in_construction)) { + free_mem_block (rlc_pP->output_sdu_in_construction); } - if (rlcP->dar_buffer_alloc) { - for (index = 0; index < 1024; index++) { - if (rlcP->dar_buffer[index]) { - free_mem_block (rlcP->dar_buffer[index]); + if (rlc_pP->dar_buffer_alloc) { + for (index = 0; index < 1024; index++) { + if (rlc_pP->dar_buffer[index]) { + free_mem_block (rlc_pP->dar_buffer[index]); + } } - } - free_mem_block (rlcP->dar_buffer_alloc); - rlcP->dar_buffer_alloc = NULL; + free_mem_block (rlc_pP->dar_buffer_alloc); + rlc_pP->dar_buffer_alloc = NULL; } + memset(rlc_pP, 0, sizeof(rlc_um_entity_t)); } //----------------------------------------------------------------------------- -void rlc_um_configure(rlc_um_entity_t *rlcP, - u32_t frame, - u32_t timer_reorderingP, - u32_t rx_sn_field_lengthP, - u32_t tx_sn_field_lengthP, - u32_t is_mXchP) +void rlc_um_configure(rlc_um_entity_t *rlc_pP, + frame_t frameP, + u32_t timer_reorderingP, + u32_t rx_sn_field_lengthP, + u32_t tx_sn_field_lengthP, + u32_t is_mXchP) //----------------------------------------------------------------------------- { - if (rx_sn_field_lengthP == 10) { - rlcP->rx_sn_length = 10; - rlcP->rx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; - rlcP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; - rlcP->rx_header_min_length_in_bytes = 2; - } else if (rx_sn_field_lengthP == 5) { - rlcP->rx_sn_length = 5; - rlcP->rx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; - rlcP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; - rlcP->rx_header_min_length_in_bytes = 1; - } else if (rx_sn_field_lengthP != 0) { - LOG_E(RLC, "[FRAME %05d][RLC_UM][MOD %02d][RB %02d][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", frame, rlcP->module_id, rlcP->rb_id, rx_sn_field_lengthP); - return; - } - - if (tx_sn_field_lengthP == 10) { - rlcP->tx_sn_length = 10; - rlcP->tx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; - rlcP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; - rlcP->tx_header_min_length_in_bytes = 2; - } else if (tx_sn_field_lengthP == 5) { - rlcP->tx_sn_length = 5; - rlcP->tx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; - rlcP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; - rlcP->tx_header_min_length_in_bytes = 1; - } else if (tx_sn_field_lengthP != 0) { - LOG_E(RLC, "[FRAME %05d][RLC_UM][MOD %02d][RB %02d][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", frame, rlcP->module_id, rlcP->rb_id, tx_sn_field_lengthP); - return; - } - - if (is_mXchP > 0) { - rlcP->tx_um_window_size = 0; - rlcP->rx_um_window_size = 0; - } - rlcP->is_mxch = is_mXchP; - - rlcP->last_reassemblied_sn = rlcP->rx_sn_modulo - 1; - rlcP->last_reassemblied_missing_sn = rlcP->rx_sn_modulo - 1; - rlcP->reassembly_missing_sn_detected = 0; - // timers - rlc_um_init_timer_reordering(rlcP, timer_reorderingP); - - rlcP->first_pdu = 1; - - rlc_um_reset_state_variables (rlcP); + if (rx_sn_field_lengthP == 10) { + rlc_pP->rx_sn_length = 10; + rlc_pP->rx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; + rlc_pP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; + rlc_pP->rx_header_min_length_in_bytes = 2; + } else if (rx_sn_field_lengthP == 5) { + rlc_pP->rx_sn_length = 5; + rlc_pP->rx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; + rlc_pP->rx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; + rlc_pP->rx_header_min_length_in_bytes = 1; + } else if (rx_sn_field_lengthP != 0) { + LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", + frame, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rx_sn_field_lengthP); + return; + } + + if (tx_sn_field_lengthP == 10) { + rlc_pP->tx_sn_length = 10; + rlc_pP->tx_sn_modulo = RLC_UM_SN_10_BITS_MODULO; + rlc_pP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_10_BITS; + rlc_pP->tx_header_min_length_in_bytes = 2; + } else if (tx_sn_field_lengthP == 5) { + rlc_pP->tx_sn_length = 5; + rlc_pP->tx_sn_modulo = RLC_UM_SN_5_BITS_MODULO; + rlc_pP->tx_um_window_size = RLC_UM_WINDOW_SIZE_SN_5_BITS; + rlc_pP->tx_header_min_length_in_bytes = 1; + } else if (tx_sn_field_lengthP != 0) { + LOG_E(RLC, "[FRAME %05d][%s][RLC_UM][MOD %02d/%02][RB %u][CONFIGURE] INVALID RX SN LENGTH %d BITS NOT IMPLEMENTED YET, RLC NOT CONFIGURED\n", + frame, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + tx_sn_field_lengthP); + return; + } + + if (is_mXchP > 0) { + rlc_pP->tx_um_window_size = 0; + rlc_pP->rx_um_window_size = 0; + } + rlc_pP->is_mxch = is_mXchP; + + rlc_pP->last_reassemblied_sn = rlc_pP->rx_sn_modulo - 1; + rlc_pP->last_reassemblied_missing_sn = rlc_pP->rx_sn_modulo - 1; + rlc_pP->reassembly_missing_sn_detected = 0; + // timers + rlc_um_init_timer_reordering(rlc_pP, timer_reorderingP); + + rlc_pP->first_pdu = 1; + + rlc_um_reset_state_variables (rlc_pP); } //----------------------------------------------------------------------------- -void rlc_um_set_debug_infos(rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +void rlc_um_set_debug_infos(rlc_um_entity_t *rlc_pP, + frame_t frameP, + eNB_flag_t eNB_flagP, + module_id_t enb_module_idP, + module_id_t ue_module_idP, + rb_id_t rb_idP, + rb_type_t rb_typeP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_UM][MOD %02d][RB %02d][SET DEBUG INFOS] module_id %d rb_id %d rb_type %d\n", frame, module_idP, rb_idP, module_idP, rb_idP, rb_typeP); - - rlcP->module_id = module_idP; - rlcP->rb_id = rb_idP; - if (rb_typeP != SIGNALLING_RADIO_BEARER) { - rlcP->is_data_plane = 1; - } else { - rlcP->is_data_plane = 0; - } - rlcP->is_enb = eNB_flagP; + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][SET DEBUG INFOS] enb_module_id %u ue_module_id %u rb_id %d rb_type %d\n", + frame, + (rlc_pP->is_enb) ? "eNB" : "UE", + eNB_flagP, + enb_module_idP, + ue_module_idP, + rb_idP, + rb_typeP); + + rlc_pP->enb_module_id = enb_module_idP; + rlc_pP->ue_module_id = ue_module_idP; + rlc_pP->rb_id = rb_idP; + if (rb_typeP != SIGNALLING_RADIO_BEARER) { + rlc_pP->is_data_plane = 1; + } else { + rlc_pP->is_data_plane = 0; + } + rlc_pP->is_enb = eNB_flagP; } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h index c8b79d915503313f6095724b304f0c2f758888fd..ec49a0a387b6b987adfb984f8ddd400c5b149590 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_control_primitives.h @@ -76,31 +76,31 @@ typedef volatile struct { } rlc_um_info_t; -/*! \fn void config_req_rlc_um (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_um_info_t * config_umP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void config_req_rlc_um (frame_t frame, eNB_flag_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_um_info_t * config_umP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Allocate memory for RLC UM instance, reset protocol variables, and set protocol parameters. After this configuration the RLC UM protocol instance will be in RLC_DATA_TRANSFER_READY_STATE state. -* \param[in] rlcP RLC UM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] config_umP Configuration parameters for RLC UM instance. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -public_rlc_um_control_primitives( void config_req_rlc_um (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rlc_um_info_t * config_umP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_um_control_primitives( void config_req_rlc_um (frame_t frame, eNB_flag_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rlc_um_info_t * config_umP, rb_id_t rb_idP, rb_type_t rb_typeP);) -/*! \fn void config_req_rlc_um_asn1 (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, u8_t mbms_flagP, module_id_t module_idP, UL_UM_RLC_t* ul_rlcP, DL_UM_RLC_t* dl_rlcP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void config_req_rlc_um_asn1 (frame_t frame, eNB_flag_t eNB_flagP, u8_t mbms_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, UL_UM_RLC_t* ul_rlcP, DL_UM_RLC_t* dl_rlcP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Allocate memory for RLC UM instance, reset protocol variables, and set protocol parameters. After this configuration the RLC UM protocol instance will be in RLC_DATA_TRANSFER_READY_STATE state. -* \param[in] rlcP RLC UM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) * \param[in] mbms_flagP Flag to indicate if this RLC is configured for MBMS. -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] ul_rlcP Configuration parameters for RLC UM UL instance. * \param[in] dl_rlcP Configuration parameters for RLC UM DL instance. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -public_rlc_um_control_primitives( void config_req_rlc_um_asn1 (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, u8_t mbms_flagP, module_id_t module_idP, UL_UM_RLC_t* ul_rlcP, DL_UM_RLC_t* dl_rlcP, rb_id_t rb_idP, rb_type_t rb_typeP);) +public_rlc_um_control_primitives( void config_req_rlc_um_asn1 (frame_t frame, eNB_flag_t eNB_flagP, u8_t mbms_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, UL_UM_RLC_t* ul_rlcP, DL_UM_RLC_t* dl_rlcP, rb_id_t rb_idP, rb_type_t rb_typeP);) /*! \fn void rlc_um_init (rlc_um_entity_t *rlcP) * \brief Initialize a RLC UM protocol instance, initialize all variables, lists, allocate buffers for making this instance ready to be configured with protocol configuration parameters. After this initialization the RLC UM protocol instance will be in RLC_NULL_STATE state. @@ -120,7 +120,7 @@ protected_rlc_um_control_primitives(void rlc_um_reset_state_variables (rlc_um_en */ public_rlc_um_control_primitives( void rlc_um_cleanup(rlc_um_entity_t *rlcP);) -/*! \fn void rlc_um_configure(rlc_um_entity_t *rlcP, u32_t frame, u32_t timer_reorderingP, u32_t rx_sn_field_lengthP, u32_t tx_sn_field_lengthP, u32_t is_mXchP) +/*! \fn void rlc_um_configure(rlc_um_entity_t *rlcP, frame_t frame, u32_t timer_reorderingP, u32_t rx_sn_field_lengthP, u32_t tx_sn_field_lengthP, u32_t is_mXchP) * \brief Configure RLC UM protocol parameters. * \param[in] rlcP RLC UM protocol instance pointer. * \param[in] frame Frame index. @@ -129,17 +129,18 @@ public_rlc_um_control_primitives( void rlc_um_cleanup(rlc_um_entity_t *rlcP);) * \param[in] tx_sn_field_lengthP Length of the sequence number, 5 or 10 bits in transmission. * \param[in] is_mXchP Is the radio bearer for MCCH, MTCH. */ -protected_rlc_um_control_primitives(void rlc_um_configure(rlc_um_entity_t *rlcP, u32_t frame, u32_t timer_reorderingP, u32_t rx_sn_field_lengthP, u32_t tx_sn_field_lengthP, u32_t is_mXchP);) +protected_rlc_um_control_primitives(void rlc_um_configure(rlc_um_entity_t *rlcP, frame_t frame, u32_t timer_reorderingP, u32_t rx_sn_field_lengthP, u32_t tx_sn_field_lengthP, u32_t is_mXchP);) -/*! \fn void rlc_um_set_debug_infos(rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) +/*! \fn void rlc_um_set_debug_infos(rlc_um_entity_t *rlcP, frame_t frame, u8_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP) * \brief Set debug informations for a RLC UM protocol instance, these informations are only for trace purpose. * \param[in] rlcP RLC UM protocol instance pointer. * \param[in] frame Frame index. * \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_module_idP eNB Virtualized module identifier. +* \param[in] ue_module_idP UE Virtualized module identifier. * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Radio bearer type (Signalling or Data). */ -protected_rlc_um_control_primitives(void rlc_um_set_debug_infos(rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flagP, module_id_t module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) +protected_rlc_um_control_primitives(void rlc_um_set_debug_infos(rlc_um_entity_t *rlcP, frame_t frame, eNB_flag_t eNB_flagP, module_id_t enb_module_idP, module_id_t ue_module_idP, rb_id_t rb_idP, rb_type_t rb_typeP);) /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c index 9381ae399af8c455588e2792bf996a2e92f67c3d..4899814000a861f9600c39d125f525b6b8d7bd9d 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.c @@ -39,105 +39,110 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "MAC_INTERFACE/extern.h" #include "UTIL/LOG/log.h" -#define DEBUG_RLC_UM_RX_DECODE -//#define DEBUG_RLC_UM_RX -//#define DEBUG_DISPLAY_NVIDIA +//#define TRACE_RLC_UM_DAR 1 +#define TRACE_RLC_UM_RX_DECODE +//#define TRACE_RLC_UM_RX 1 +//#define TRACE_DISPLAY_NVIDIA 1 //----------------------------------------------------------------------------- -signed int rlc_um_get_pdu_infos(u32_t frame,rlc_um_pdu_sn_10_t* headerP, s16_t total_sizeP, rlc_um_pdu_info_t* pdu_infoP, u8_t sn_lengthP) +signed int rlc_um_get_pdu_infos(frame_t frameP,rlc_um_pdu_sn_10_t* header_pP, sdu_ssize_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, u8_t sn_lengthP) //----------------------------------------------------------------------------- { - memset(pdu_infoP, 0, sizeof (rlc_um_pdu_info_t)); + sdu_size_t sum_li = 0; + memset(pdu_info_pP, 0, sizeof (rlc_um_pdu_info_t)); - s16_t sum_li = 0; - pdu_infoP->num_li = 0; + pdu_info_pP->num_li = 0; AssertFatal( total_sizeP > 0 , "RLC UM PDU LENGTH %d", total_sizeP); if (sn_lengthP == 10) { - pdu_infoP->fi = (headerP->b1 >> 3) & 0x03; - pdu_infoP->e = (headerP->b1 >> 2) & 0x01; - pdu_infoP->sn = headerP->b2 + (((u16_t)(headerP->b1 & 0x03)) << 8); - pdu_infoP->header_size = 2; - pdu_infoP->payload = &headerP->data[0]; + pdu_info_pP->fi = (header_pP->b1 >> 3) & 0x03; + pdu_info_pP->e = (header_pP->b1 >> 2) & 0x01; + pdu_info_pP->sn = header_pP->b2 + (((u16_t)(header_pP->b1 & 0x03)) << 8); + pdu_info_pP->header_size = 2; + pdu_info_pP->payload = &header_pP->data[0]; } else if (sn_lengthP == 5) { - pdu_infoP->fi = (headerP->b1 >> 6) & 0x03; - pdu_infoP->e = (headerP->b1 >> 5) & 0x01; - pdu_infoP->sn = headerP->b1 & 0x1F; - pdu_infoP->header_size = 1; - pdu_infoP->payload = &headerP->b2; + pdu_info_pP->fi = (header_pP->b1 >> 6) & 0x03; + pdu_info_pP->e = (header_pP->b1 >> 5) & 0x01; + pdu_info_pP->sn = header_pP->b1 & 0x1F; + pdu_info_pP->header_size = 1; + pdu_info_pP->payload = &header_pP->b2; } else { AssertFatal( sn_lengthP == 5 || sn_lengthP == 10, "RLC UM SN LENGTH %d", sn_lengthP); } - if (pdu_infoP->e) { - rlc_am_e_li_t *e_li; + if (pdu_info_pP->e) { + rlc_am_e_li_t *e_li_p; unsigned int li_length_in_bytes = 1; unsigned int li_to_read = 1; - e_li = (rlc_am_e_li_t*)(pdu_infoP->payload); + e_li_p = (rlc_am_e_li_t*)(pdu_info_pP->payload); while (li_to_read) { li_length_in_bytes = li_length_in_bytes ^ 3; if (li_length_in_bytes == 2) { - AssertFatal( total_sizeP >= ((uint64_t)(&e_li->b2) - (uint64_t)headerP), + AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b2) - (uint64_t)header_pP), "DECODING PDU TOO FAR PDU size %d", total_sizeP); - pdu_infoP->li_list[pdu_infoP->num_li] = ((u16_t)(e_li->b1 << 4)) & 0x07F0; - pdu_infoP->li_list[pdu_infoP->num_li] |= (((u8_t)(e_li->b2 >> 4)) & 0x000F); - li_to_read = e_li->b1 & 0x80; - pdu_infoP->header_size += 2; + pdu_info_pP->li_list[pdu_info_pP->num_li] = ((u16_t)(e_li_p->b1 << 4)) & 0x07F0; + pdu_info_pP->li_list[pdu_info_pP->num_li] |= (((u8_t)(e_li_p->b2 >> 4)) & 0x000F); + li_to_read = e_li_p->b1 & 0x80; + pdu_info_pP->header_size += 2; } else { - AssertFatal( total_sizeP >= ((uint64_t)(&e_li->b3) - (uint64_t)headerP), + AssertFatal( total_sizeP >= ((uint64_t)(&e_li_p->b3) - (uint64_t)header_pP), "DECODING PDU TOO FAR PDU size %d", total_sizeP); - pdu_infoP->li_list[pdu_infoP->num_li] = ((u16_t)(e_li->b2 << 8)) & 0x0700; - pdu_infoP->li_list[pdu_infoP->num_li] |= e_li->b3; - li_to_read = e_li->b2 & 0x08; - e_li++; - pdu_infoP->header_size += 1; + pdu_info_pP->li_list[pdu_info_pP->num_li] = ((u16_t)(e_li_p->b2 << 8)) & 0x0700; + pdu_info_pP->li_list[pdu_info_pP->num_li] |= e_li_p->b3; + li_to_read = e_li_p->b2 & 0x08; + e_li_p++; + pdu_info_pP->header_size += 1; } - AssertFatal( pdu_infoP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, "[FRAME %05d][RLC_UM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", frame, pdu_infoP->sn); - sum_li += pdu_infoP->li_list[pdu_infoP->num_li]; - pdu_infoP->num_li = pdu_infoP->num_li + 1; - if (pdu_infoP->num_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { + AssertFatal( pdu_info_pP->num_li <= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU, + "[FRAME %05u][RLC_UM][MOD XX][RB XX][GET PDU INFO] SN %04d TOO MANY LIs ", + frameP, + pdu_info_pP->sn); + + sum_li += pdu_info_pP->li_list[pdu_info_pP->num_li]; + pdu_info_pP->num_li = pdu_info_pP->num_li + 1; + if (pdu_info_pP->num_li > RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { return -2; } } if (li_length_in_bytes == 2) { - pdu_infoP->payload = &e_li->b3; + pdu_info_pP->payload = &e_li_p->b3; } else { - pdu_infoP->payload = &e_li->b1; + pdu_info_pP->payload = &e_li_p->b1; } } - pdu_infoP->payload_size = total_sizeP - pdu_infoP->header_size; - if (pdu_infoP->payload_size > sum_li) { - pdu_infoP->hidden_size = pdu_infoP->payload_size - sum_li; + pdu_info_pP->payload_size = total_sizeP - pdu_info_pP->header_size; + if (pdu_info_pP->payload_size > sum_li) { + pdu_info_pP->hidden_size = pdu_info_pP->payload_size - sum_li; } return 0; } //----------------------------------------------------------------------------- -int rlc_um_read_length_indicators(unsigned char**dataP, rlc_um_e_li_t* e_liP, unsigned int* li_arrayP, unsigned int *num_liP, unsigned int *data_sizeP) { +int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_liP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP) { //----------------------------------------------------------------------------- - int continue_loop = 1; - *num_liP = 0; - unsigned int e1; - unsigned int li1; - unsigned int e2; - unsigned int li2; + int continue_loop = 1; + unsigned int e1 = 0; + unsigned int li1 = 0; + unsigned int e2 = 0; + unsigned int li2 = 0; + *num_li_pP = 0; while ((continue_loop)) { //msg("[RLC_UM] e_liP->b1 = %02X\n", e_liP->b1); //msg("[RLC_UM] e_liP->b2 = %02X\n", e_liP->b2); e1 = ((unsigned int)e_liP->b1 & 0x00000080) >> 7; li1 = (((unsigned int)e_liP->b1 & 0x0000007F) << 4) + (((unsigned int)e_liP->b2 & 0x000000F0) >> 4); - li_arrayP[*num_liP] = li1; - *data_sizeP = *data_sizeP - li1 - 2; - *num_liP = *num_liP +1; + li_array_pP[*num_li_pP] = li1; + *data_size_pP = *data_size_pP - li1 - 2; + *num_li_pP = *num_li_pP +1; if ((e1)) { e2 = ((unsigned int)e_liP->b2 & 0x00000008) >> 3; li2 = (((unsigned int)e_liP->b2 & 0x00000007) << 8) + ((unsigned int)e_liP->b3 & 0x000000FF); - li_arrayP[*num_liP] = li2; - *data_sizeP = *data_sizeP - li2 - 1; - *num_liP = *num_liP +1; + li_array_pP[*num_li_pP] = li2; + *data_size_pP = *data_size_pP - li2 - 1; + *num_li_pP = *num_li_pP +1; if (e2 == 0) { continue_loop = 0; } else { @@ -146,330 +151,507 @@ int rlc_um_read_length_indicators(unsigned char**dataP, rlc_um_e_li_t* e_liP, un } else { continue_loop = 0; } - if (*num_liP >= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { + if (*num_li_pP >= RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU) { return -1; } } - *dataP = *dataP + (((*num_liP*3) +1) >> 1); + *data_ppP = *data_ppP + (((*num_li_pP*3) +1) >> 1); return 0; } //----------------------------------------------------------------------------- -void rlc_um_try_reassembly(rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, signed int start_snP, signed int end_snP) { +void rlc_um_try_reassembly(rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, rlc_sn_t start_snP, rlc_sn_t end_snP) { //----------------------------------------------------------------------------- - mem_block_t *pdu_mem; - struct mac_tb_ind *tb_ind; - rlc_um_e_li_t *e_li; - unsigned char *data; - int e; - int fi; - unsigned int size; - signed int sn; - unsigned int continue_reassembly; - unsigned int num_li; + mem_block_t *pdu_mem_p = NULL; + struct mac_tb_ind *tb_ind_p = NULL; + rlc_um_e_li_t *e_li_p = NULL; + unsigned char *data_p = NULL; + int e = 0; + int fi = 0; + sdu_size_t size = 0; + rlc_sn_t sn = 0; + unsigned int continue_reassembly = 0; + unsigned int num_li = 0; unsigned int li_array[RLC_UM_SEGMENT_NB_MAX_LI_PER_PDU]; - int i; - int reassembly_start_index; - - if (end_snP < 0) end_snP = end_snP + rlcP->rx_sn_modulo; - if (start_snP < 0) start_snP = start_snP + rlcP->rx_sn_modulo; + int i = 0; + int reassembly_start_index = 0; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY FROM PDU SN=%03d+1 TO PDU SN=%03d SN Length = %d bits\n", - rlcP->module_id, - rlcP->rb_id, - frame, - rlcP->last_reassemblied_sn, - end_snP, - rlcP->rx_sn_length); + if (end_snP < 0) end_snP = end_snP + rlc_pP->rx_sn_modulo; + if (start_snP < 0) start_snP = start_snP + rlc_pP->rx_sn_modulo; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY FROM PDU SN=%03d+1 TO PDU SN=%03d SN Length = %d bits\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->last_reassemblied_sn, + end_snP, + rlc_pP->rx_sn_length); +#endif // nothing to be reassemblied if (start_snP == end_snP) { return; } continue_reassembly = 1; - //sn = (rlcP->last_reassemblied_sn + 1) % rlcP->rx_sn_modulo; + //sn = (rlc_pP->last_reassemblied_sn + 1) % rlc_pP->rx_sn_modulo; sn = start_snP; //check_mem_area(); while (continue_reassembly) { - if ((pdu_mem = rlcP->dar_buffer[sn])) { + if ((pdu_mem_p = rlc_pP->dar_buffer[sn])) { - if ((rlcP->last_reassemblied_sn+1)%rlcP->rx_sn_modulo != sn) { - LOG_W(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] FINDING a HOLE in RLC UM SN: CLEARING OUTPUT SDU BECAUSE NEW SN (%03d) TO REASSEMBLY NOT CONTIGUOUS WITH LAST REASSEMBLIED SN (%03d)\n", - rlcP->module_id, rlcP->rb_id, frame, sn, rlcP->last_reassemblied_sn); - rlc_um_clear_rx_sdu(rlcP); + if ((rlc_pP->last_reassemblied_sn+1)%rlc_pP->rx_sn_modulo != sn) { +#if defined (TRACE_RLC_UM_DAR) + LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] FINDING a HOLE in RLC UM SN: CLEARING OUTPUT SDU BECAUSE NEW SN (%03d) TO REASSEMBLY NOT CONTIGUOUS WITH LAST REASSEMBLIED SN (%03d)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + rlc_pP->last_reassemblied_sn); +#endif + rlc_um_clear_rx_sdu(rlc_pP); } - rlcP->last_reassemblied_sn = sn; - tb_ind = (struct mac_tb_ind *)(pdu_mem->data); - if (rlcP->rx_sn_length == 10) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY 10 PDU SN=%03d\n", rlcP->module_id, rlcP->rb_id, frame, sn); - e = (((rlc_um_pdu_sn_10_t*)(tb_ind->data_ptr))->b1 & 0x04) >> 2; - fi = (((rlc_um_pdu_sn_10_t*)(tb_ind->data_ptr))->b1 & 0x18) >> 3; - e_li = (rlc_um_e_li_t*)((rlc_um_pdu_sn_10_t*)(tb_ind->data_ptr))->data; - size = tb_ind->size - 2; - data = &tb_ind->data_ptr[2]; + rlc_pP->last_reassemblied_sn = sn; + tb_ind_p = (struct mac_tb_ind *)(pdu_mem_p->data); + if (rlc_pP->rx_sn_length == 10) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY 10 PDU SN=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif + e = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x04) >> 2; + fi = (((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->b1 & 0x18) >> 3; + e_li_p = (rlc_um_e_li_t*)((rlc_um_pdu_sn_10_t*)(tb_ind_p->data_ptr))->data; + size = tb_ind_p->size - 2; + data_p = &tb_ind_p->data_ptr[2]; } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY 5 PDU SN=%03d Byte 0=%02X\n", rlcP->module_id, rlcP->rb_id, frame, sn, ((rlc_um_pdu_sn_5_t*)(tb_ind->data_ptr))->b1); - e = (((rlc_um_pdu_sn_5_t*)(tb_ind->data_ptr))->b1 & 0x00000020) >> 5; - fi = (((rlc_um_pdu_sn_5_t*)(tb_ind->data_ptr))->b1 & 0x000000C0) >> 6; - e_li = (rlc_um_e_li_t*)((rlc_um_pdu_sn_5_t*)(tb_ind->data_ptr))->data; - size = tb_ind->size - 1; - data = &tb_ind->data_ptr[1]; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] e=%01X fi=%01X\n", rlcP->module_id, rlcP->rb_id, frame, e, fi); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY 5 PDU SN=%03d Byte 0=%02X\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + ((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1); +#endif + e = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x00000020) >> 5; + fi = (((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->b1 & 0x000000C0) >> 6; + e_li_p = (rlc_um_e_li_t*)((rlc_um_pdu_sn_5_t*)(tb_ind_p->data_ptr))->data; + size = tb_ind_p->size - 1; + data_p = &tb_ind_p->data_ptr[1]; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] e=%01X fi=%01X\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e, + fi); +#endif } if (e == RLC_E_FIXED_PART_DATA_FIELD_FOLLOW) { switch (fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU NO E_LI FI=11 (00)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif // one complete SDU - //LGrlc_um_send_sdu(rlcP,frame,eNB_flag); // may be not necessary - rlc_um_clear_rx_sdu(rlcP); - rlc_um_reassembly (data, size, rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); - rlcP->reassembly_missing_sn_detected = 0; + //LGrlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); // may be not necessary + rlc_um_clear_rx_sdu(rlc_pP); + rlc_um_reassembly (data_p, size, rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU NO E_LI FI=10 (01)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif // one beginning segment of SDU in PDU - //LG rlc_um_send_sdu(rlcP,frame,eNB_flag); // may be not necessary - rlc_um_clear_rx_sdu(rlcP); - rlc_um_reassembly (data, size, rlcP,frame); - rlcP->reassembly_missing_sn_detected = 0; + //LG rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); // may be not necessary + rlc_um_clear_rx_sdu(rlc_pP); + rlc_um_reassembly (data_p, size, rlc_pP,frameP); + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU NO E_LI FI=01 (10)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif // one last segment of SDU - if (rlcP->reassembly_missing_sn_detected == 0) { - rlc_um_reassembly (data, size, rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); + if (rlc_pP->reassembly_missing_sn_detected == 0) { + rlc_um_reassembly (data_p, size, rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); } else { //clear sdu already done - rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += tb_ind->size; + rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; } - rlcP->reassembly_missing_sn_detected = 0; + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", rlcP->module_id, rlcP->rb_id, frame); - if (rlcP->reassembly_missing_sn_detected == 0) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU NO E_LI FI=00 (11)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + if (rlc_pP->reassembly_missing_sn_detected == 0) { // one whole segment of SDU in PDU - rlc_um_reassembly (data, size, rlcP,frame); + rlc_um_reassembly (data_p, size, rlc_pP,frameP); } else { - LOG_W(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU NO E_LI FI=00 (11) MISSING SN DETECTED\n", rlcP->module_id, rlcP->rb_id, frame); - //LOG_D(RLC, "[MSC_NBOX][FRAME %05d][RLC_UM][MOD %02d][RB %02d][Missing SN detected][RLC_UM][MOD %02d][RB %02d]\n", - // frame, rlcP->module_id,rlcP->rb_id, rlcP->module_id,rlcP->rb_id); - rlcP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code - rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += tb_ind->size; +#if defined (TRACE_RLC_UM_DAR) + LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU NO E_LI FI=00 (11) MISSING SN DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + //LOG_D(RLC, "[MSC_NBOX][FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u][Missing SN detected][RLC_UM][MOD %u/%u][RB %u]\n", + // frameP, rlc_pP->module_id,rlc_pP->rb_id, rlc_pP->module_id,rlc_pP->rb_id); + rlc_pP->reassembly_missing_sn_detected = 1; // not necessary but for readability of the code + rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; #if defined(RLC_STOP_ON_LOST_PDU) - AssertFatal( rlcP->reassembly_missing_sn_detected == 1, - "[RLC_UM][MOD %d][RB %d][FRAME %05d] MISSING PDU DETECTED\n", - rlcP->module_id, rlcP->rb_id, frame); + AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, + "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] MISSING PDU DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #endif } break; default: - AssertFatal( 0 !=0, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY SHOULD NOT GO HERE\n", rlcP->module_id, rlcP->rb_id, frame); + AssertFatal( 0 , "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY SHOULD NOT GO HERE\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } } else { - if (rlc_um_read_length_indicators(&data, e_li, li_array, &num_li, &size ) >= 0) { + if (rlc_um_read_length_indicators(&data_p, e_li_p, li_array, &num_li, &size ) >= 0) { switch (fi) { case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU FI=11 (00) Li=", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU FI=11 (00) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); } LOG_D(RLC, " remaining size %d\n",size); +#endif // N complete SDUs - //LGrlc_um_send_sdu(rlcP,frame,eNB_flag); - rlc_um_clear_rx_sdu(rlcP); + //LGrlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + rlc_um_clear_rx_sdu(rlc_pP); for (i = 0; i < num_li; i++) { - rlc_um_reassembly (data, li_array[i], rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); - data = &data[li_array[i]]; + rlc_um_reassembly (data_p, li_array[i], rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + data_p = &data_p[li_array[i]]; } if (size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_um_reassembly (data, size, rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); + // data_p is already ok, done by last loop above + rlc_um_reassembly (data_p, size, rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); } - rlcP->reassembly_missing_sn_detected = 0; + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU FI=10 (01) Li=", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU FI=10 (01) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); } LOG_D(RLC, " remaining size %d\n",size); +#endif // N complete SDUs + one segment of SDU in PDU - //LG rlc_um_send_sdu(rlcP,frame,eNB_flag); - rlc_um_clear_rx_sdu(rlcP); + //LG rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + rlc_um_clear_rx_sdu(rlc_pP); for (i = 0; i < num_li; i++) { - rlc_um_reassembly (data, li_array[i], rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); - data = &data[li_array[i]]; + rlc_um_reassembly (data_p, li_array[i], rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + data_p = &data_p[li_array[i]]; } if (size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_um_reassembly (data, size, rlcP,frame); + // data_p is already ok, done by last loop above + rlc_um_reassembly (data_p, size, rlc_pP,frameP); } - rlcP->reassembly_missing_sn_detected = 0; + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU FI=01 (10) Li=", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU FI=01 (10) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); } LOG_D(RLC, " remaining size %d\n",size); - if (rlcP->reassembly_missing_sn_detected) { +#endif + if (rlc_pP->reassembly_missing_sn_detected) { reassembly_start_index = 1; - data = &data[li_array[0]]; - //rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += li_array[0]; + data_p = &data_p[li_array[0]]; + //rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += li_array[0]; } else { reassembly_start_index = 0; } // one last segment of SDU + N complete SDUs in PDU for (i = reassembly_start_index; i < num_li; i++) { - rlc_um_reassembly (data, li_array[i], rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); - data = &data[li_array[i]]; + rlc_um_reassembly (data_p, li_array[i], rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + data_p = &data_p[li_array[i]]; } if (size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_um_reassembly (data, size, rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); + // data_p is already ok, done by last loop above + rlc_um_reassembly (data_p, size, rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); } - rlcP->reassembly_missing_sn_detected = 0; + rlc_pP->reassembly_missing_sn_detected = 0; break; case RLC_FI_1ST_BYTE_DATA_IS_NOT_1ST_BYTE_SDU_LAST_BYTE_DATA_IS_NOT_LAST_BYTE_SDU: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRY REASSEMBLY PDU FI=00 (11) Li=", rlcP->module_id, rlcP->rb_id, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRY REASSEMBLY PDU FI=00 (11) Li=", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); for (i=0; i < num_li; i++) { LOG_D(RLC, "%d ",li_array[i]); } LOG_D(RLC, " remaining size %d\n",size); - if (rlcP->reassembly_missing_sn_detected) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] DISCARD FIRST LI %d", rlcP->module_id, rlcP->rb_id, frame, li_array[0]); +#endif + if (rlc_pP->reassembly_missing_sn_detected) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] DISCARD FIRST LI %d", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + li_array[0]); +#endif reassembly_start_index = 1; - data = &data[li_array[0]]; - //rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += li_array[0]; + data_p = &data_p[li_array[0]]; + //rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += li_array[0]; } else { reassembly_start_index = 0; } for (i = reassembly_start_index; i < num_li; i++) { - rlc_um_reassembly (data, li_array[i], rlcP,frame); - rlc_um_send_sdu(rlcP,frame,eNB_flag); - data = &data[li_array[i]]; + rlc_um_reassembly (data_p, li_array[i], rlc_pP,frameP); + rlc_um_send_sdu(rlc_pP,frameP,eNB_flagP); + data_p = &data_p[li_array[i]]; } if (size > 0) { // normally should always be > 0 but just for help debug - // data is already ok, done by last loop above - rlc_um_reassembly (data, size, rlcP,frame); + // data_p is already ok, done by last loop above + rlc_um_reassembly (data_p, size, rlc_pP,frameP); } else { - AssertFatal( 0 !=0, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SHOULD NOT GO HERE\n", rlcP->module_id, rlcP->rb_id, frame); - //rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += size; + AssertFatal( 0 !=0, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SHOULD NOT GO HERE\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + //rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += size; } - rlcP->reassembly_missing_sn_detected = 0; + rlc_pP->reassembly_missing_sn_detected = 0; break; default: - LOG_W(RLC, "[MSC_NBOX][FRAME %05d][RLC_UM][MOD %02d][RB %02d][Missing SN detected][RLC_UM][MOD %02d][RB %02d]\n", - frame, rlcP->module_id,rlcP->rb_id, rlcP->module_id,rlcP->rb_id); - rlcP->stat_rx_data_pdu_dropped += 1; - rlcP->stat_rx_data_bytes_dropped += tb_ind->size; +#if defined (TRACE_RLC_UM_DAR) + LOG_W(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] Missing SN detected\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + rlc_pP->stat_rx_data_pdu_dropped += 1; + rlc_pP->stat_rx_data_bytes_dropped += tb_ind_p->size; - rlcP->reassembly_missing_sn_detected = 1; + rlc_pP->reassembly_missing_sn_detected = 1; #if defined(RLC_STOP_ON_LOST_PDU) - AssertFatal( rlcP->reassembly_missing_sn_detected == 1, - "[RLC_UM][MOD %d][RB %d][FRAME %05d] MISSING PDU DETECTED\n", rlcP->module_id, rlcP->rb_id, frame); + AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, + "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] MISSING PDU DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #endif } } } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] REMOVE PDU FROM DAR BUFFER SN=%03d\n", rlcP->module_id, rlcP->rb_id, frame, sn); - free_mem_block(rlcP->dar_buffer[sn]); - rlcP->dar_buffer[sn] = NULL; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] REMOVE PDU FROM DAR BUFFER SN=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif + free_mem_block(rlc_pP->dar_buffer[sn]); + rlc_pP->dar_buffer[sn] = NULL; } else { - rlcP->last_reassemblied_missing_sn = sn; - LOG_D(RLC, "[MSC_NBOX][FRAME %05d][RLC_UM][MOD %02d][RB %02d][Missing SN %04d detected, clearing RX SDU][RLC_UM][MOD %02d][RB %02d]\n", - frame, rlcP->module_id,rlcP->rb_id, sn, rlcP->module_id,rlcP->rb_id); - rlcP->reassembly_missing_sn_detected = 1; - rlc_um_clear_rx_sdu(rlcP); + rlc_pP->last_reassemblied_missing_sn = sn; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] Missing SN %04d detected, clearing RX SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif + rlc_pP->reassembly_missing_sn_detected = 1; + rlc_um_clear_rx_sdu(rlc_pP); #if defined(RLC_STOP_ON_LOST_PDU) - AssertFatal( rlcP->reassembly_missing_sn_detected == 1, - "[FRAME %05d][RLC_UM][MOD %d][RB %d] MISSING PDU DETECTED\n", frame, rlcP->module_id, rlcP->rb_id); + AssertFatal( rlc_pP->reassembly_missing_sn_detected == 1, + "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] MISSING PDU DETECTED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); #endif } - sn = (sn + 1) % rlcP->rx_sn_modulo; - if ((sn == rlcP->vr_uh) || (sn == end_snP)){ + sn = (sn + 1) % rlc_pP->rx_sn_modulo; + if ((sn == rlc_pP->vr_uh) || (sn == end_snP)){ continue_reassembly = 0; } } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TRIED REASSEMBLY VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ur, rlcP->vr_ux,rlcP->vr_uh); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TRIED REASSEMBLY VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ur, + rlc_pP->vr_ux, + rlc_pP->vr_uh); +#endif } //----------------------------------------------------------------------------- -void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame) +void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] STOPPED AND RESET\n", frame, - rlcP->module_id, rlcP->rb_id); - rlcP->t_reordering.running = 0; - rlcP->t_reordering.frame_time_out = 0; - rlcP->t_reordering.frame_start = 0; - rlcP->t_reordering.timed_out = 0; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u][T-REORDERING] STOPPED AND RESET\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + rlc_pP->t_reordering.running = 0; + rlc_pP->t_reordering.frame_time_out = 0; + rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- -void rlc_um_start_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame) +void rlc_um_start_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP) //----------------------------------------------------------------------------- { - rlcP->t_reordering.running = 1; - rlcP->t_reordering.frame_time_out = frame + rlcP->t_reordering.time_out; - rlcP->t_reordering.frame_start = frame; - rlcP->t_reordering.timed_out = 0; - LOG_D(RLC, "[FRAME %05d][RLC_AM][MOD %02d][RB %02d][T-REORDERING] STARTED (TIME-OUT = FRAME %05d)\n", - frame, rlcP->module_id, rlcP->rb_id, rlcP->t_reordering.frame_time_out); + rlc_pP->t_reordering.running = 1; + rlc_pP->t_reordering.frame_time_out = frameP + rlc_pP->t_reordering.time_out; + rlc_pP->t_reordering.frame_start = frameP; + rlc_pP->t_reordering.timed_out = 0; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u][T-REORDERING] STARTED (TIME-OUT = FRAME %05u)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_reordering.frame_time_out); +#endif } //----------------------------------------------------------------------------- -void rlc_um_init_timer_reordering(rlc_um_entity_t *rlcP, u32_t time_outP) +void rlc_um_init_timer_reordering(rlc_um_entity_t *rlc_pP, u32_t time_outP) //----------------------------------------------------------------------------- { - rlcP->t_reordering.running = 0; - rlcP->t_reordering.frame_time_out = 0; - rlcP->t_reordering.frame_start = 0; - rlcP->t_reordering.time_out = time_outP; - rlcP->t_reordering.timed_out = 0; + rlc_pP->t_reordering.running = 0; + rlc_pP->t_reordering.frame_time_out = 0; + rlc_pP->t_reordering.frame_start = 0; + rlc_pP->t_reordering.time_out = time_outP; + rlc_pP->t_reordering.timed_out = 0; } //----------------------------------------------------------------------------- -void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlcP,u32_t frame,u8_t eNB_flag) { +void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP) { //----------------------------------------------------------------------------- - signed int in_window; - u16_t old_vr_ur; - if ((rlcP->t_reordering.running)) { + signed int in_window; + rlc_usn_t old_vr_ur; + if ((rlc_pP->t_reordering.running)) { if ( // CASE 1: start time out // +-----------+------------------+----------+ // | |******************| | // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX - ((rlcP->t_reordering.frame_start < rlcP->t_reordering.frame_time_out) && - ((frame >= rlcP->t_reordering.frame_time_out) || - (frame < rlcP->t_reordering.frame_start))) || + ((rlc_pP->t_reordering.frame_start < rlc_pP->t_reordering.frame_time_out) && + ((frameP >= rlc_pP->t_reordering.frame_time_out) || + (frameP < rlc_pP->t_reordering.frame_start))) || // CASE 2: time out start // +-----------+------------------+----------+ // |***********| |**********| // +-----------+------------------+----------+ //FRAME # 0 FRAME MAX VALUE - ((rlcP->t_reordering.frame_start > rlcP->t_reordering.frame_time_out) && - (frame < rlcP->t_reordering.frame_start) && (frame >= rlcP->t_reordering.frame_time_out)) + ((rlc_pP->t_reordering.frame_start > rlc_pP->t_reordering.frame_time_out) && + (frameP < rlc_pP->t_reordering.frame_start) && (frameP >= rlc_pP->t_reordering.frame_time_out)) ) { - //if ((u32_t)((u32_t)rlcP->timer_reordering + (u32_t)rlcP->timer_reordering_init) <= frame) { + //if ((u32_t)((u32_t)rlc_pP->timer_reordering + (u32_t)rlc_pP->timer_reordering_init) <= frameP) { // 5.1.2.2.4 Actions when t-Reordering expires // When t-Reordering expires, the receiving UM RLC entity shall: // -update VR(UR) to the SN of the first UMD PDU with SN >= VR(UX) that has not been received; @@ -477,85 +659,132 @@ void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlcP,u32_t frame,u8_t eNB_ // -if VR(UH) > VR(UR): // -start t-Reordering; // -set VR(UX) to VR(UH). - rlcP->stat_timer_reordering_timed_out += 1; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d]*****************************************************\n", rlcP->module_id, rlcP->rb_id, frame); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d]* T I M E - O U T *\n", rlcP->module_id, rlcP->rb_id, frame); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d]*****************************************************\n", rlcP->module_id, rlcP->rb_id, frame); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] TIMER t-Reordering expiration\n", rlcP->module_id, rlcP->rb_id, frame); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] timer_reordering=%d frame=%d expire frame %d\n", - rlcP->module_id, - rlcP->rb_id, - frame, - rlcP->t_reordering.time_out, - rlcP->t_reordering.frame_time_out, - frame); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] set VR(UR)=%03d to", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ur); - - old_vr_ur = rlcP->vr_ur; - - rlcP->vr_ur = rlcP->vr_ux; - while (rlc_um_get_pdu_from_dar_buffer(rlcP, rlcP->vr_ur)) { - rlcP->vr_ur = (rlcP->vr_ur+1)%rlcP->rx_sn_modulo; + rlc_pP->stat_timer_reordering_timed_out += 1; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u]*****************************************************\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u]* T I M E - O U T *\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u]*****************************************************\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] TIMER t-Reordering expiration\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] timer_reordering=%d frameP=%d expire frameP %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->t_reordering.time_out, + rlc_pP->t_reordering.frame_time_out, + frameP); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] set VR(UR)=%03d to", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ur); +#endif + + old_vr_ur = rlc_pP->vr_ur; + + rlc_pP->vr_ur = rlc_pP->vr_ux; + while (rlc_um_get_pdu_from_dar_buffer(rlc_pP, rlc_pP->vr_ur)) { + rlc_pP->vr_ur = (rlc_pP->vr_ur+1)%rlc_pP->rx_sn_modulo; } - LOG_D(RLC, " %d", rlcP->vr_ur); + LOG_D(RLC, " %d", rlc_pP->vr_ur); LOG_D(RLC, "\n"); - rlc_um_try_reassembly(rlcP,frame,eNB_flag,old_vr_ur, rlcP->vr_ur); + rlc_um_try_reassembly(rlc_pP,frameP,eNB_flagP,old_vr_ur, rlc_pP->vr_ur); - in_window = rlc_um_in_window(rlcP, frame, rlcP->vr_ur, rlcP->vr_uh, rlcP->vr_uh); + in_window = rlc_um_in_window(rlc_pP, frameP, rlc_pP->vr_ur, rlc_pP->vr_uh, rlc_pP->vr_uh); if (in_window == 2) { - rlc_um_start_timer_reordering(rlcP, frame); - rlcP->vr_ux = rlcP->vr_uh; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] restarting t-Reordering set VR(UX) to %d (VR(UH)>VR(UR))\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ux); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_UM][MOD %02d][RB %02d][--- t-Reordering Timed-out (restarted) VR(UR)=%03d->%03d VR(UX)=%03d --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, - rlcP->module_id, - rlcP->rb_id, - old_vr_ur, - rlcP->vr_ur, - rlcP->vr_ux, - rlcP->module_id, - rlcP->rb_id); + rlc_um_start_timer_reordering(rlc_pP, frameP); + rlc_pP->vr_ux = rlc_pP->vr_uh; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] restarting t-Reordering set VR(UX) to %d (VR(UH)>VR(UR))\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ux); +#endif } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] STOP t-Reordering VR(UX) = %03d\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ux); - rlc_um_stop_and_reset_timer_reordering(rlcP, frame); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_UM][MOD %02d][RB %02d][--- t-Reordering Timed-out (stopped) VR(UR)=%03d->%03d VR(UX)=%03d --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, - rlcP->module_id, - rlcP->rb_id, - old_vr_ur, - rlcP->vr_ur, - rlcP->vr_ux, - rlcP->module_id, - rlcP->rb_id); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] STOP t-Reordering VR(UX) = %03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ux); +#endif + rlc_um_stop_and_reset_timer_reordering(rlc_pP, frameP); } } } } //----------------------------------------------------------------------------- inline mem_block_t * -rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP) +rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, rlc_usn_t snP) { //----------------------------------------------------------------------------- - mem_block_t * pdu = rlcP->dar_buffer[snP]; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] REMOVE PDU FROM DAR BUFFER SN=%03d\n", rlcP->module_id, rlcP->rb_id, -1, snP); - rlcP->dar_buffer[snP] = NULL; - return pdu; + mem_block_t * pdu_p = rlc_pP->dar_buffer[snP]; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] REMOVE PDU FROM DAR BUFFER SN=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP); +#endif + rlc_pP->dar_buffer[snP] = NULL; + return pdu_p; } //----------------------------------------------------------------------------- inline mem_block_t * -rlc_um_get_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP) +rlc_um_get_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, rlc_usn_t snP) { //----------------------------------------------------------------------------- - return rlcP->dar_buffer[snP]; + return rlc_pP->dar_buffer[snP]; } //----------------------------------------------------------------------------- inline void -rlc_um_store_pdu_in_dar_buffer(rlc_um_entity_t *rlcP, u32_t frame, mem_block_t *pduP, u16_t snP) +rlc_um_store_pdu_in_dar_buffer(rlc_um_entity_t *rlc_pP, frame_t frameP, mem_block_t *pdu_pP, rlc_usn_t snP) { //----------------------------------------------------------------------------- - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] STORE PDU IN DAR BUFFER SN=%03d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", rlcP->module_id, rlcP->rb_id, frame, snP, rlcP->vr_ur, rlcP->vr_ux, rlcP->vr_uh); - rlcP->dar_buffer[snP] = pduP; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] STORE PDU IN DAR BUFFER SN=%03d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + rlc_pP->vr_ur, + rlc_pP->vr_ux, + rlc_pP->vr_uh); +#endif + rlc_pP->dar_buffer[snP] = pdu_pP; } //----------------------------------------------------------------------------- // returns -2 if lower_bound > sn @@ -564,46 +793,89 @@ rlc_um_store_pdu_in_dar_buffer(rlc_um_entity_t *rlcP, u32_t frame, mem_block_t * // returns 1 if lower_bound == sn // returns 2 if higher_bound == sn // returns 3 if higher_bound == sn == lower_bound -inline signed int rlc_um_in_window(rlc_um_entity_t *rlcP, u32_t frame, signed int lower_boundP, signed int snP, signed int higher_boundP) { +inline signed int rlc_um_in_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t lower_boundP, rlc_sn_t snP, rlc_sn_t higher_boundP) { //----------------------------------------------------------------------------- - signed int modulus = (signed int)rlcP->vr_uh - rlcP->rx_um_window_size; -#ifdef DEBUG_RLC_UM_RX - signed int lower_bound = lower_boundP; - signed int higher_bound = higher_boundP; - signed int sn = snP; + rlc_sn_t modulus = (rlc_sn_t)rlc_pP->vr_uh - rlc_pP->rx_um_window_size; +#ifdef TRACE_RLC_UM_RX + rlc_sn_t lower_bound = lower_boundP; + rlc_sn_t higher_bound = higher_boundP; + rlc_sn_t sn = snP; #endif - lower_boundP = (lower_boundP - modulus) % rlcP->rx_sn_modulo; - higher_boundP = (higher_boundP - modulus) % rlcP->rx_sn_modulo; - snP = (snP - modulus) % rlcP->rx_sn_modulo; + lower_boundP = (lower_boundP - modulus) % rlc_pP->rx_sn_modulo; + higher_boundP = (higher_boundP - modulus) % rlc_pP->rx_sn_modulo; + snP = (snP - modulus) % rlc_pP->rx_sn_modulo; if ( lower_boundP > snP) { -#ifdef DEBUG_RLC_UM_RX - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d not in WINDOW[%03d:%03d] (SN<LOWER BOUND)\n", rlcP->module_id, rlcP->rb_id, frame, sn, lower_bound, higher_bound); +#ifdef TRACE_RLC_UM_RX + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d not in WINDOW[%03d:%03d] (SN<LOWER BOUND)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + lower_bound, + higher_bound); #endif return -2; } if ( higher_boundP < snP) { -#ifdef DEBUG_RLC_UM_RX - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d not in WINDOW[%03d:%03d] (SN>HIGHER BOUND) <=> %d not in WINDOW[%03d:%03d]\n", rlcP->module_id, rlcP->rb_id, frame, sn, lower_bound, higher_bound, snP, lower_boundP, higher_boundP); +#ifdef TRACE_RLC_UM_RX + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d not in WINDOW[%03d:%03d] (SN>HIGHER BOUND) <=> %d not in WINDOW[%03d:%03d]\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + lower_bound, + higher_bound, + snP, + lower_boundP, + higher_boundP); #endif return -1; } if ( lower_boundP == snP) { if ( higher_boundP == snP) { -#ifdef DEBUG_RLC_UM_RX - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND=LOWER BOUND)\n", rlcP->module_id, rlcP->rb_id, frame, sn, lower_bound, higher_bound); +#ifdef TRACE_RLC_UM_RX + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND=LOWER BOUND)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + lower_bound, + higher_bound); #endif return 3; } -#ifdef DEBUG_RLC_UM_RX - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d in WINDOW[%03d:%03d] (SN=LOWER BOUND)\n", rlcP->module_id, rlcP->rb_id, frame, sn, lower_bound, higher_bound); +#ifdef TRACE_RLC_UM_RX + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d in WINDOW[%03d:%03d] (SN=LOWER BOUND)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + lower_bound, + higher_bound); #endif return 1; } if ( higher_boundP == snP) { -#ifdef DEBUG_RLC_UM_RX - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND)\n", rlcP->module_id, rlcP->rb_id, frame, sn, lower_bound, higher_bound); +#ifdef TRACE_RLC_UM_RX + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d in WINDOW[%03d:%03d] (SN=HIGHER BOUND)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + lower_bound, + higher_bound); #endif return 2; } @@ -611,34 +883,72 @@ inline signed int rlc_um_in_window(rlc_um_entity_t *rlcP, u32_t frame, signed in } //----------------------------------------------------------------------------- -inline signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlcP, u32_t frame, signed int snP) { +inline signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP) { //----------------------------------------------------------------------------- - signed int modulus = (signed int)rlcP->vr_uh - rlcP->rx_um_window_size; - signed int sn = snP; + rlc_sn_t modulus = (signed int)rlc_pP->vr_uh - rlc_pP->rx_um_window_size; + rlc_sn_t sn = snP; - snP = (snP - modulus) % rlcP->rx_sn_modulo; + snP = (snP - modulus) % rlc_pP->rx_sn_modulo; if ( 0 <= snP) { - if (snP < rlcP->rx_um_window_size) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d IN REORDERING WINDOW[%03d:%03d[ SN %d IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - rlcP->module_id, rlcP->rb_id, frame, snP, 0, rlcP->rx_um_window_size, - sn, (signed int)rlcP->vr_uh - rlcP->rx_um_window_size, rlcP->vr_uh, - rlcP->vr_ur, rlcP->vr_uh); + if (snP < rlc_pP->rx_um_window_size) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d IN REORDERING WINDOW[%03d:%03d[ SN %d IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + 0, + rlc_pP->rx_um_window_size, + sn, + (signed int)rlc_pP->vr_uh - rlc_pP->rx_um_window_size, + rlc_pP->vr_uh, + rlc_pP->vr_ur, + rlc_pP->vr_uh); +#endif return 0; } } +#if defined (TRACE_RLC_UM_DAR) if (modulus < 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - rlcP->module_id, rlcP->rb_id, frame, snP, modulus + 1024, rlcP->rx_um_window_size, sn, modulus + 1024 , rlcP->vr_uh, rlcP->vr_ur, rlcP->vr_uh); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + modulus + 1024, + rlc_pP->rx_um_window_size, + sn, + modulus + 1024 , + rlc_pP->vr_uh, + rlc_pP->vr_ur, + rlc_pP->vr_uh); } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", - rlcP->module_id, rlcP->rb_id, frame, snP, modulus, rlcP->rx_um_window_size, sn, modulus , rlcP->vr_uh, rlcP->vr_ur, rlcP->vr_uh); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] %d NOT IN REORDERING WINDOW[%03d:%03d[ SN %d NOT IN [%03d:%03d[ VR(UR)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + snP, + modulus, + rlc_pP->rx_um_window_size, + sn, + modulus , + rlc_pP->vr_uh, + rlc_pP->vr_ur, + rlc_pP->vr_uh); } +#endif return -1; } //----------------------------------------------------------------------------- void -rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t *pdu_memP,rlc_um_pdu_sn_10_t *pduP, u16_t tb_sizeP) +rlc_um_receive_process_dar (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t *pdu_mem_pP,rlc_um_pdu_sn_10_t *pdu_pP, sdu_size_t tb_sizeP) { //----------------------------------------------------------------------------- // 36.322v9.3.0 section 5.1.2.2.1: @@ -661,19 +971,19 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // -else: // -place the received UMD PDU in the reception buffer. - signed int sn = -1; + rlc_sn_t sn = -1; signed int in_window; - if (rlcP->rx_sn_length == 10) { - sn = ((pduP->b1 & 0x00000003) << 8) + pduP->b2; - } else if (rlcP->rx_sn_length == 5) { - sn = pduP->b1 & 0x1F; + if (rlc_pP->rx_sn_length == 10) { + sn = ((pdu_pP->b1 & 0x00000003) << 8) + pdu_pP->b2; + } else if (rlc_pP->rx_sn_length == 5) { + sn = pdu_pP->b1 & 0x1F; } else { - free_mem_block(pdu_memP); + free_mem_block(pdu_mem_pP); } - in_window = rlc_um_in_window(rlcP, frame, rlcP->vr_uh - rlcP->rx_um_window_size, sn, rlcP->vr_ur); + in_window = rlc_um_in_window(rlc_pP, frameP, rlc_pP->vr_uh - rlc_pP->rx_um_window_size, sn, rlc_pP->vr_ur); - rlc_util_print_hex_octets(RLC, &pduP->b1, tb_sizeP); + rlc_util_print_hex_octets(RLC, &pdu_pP->b1, tb_sizeP); // rlc_um_in_window() returns -2 if lower_bound > sn // rlc_um_in_window() returns -1 if higher_bound < sn @@ -682,36 +992,56 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // rlc_um_in_window() returns 2 if higher_bound == sn // rlc_um_in_window() returns 3 if higher_bound == sn == lower_bound if ((in_window == 1) || (in_window == 0)){ - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RX PDU VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> GARBAGE\n", rlcP->module_id, rlcP->rb_id, frame, sn); - LOG_D(RLC, "[MSC_NBOX][FRAME %05d][RLC_UM][MOD %02d][RB %02d][RX PDU (VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> DROPPED][RLC_UM][MOD %02d][RB %02d]\n", - frame, rlcP->module_id,rlcP->rb_id, sn, rlcP->module_id,rlcP->rb_id); //discard the PDU - rlcP->stat_rx_data_pdu_out_of_window += 1; - rlcP->stat_rx_data_bytes_out_of_window += tb_sizeP; - free_mem_block(pdu_memP); - pdu_memP = NULL; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] RX PDU VR(UH) – UM_Window_Size) <= SN %d < VR(UR) -> GARBAGE\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif + rlc_pP->stat_rx_data_pdu_out_of_window += 1; + rlc_pP->stat_rx_data_bytes_out_of_window += tb_sizeP; + free_mem_block(pdu_mem_pP); + pdu_mem_pP = NULL; return; } - if ((rlc_um_get_pdu_from_dar_buffer(rlcP, sn))) { - in_window = rlc_um_in_window(rlcP, frame, rlcP->vr_ur, sn, rlcP->vr_uh); + if ((rlc_um_get_pdu_from_dar_buffer(rlc_pP, sn))) { + in_window = rlc_um_in_window(rlc_pP, frameP, rlc_pP->vr_ur, sn, rlc_pP->vr_uh); if (in_window == 0){ - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> GARBAGE\n", rlcP->module_id, rlcP->rb_id, frame, sn); - LOG_D(RLC, "[MSC_NBOX][FRAME %05d][RLC_UM][MOD %02d][RB %02d][RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> DROPPED][RLC_UM][MOD %02d][RB %02d]\n", - frame, rlcP->module_id,rlcP->rb_id, sn, rlcP->module_id,rlcP->rb_id); //discard the PDU +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] RX PDU VR(UR) < SN %d < VR(UH) and RECEIVED BEFORE-> GARBAGE\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif //discard the PDU - rlcP->stat_rx_data_pdus_duplicate += 1; - rlcP->stat_rx_data_bytes_duplicate += tb_sizeP; - free_mem_block(pdu_memP); - pdu_memP = NULL; + rlc_pP->stat_rx_data_pdus_duplicate += 1; + rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; + free_mem_block(pdu_mem_pP); + pdu_mem_pP = NULL; return; } // 2 lines to avoid memory leaks - rlcP->stat_rx_data_pdus_duplicate += 1; - rlcP->stat_rx_data_bytes_duplicate += tb_sizeP; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RX PDU SN %03d REMOVE OLD PDU BEFORE STORING NEW PDU\n", rlcP->module_id, rlcP->rb_id, frame, sn); - mem_block_t *pdu = rlc_um_remove_pdu_from_dar_buffer(rlcP, sn); + rlc_pP->stat_rx_data_pdus_duplicate += 1; + rlc_pP->stat_rx_data_bytes_duplicate += tb_sizeP; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] RX PDU SN %03d REMOVE OLD PDU BEFORE STORING NEW PDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn); +#endif + mem_block_t *pdu = rlc_um_remove_pdu_from_dar_buffer(rlc_pP, sn); free_mem_block(pdu); } - rlc_um_store_pdu_in_dar_buffer(rlcP, frame, pdu_memP, sn); + rlc_um_store_pdu_in_dar_buffer(rlc_pP, frameP, pdu_mem_pP, sn); // -if x falls outside of the reordering window: @@ -723,23 +1053,42 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // // -if VR(UR) falls outside of the reordering window: // -set VR(UR) to (VR(UH) – UM_Window_Size); - if (rlc_um_in_reordering_window(rlcP, frame, sn) < 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RX PDU SN %d OUTSIDE REORDERING WINDOW VR(UH)=%d UM_Window_Size=%d\n", rlcP->module_id, rlcP->rb_id, frame, sn, rlcP->vr_uh, rlcP->rx_um_window_size); - rlcP->vr_uh = (sn + 1) % rlcP->rx_sn_modulo; + if (rlc_um_in_reordering_window(rlc_pP, frameP, sn) < 0) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] RX PDU SN %d OUTSIDE REORDERING WINDOW VR(UH)=%d UM_Window_Size=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sn, + rlc_pP->vr_uh, + rlc_pP->rx_um_window_size); +#endif + rlc_pP->vr_uh = (sn + 1) % rlc_pP->rx_sn_modulo; - if (rlc_um_in_reordering_window(rlcP, frame, rlcP->vr_ur) != 0) { - in_window = rlcP->vr_uh - rlcP->rx_um_window_size; + if (rlc_um_in_reordering_window(rlc_pP, frameP, rlc_pP->vr_ur) != 0) { + in_window = rlc_pP->vr_uh - rlc_pP->rx_um_window_size; if (in_window < 0) { - in_window = in_window + rlcP->rx_sn_modulo; + in_window = in_window + rlc_pP->rx_sn_modulo; } - rlc_um_try_reassembly(rlcP, frame, eNB_flag, rlcP->vr_ur, in_window); + rlc_um_try_reassembly(rlc_pP, frameP, eNB_flagP, rlc_pP->vr_ur, in_window); } - if (rlc_um_in_reordering_window(rlcP, frame, rlcP->vr_ur) < 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ur, in_window); - rlcP->vr_ur = in_window; + if (rlc_um_in_reordering_window(rlc_pP, frameP, rlc_pP->vr_ur) < 0) { +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] VR(UR) %d OUTSIDE REORDERING WINDOW SET TO VR(UH) – UM_Window_Size = %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ur, + in_window); +#endif + rlc_pP->vr_ur = in_window; } } // -if the reception buffer contains an UMD PDU with SN = VR(UR): @@ -749,12 +1098,12 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // remove RLC headers when doing so and deliver the reassembled RLC // SDUs to upper layer in ascending order of the RLC SN if not // delivered before; - if ((sn == rlcP->vr_ur) && rlc_um_get_pdu_from_dar_buffer(rlcP, rlcP->vr_ur)) { - //sn_tmp = rlcP->vr_ur; + if ((sn == rlc_pP->vr_ur) && rlc_um_get_pdu_from_dar_buffer(rlc_pP, rlc_pP->vr_ur)) { + //sn_tmp = rlc_pP->vr_ur; do { - rlcP->vr_ur = (rlcP->vr_ur+1) % rlcP->rx_sn_modulo; - } while (rlc_um_get_pdu_from_dar_buffer(rlcP, rlcP->vr_ur) && (rlcP->vr_ur != rlcP->vr_uh)); - rlc_um_try_reassembly(rlcP, frame, eNB_flag, sn, rlcP->vr_ur); + rlc_pP->vr_ur = (rlc_pP->vr_ur+1) % rlc_pP->rx_sn_modulo; + } while (rlc_um_get_pdu_from_dar_buffer(rlc_pP, rlc_pP->vr_ur) && (rlc_pP->vr_ur != rlc_pP->vr_uh)); + rlc_um_try_reassembly(rlc_pP, frameP, eNB_flagP, sn, rlc_pP->vr_ur); } // -if t-Reordering is running: @@ -762,20 +1111,38 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // -if VR(UX) falls outside of the reordering window and VR(UX) is not // equal to VR(UH):: // -stop and reset t-Reordering; - if (rlcP->t_reordering.running) { - if (rlcP->vr_uh != rlcP->vr_ux) { - in_window = rlc_um_in_reordering_window(rlcP, frame, rlcP->vr_ux); + if (rlc_pP->t_reordering.running) { + if (rlc_pP->vr_uh != rlc_pP->vr_ux) { + in_window = rlc_um_in_reordering_window(rlc_pP, frameP, rlc_pP->vr_ux); if (in_window < 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d -or- VR(UX) <= VR(UR)\n", rlcP->module_id, rlcP->rb_id, frame,rlcP->vr_ux,rlcP->vr_uh); - rlc_um_stop_and_reset_timer_reordering(rlcP, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d -or- VR(UX) <= VR(UR)\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ux, + rlc_pP->vr_uh); +#endif + rlc_um_stop_and_reset_timer_reordering(rlc_pP, frameP); } } } - if (rlcP->t_reordering.running) { - in_window = rlc_um_in_window(rlcP, frame, rlcP->vr_ur, rlcP->vr_ux, rlcP->vr_uh); + if (rlc_pP->t_reordering.running) { + in_window = rlc_um_in_window(rlc_pP, frameP, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh); if ((in_window == -2) || (in_window == 1)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d\n", rlcP->module_id, rlcP->rb_id, frame,rlcP->vr_ux,rlcP->vr_uh); - rlc_um_stop_and_reset_timer_reordering(rlcP, frame); +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] STOP and RESET t-Reordering because VR(UX) falls outside of the reordering window and VR(UX)=%d is not equal to VR(UH)=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ux, + rlc_pP->vr_uh); +#endif + rlc_um_stop_and_reset_timer_reordering(rlc_pP, frameP); } } // -if t-Reordering is not running (includes the case when t-Reordering is @@ -783,12 +1150,20 @@ rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, m // -if VR(UH) > VR(UR): // -start t-Reordering; // -set VR(UX) to VR(UH). - if (rlcP->t_reordering.running == 0) { - in_window = rlc_um_in_window(rlcP, frame, rlcP->vr_ur, rlcP->vr_uh, rlcP->vr_uh); + if (rlc_pP->t_reordering.running == 0) { + in_window = rlc_um_in_window(rlc_pP, frameP, rlc_pP->vr_ur, rlc_pP->vr_uh, rlc_pP->vr_uh); if (in_window == 2) { - rlc_um_start_timer_reordering(rlcP, frame); - rlcP->vr_ux = rlcP->vr_uh; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] RESTART t-Reordering set VR(UX) to VR(UH) =%d\n", rlcP->module_id, rlcP->rb_id, frame,rlcP->vr_ux); + rlc_um_start_timer_reordering(rlc_pP, frameP); + rlc_pP->vr_ux = rlc_pP->vr_uh; +#if defined (TRACE_RLC_UM_DAR) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] RESTART t-Reordering set VR(UX) to VR(UH) =%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ux); +#endif } } } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h index 23695f8d0bca362f4b128da11b51c371b64d3b0d..a0155034714027d1e879ca3a9a9ee109e8e37f16 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_dar.h @@ -62,119 +62,119 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # define public_rlc_um_dar(x) extern x # endif # endif -/*! \fn signed int rlc_um_get_pdu_infos(u32_t frame,rlc_um_pdu_sn_10_t* headerP, s16_t total_sizeP, rlc_um_pdu_info_t* pdu_infoP) +/*! \fn signed int rlc_um_get_pdu_infos(frame_t frameP,rlc_um_pdu_sn_10_t* header_pP, s16_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, u8_t sn_lengthP) * \brief Extract PDU informations (header fields, data size, etc) from the serialized PDU. -* \param[in] frame Frame index. -* \param[in] headerP RLC UM header PDU pointer. -* \param[in] total_sizeP Size of RLC UM PDU. -* \param[in] pdu_infoP Structure containing extracted informations from PDU. -* \param[in] sn_lengthP Sequence number length in bits in PDU header (5 or 10). +* \param[in] frameP Frame index. +* \param[in] header_pP RLC UM header PDU pointer. +* \param[in] total_sizeP Size of RLC UM PDU. +* \param[in] pdu_info_pP Structure containing extracted informations from PDU. +* \param[in] sn_lengthP Sequence number length in bits in PDU header (5 or 10). * \return 0 if no error was encountered during the parsing of the PDU, else -1; */ -protected_rlc_um_dar( signed int rlc_um_get_pdu_infos(u32_t frame, rlc_um_pdu_sn_10_t* headerP, s16_t total_sizeP, rlc_um_pdu_info_t* pdu_infoP, u8_t sn_lengthP)); +protected_rlc_um_dar( signed int rlc_um_get_pdu_infos(frame_t frameP, rlc_um_pdu_sn_10_t* header_pP, s16_t total_sizeP, rlc_um_pdu_info_t* pdu_info_pP, u8_t sn_lengthP)); -/*! \fn int rlc_um_read_length_indicators(unsigned char**dataP, rlc_um_e_li_t* e_liP, unsigned int* li_arrayP, unsigned int *num_liP, unsigned int *data_sizeP) +/*! \fn int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_li_pP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP) * \brief Reset protocol variables and state variables to initial values. -* \param[in,out] dataP Pointer on data payload. -* \param[in] e_liP Pointer on first LI + e bit in PDU. -* \param[in,out] li_arrayP Array containing read LI. -* \param[in,out] num_liP Number of LI read. -* \param[in,out] data_sizeP Pointer on data size. +* \param[in,out] data_ppP Pointer on data payload. +* \param[in] e_li_pP Pointer on first LI + e bit in PDU. +* \param[in,out] li_array_pP Array containing read LI. +* \param[in,out] num_li_pP Pointer on number of LI read. +* \param[in,out] data_size_pP Pointer on data size. * \return 0 if no error was encountered during the parsing of the PDU, else -1; */ -private_rlc_um_dar( int rlc_um_read_length_indicators(unsigned char**dataP, rlc_um_e_li_t* e_liP, unsigned int* li_arrayP, unsigned int *num_liP, unsigned int *data_sizeP)); +private_rlc_um_dar( int rlc_um_read_length_indicators(unsigned char**data_ppP, rlc_um_e_li_t* e_li_pP, unsigned int* li_array_pP, unsigned int *num_li_pP, sdu_size_t *data_size_pP)); -/*! \fn void rlc_um_try_reassembly (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, signed int start_snP, signed int end_snP) +/*! \fn void rlc_um_try_reassembly (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, rlc_sn_t start_snP, rlc_sn_t end_snP) * \brief Try reassembly PDUs from DAR buffer, starting at sequence number snP. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0). +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0). * \param[in] start_snP First PDU to be reassemblied if possible. * \param[in] end_snP Last excluded highest sequence number of PDU to be reassemblied. */ -private_rlc_um_dar( void rlc_um_try_reassembly (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, signed int start_snP, signed int end_snP)); +private_rlc_um_dar( void rlc_um_try_reassembly (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, rlc_sn_t start_snP, rlc_sn_t end_snP)); -/*! \fn void rlc_um_check_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_um_check_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP) * \brief Check if timer reordering has timed-out, if so it is stopped and has the status "timed-out". -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index */ -protected_rlc_um_dar(void rlc_um_check_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame)); +protected_rlc_um_dar(void rlc_um_check_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP)); -/*! \fn void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP) * \brief Stop and reset the timer reordering. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. */ -protected_rlc_um_dar(void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame);) +protected_rlc_um_dar(void rlc_um_stop_and_reset_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_um_start_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_um_start_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP) * \brief Re-arm (based on RLC UM config parameter) and start timer reordering. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. */ -protected_rlc_um_dar(void rlc_um_start_timer_reordering(rlc_um_entity_t *rlcP,u32_t frame);) +protected_rlc_um_dar(void rlc_um_start_timer_reordering(rlc_um_entity_t *rlc_pP,frame_t frameP);) -/*! \fn void rlc_um_init_timer_reordering(rlc_um_entity_t *rlcP, u32_t time_outP) +/*! \fn void rlc_um_init_timer_reordering(rlc_um_entity_t *rlc_pP, u32_t time_outP) * \brief Initialize the timer reordering with RLC UM time-out config parameter. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] time_outP Time-out in frame units. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] time_outP Time-out in frameP units. */ -protected_rlc_um_dar(void rlc_um_init_timer_reordering(rlc_um_entity_t *rlcP, u32_t time_outP);) +protected_rlc_um_dar(void rlc_um_init_timer_reordering(rlc_um_entity_t *rlc_pP, u32_t time_outP);) -/*! \fn void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlcP,u32_t frame,u8_t eNB_flag) +/*! \fn void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlc_pP,frame_t frameP,eNB_flag_t eNB_flagP) * \brief Check if t-Reordering expires and take the appropriate actions as described in 3GPP specifications. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB(1) or UE (1) +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB(1) or UE (1) */ -protected_rlc_um_dar( void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlcP,u32_t frame,u8_t eNB_flag)); +protected_rlc_um_dar( void rlc_um_check_timer_dar_time_out(rlc_um_entity_t *rlc_pP,frame_t frameP,eNB_flag_t eNB_flagP)); -/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP) +/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, u16_t snP) * \brief Remove the PDU with sequence number snP from the DAR buffer and return it. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] snP Sequence number. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] snP Sequence number. * \return The PDU stored in the DAR buffer having sequence number snP, else return NULL. */ -private_rlc_um_dar( mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP)); +private_rlc_um_dar( mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, u16_t snP)); -/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP) +/*! \fn mem_block_t *rlc_um_remove_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, u16_t snP) * \brief Get the PDU with sequence number snP from the DAR buffer. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] snP Sequence number. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] snP Sequence number. * \return The PDU stored in the DAR buffer having sequence number snP, else return NULL. */ -protected_rlc_um_dar( inline mem_block_t* rlc_um_get_pdu_from_dar_buffer(rlc_um_entity_t *rlcP, u16_t snP)); +protected_rlc_um_dar( inline mem_block_t* rlc_um_get_pdu_from_dar_buffer(rlc_um_entity_t *rlc_pP, u16_t snP)); -/*! \fn signed int rlc_um_in_window(rlc_um_entity_t *rlcP, u32_t frame, signed int lower_boundP, signed int snP, signed int higher_boundP) +/*! \fn signed int rlc_um_in_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t lower_boundP, rlc_sn_t snP, rlc_sn_t higher_boundP) * \brief Compute if the sequence number of a PDU is in a window . -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. * \param[in] lower_boundP Lower bound of a window. * \param[in] snP Sequence number of a theorical PDU. * \param[in] higher_boundP Higher bound of a window. * \return -2 if lower_boundP > sn, -1 if higher_boundP < sn, 0 if lower_boundP < sn < higher_boundP, 1 if lower_boundP == sn, 2 if higher_boundP == sn, 3 if higher_boundP == sn == lower_boundP. */ -protected_rlc_um_dar(inline signed int rlc_um_in_window(rlc_um_entity_t *rlcP, u32_t frame, signed int lower_boundP, signed int snP, signed int higher_boundP)); +protected_rlc_um_dar(inline signed int rlc_um_in_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t lower_boundP, rlc_sn_t snP, rlc_sn_t higher_boundP)); -/*! \fn signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlcP, u32_t frame, signed int snP) +/*! \fn signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP) * \brief Compute if the sequence number of a PDU is in a window . -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. * \param[in] snP Sequence number of a theorical PDU. * \return 0 if snP is in reordering window, else -1. */ -protected_rlc_um_dar(inline signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlcP, u32_t frame, signed int snP)); +protected_rlc_um_dar(inline signed int rlc_um_in_reordering_window(rlc_um_entity_t *rlc_pP, frame_t frameP, rlc_sn_t snP)); -/*! \fn void rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t *pdu_memP,rlc_um_pdu_sn_10_t *pduP, u16_t tb_sizeP) +/*! \fn void rlc_um_receive_process_dar (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t *pdu_mem_pP,rlc_um_pdu_sn_10_t *pdu_pP, sdu_size_t tb_sizeP) * \brief Apply the DAR process for a PDU: put it in DAR buffer and try to reassembly or discard it. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicated eNB (1) or UE (0). -* \param[in] pdu_memP mem_block_t wrapper for a UM PDU . -* \param[in] pduP Pointer on the header of the UM PDU. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicated eNB (1) or UE (0). +* \param[in] pdu_mem_pP mem_block_t wrapper for a UM PDU . +* \param[in] pdu_pP Pointer on the header of the UM PDU. * \param[in] tb_sizeP Size of the UM PDU. */ -protected_rlc_um_dar(void rlc_um_receive_process_dar (rlc_um_entity_t *rlcP, u32_t frame, u8_t eNB_flag, mem_block_t *pdu_memP,rlc_um_pdu_sn_10_t *pduP, u16_t tb_sizeP)); +protected_rlc_um_dar(void rlc_um_receive_process_dar (rlc_um_entity_t *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, mem_block_t *pdu_mem_pP,rlc_um_pdu_sn_10_t *pdu_pP, sdu_size_t tb_sizeP)); /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h index e066badcbe1b7f36dd97ad7530bc85039a3897d8..b90399171339dad78f8c8f084e7bd172bc7100c7 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_entity.h @@ -59,7 +59,8 @@ typedef struct rlc_um_timer { */ typedef struct rlc_um_entity { - module_id_t module_id; /*!< \brief Virtualization index for this protocol instance, means handset or eNB index.*/ + module_id_t enb_module_id; /*!< \brief eNB Virtualization index for this protocol instance, meaningful if is_enb is set. */ + module_id_t ue_module_id; /*!< \brief UE Virtualization index for this protocol instance. */ u8_t allocation; /*!< \brief Boolean for rlc_am_entity_t struct allocation. */ u8_t is_uplink_downlink; /*!< \brief Is this instance is a transmitter, a receiver or both? */ u8_t protocol_state; /*!< \brief Protocol state, can be RLC_NULL_STATE, RLC_DATA_TRANSFER_READY_STATE, RLC_LOCAL_SUSPEND_STATE. */ @@ -114,7 +115,8 @@ typedef struct rlc_um_entity { mem_block_t *dar_buffer_alloc; /*!< \brief Allocated memory for the DAR buffer. */ list_t pdus_from_mac_layer; /*!< \brief Not Used. */ - u16_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ + logical_chan_id_t channel_id; /*!< \brief Transport channel identifier. */ + rb_id_t rb_id; /*!< \brief Radio bearer identifier, for statistics and trace purpose. */ u16_t last_reassemblied_sn; /*!< \brief Sequence number of the last reassemblied PDU. */ u16_t last_reassemblied_missing_sn; /*!< \brief Sequence number of the last found missing PDU. */ u16_t reassembly_missing_sn_detected; /*!< \brief Act as a boolean, set if a hole in the sequence numbering of received PDUs has been found. */ diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c index acb7d8b439ff2a9406415442caee8fd134c8c67d..a3584dbb37a7ecdfc8f4f0b8be256640482ad7ed 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_fsm.c @@ -38,24 +38,33 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis //----------------------------------------------------------------------------- int -rlc_um_fsm_notify_event (struct rlc_um_entity *rlcP, u8_t eventP) +rlc_um_fsm_notify_event (struct rlc_um_entity *rlc_pP, u8_t eventP) { //----------------------------------------------------------------------------- - switch (rlcP->protocol_state) { + switch (rlc_pP->protocol_state) { //------------------------------- // RLC_NULL_STATE //------------------------------- case RLC_NULL_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_DATA_TRANSFER_READY_STATE_EVENT: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d] FSM RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", rlcP->module_id, rlcP->rb_id); - rlcP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; + LOG_D(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_NULL_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", rlcP->module_id, rlcP->rb_id, eventP); + LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM NULL_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + eventP); mac_xface->macphy_exit(""); return 0; } @@ -66,20 +75,33 @@ rlc_um_fsm_notify_event (struct rlc_um_entity *rlcP, u8_t eventP) case RLC_DATA_TRANSFER_READY_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", rlcP->module_id, rlcP->rb_id); - rlcP->protocol_state = RLC_NULL_STATE; + LOG_D(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_NULL_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->protocol_state = RLC_NULL_STATE; return 1; break; case RLC_UM_RECEIVE_CRLC_SUSPEND_REQ_EVENT: case RLC_UM_TRANSMIT_CRLC_SUSPEND_CNF_EVENT: - LOG_N(RLC, "[RLC_UM][MOD %d][RB %d] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_LOCAL_SUSPEND_STATE\n", rlcP->module_id, rlcP->rb_id); - rlcP->protocol_state = RLC_LOCAL_SUSPEND_STATE; + LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_DATA_TRANSFER_READY_STATE -> RLC_LOCAL_SUSPEND_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->protocol_state = RLC_LOCAL_SUSPEND_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM DATA_TRANSFER_READY_STATE\n", rlcP->module_id, rlcP->rb_id, eventP); + LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM DATA_TRANSFER_READY_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + eventP); return 0; } break; @@ -89,25 +111,43 @@ rlc_um_fsm_notify_event (struct rlc_um_entity *rlcP, u8_t eventP) case RLC_LOCAL_SUSPEND_STATE: switch (eventP) { case RLC_UM_RECEIVE_CRLC_CONFIG_REQ_ENTER_NULL_STATE_EVENT: - LOG_N(RLC, "[RLC_UM][MOD %d][RB %d] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_NULL_STATE\n", rlcP->module_id, rlcP->rb_id); - rlcP->protocol_state = RLC_NULL_STATE; + LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_NULL_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->protocol_state = RLC_NULL_STATE; return 1; break; case RLC_UM_RECEIVE_CRLC_RESUME_REQ_EVENT: - LOG_N(RLC, "[RLC_UM][MOD %d][RB %d] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", rlcP->module_id, rlcP->rb_id); - rlcP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; + LOG_N(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM RLC_LOCAL_SUSPEND_STATE -> RLC_DATA_TRANSFER_READY_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_pP->protocol_state = RLC_DATA_TRANSFER_READY_STATE; return 1; break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE\n", rlcP->module_id, rlcP->rb_id, eventP); + LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM WARNING PROTOCOL ERROR - EVENT %02X hex NOT EXPECTED FROM RLC_LOCAL_SUSPEND_STATE\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + eventP); return 0; } break; default: - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d] FSM ERROR UNKNOWN STATE %d\n", rlcP->module_id, rlcP->rb_id, rlcP->protocol_state); + LOG_E(RLC, "[RLC_UM][%s][MOD %u/%u][RB %u] FSM ERROR UNKNOWN STATE %d\n", + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->protocol_state); return 0; } } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c index 355ce6744f607b854e468a3a2a75ecd219a33ce5..aae64633e99cb598ab974e4203027195a3dc05ea 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.c @@ -33,6 +33,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #ifdef USER_MODE #include <string.h> #endif +#include "assertions.h" #include "rlc.h" #include "rlc_um.h" #include "rlc_primitives.h" @@ -40,101 +41,144 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" -//#define DEBUG_RLC_UM_DISPLAY_ASCII_DATA 1 +//#define TRACE_RLC_UM_DISPLAY_ASCII_DATA 1 //----------------------------------------------------------------------------- inline void -rlc_um_clear_rx_sdu (rlc_um_entity_t *rlcP) +rlc_um_clear_rx_sdu (rlc_um_entity_t *rlc_pP) { //----------------------------------------------------------------------------- - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; } //----------------------------------------------------------------------------- void -rlc_um_reassembly (u8_t * srcP, s32_t lengthP, rlc_um_entity_t *rlcP,u32_t frame) +rlc_um_reassembly (u8_t * src_pP, s32_t lengthP, rlc_um_entity_t *rlc_pP, frame_t frameP) { //----------------------------------------------------------------------------- - int sdu_max_size; -#ifdef DEBUG_RLC_UM_DISPLAY_ASCII_DATA - int index; -#endif + sdu_size_t sdu_max_size; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", rlcP->module_id, rlcP->rb_id, frame, lengthP, rlcP->output_sdu_size_to_write); + LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][REASSEMBLY] reassembly() %d bytes %d bytes already reassemblied\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + lengthP, + rlc_pP->output_sdu_size_to_write); if (lengthP <= 0) { return; } - if ((rlcP->is_data_plane)) { - sdu_max_size = RLC_SDU_MAX_SIZE_DATA_PLANE; + if ((rlc_pP->is_data_plane)) { + sdu_max_size = RLC_SDU_MAX_SIZE_DATA_PLANE; } else { - sdu_max_size = RLC_SDU_MAX_SIZE_CONTROL_PLANE; + sdu_max_size = RLC_SDU_MAX_SIZE_CONTROL_PLANE; } - if (rlcP->output_sdu_in_construction == NULL) { - // msg("[RLC_UM_LITE] Getting mem_block ...\n"); - rlcP->output_sdu_in_construction = get_free_mem_block (sdu_max_size); - rlcP->output_sdu_size_to_write = 0; + if (rlc_pP->output_sdu_in_construction == NULL) { + // msg("[RLC_UM_LITE] Getting mem_block ...\n"); + rlc_pP->output_sdu_in_construction = get_free_mem_block (sdu_max_size); + rlc_pP->output_sdu_size_to_write = 0; } - if ((rlcP->output_sdu_in_construction)) { - - // check if no overflow in size - if ((rlcP->output_sdu_size_to_write + lengthP) <= sdu_max_size) { - memcpy (&rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write], srcP, lengthP); - rlcP->output_sdu_size_to_write += lengthP; -#ifdef DEBUG_RLC_UM_DISPLAY_ASCII_DATA - rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write] = 0; - LOG_T(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][REASSEMBLY] DATA :", rlcP->module_id, rlcP->rb_id, frame); - rlc_util_print_hex_octets(RLC, (unsigned char*)rlcP->output_sdu_in_construction->data, rlcP->output_sdu_size_to_write); + if ((rlc_pP->output_sdu_in_construction)) { + // check if no overflow in size + if ((rlc_pP->output_sdu_size_to_write + lengthP) <= sdu_max_size) { + memcpy (&rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write], src_pP, lengthP); + rlc_pP->output_sdu_size_to_write += lengthP; +#ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA + rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; + LOG_T(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][REASSEMBLY] DATA :", + frameP + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_util_print_hex_octets(RLC, (unsigned char*)rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif - } else { - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", rlcP->module_id, rlcP->rb_id, frame, sdu_max_size); - // erase SDU - rlcP->output_sdu_size_to_write = 0; - } + } else { +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u] RLC_UM_DATA_IND, SDU TOO BIG, DROPPED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif + LOG_E(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][REASSEMBLY] [max_sdu size %d] ERROR SDU SIZE OVERFLOW SDU GARBAGED\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_max_size); + // erase SDU + rlc_pP->output_sdu_size_to_write = 0; + } } else { - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", rlcP->module_id, rlcP->rb_id, frame); + LOG_E(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][REASSEMBLY]ERROR OUTPUT SDU IS NULL\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#if defined(STOP_ON_IP_TRAFFIC_OVERLOAD) + AssertFatal(0, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u] RLC_UM_DATA_IND, SDU DROPPED, OUT OF MEMORY\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif } } //----------------------------------------------------------------------------- void -rlc_um_send_sdu (rlc_um_entity_t *rlcP,u32_t frame, u8_t eNB_flag) +rlc_um_send_sdu (rlc_um_entity_t *rlc_pP,frame_t frameP, eNB_flag_t eNB_flagP) { //----------------------------------------------------------------------------- - if ((rlcP->output_sdu_in_construction)) { - LOG_D(RLC, "\n\n\n[RLC_UM][MOD %d][RB %d][FRAME %05d][SEND_SDU] %d bytes sdu %p\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction); - - if (rlcP->output_sdu_size_to_write > 0) { - u8_t UE_id, eNB_id; - if (eNB_flag == 0) { - UE_id = rlcP->module_id - NB_eNB_INST; - /* FIXME: force send on eNB 0 */ - eNB_id = 0; - } else { - UE_id = rlcP->rb_id / NB_RB_MAX; - eNB_id = rlcP->module_id; - } - rlcP->stat_rx_pdcp_sdu += 1; - rlcP->stat_rx_pdcp_bytes += rlcP->output_sdu_size_to_write; + if ((rlc_pP->output_sdu_in_construction)) { + LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u] SEND_SDU to upper layers %d bytes sdu %p\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->output_sdu_size_to_write, + rlc_pP->output_sdu_in_construction); + + if (rlc_pP->output_sdu_size_to_write > 0) { + rlc_pP->stat_rx_pdcp_sdu += 1; + rlc_pP->stat_rx_pdcp_bytes += rlc_pP->output_sdu_size_to_write; #ifdef TEST_RLC_UM - #ifdef DEBUG_RLC_UM_DISPLAY_ASCII_DATA - rlcP->output_sdu_in_construction->data[rlcP->output_sdu_size_to_write] = 0; - LOG_T(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][SEND_SDU] DATA :", rlcP->module_id, rlcP->rb_id, frame); - rlc_util_print_hex_octets(RLC, rlcP->output_sdu_in_construction->data, rlcP->output_sdu_size_to_write); + #ifdef TRACE_RLC_UM_DISPLAY_ASCII_DATA + rlc_pP->output_sdu_in_construction->data[rlc_pP->output_sdu_size_to_write] = 0; + LOG_T(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][SEND_SDU] DATA :", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); + rlc_util_print_hex_octets(RLC, rlc_pP->output_sdu_in_construction->data, rlc_pP->output_sdu_size_to_write); #endif - rlc_um_v9_3_0_test_data_ind (rlcP->module_id, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction); + rlc_um_v9_3_0_test_data_ind (rlc_pP->module_id, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction); #else - // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlcP->module_id, rlcP->rb_id, frame,rlcP->output_sdu_size_to_write); - rlc_data_ind (rlcP->module_id, eNB_id, UE_id, frame, eNB_flag, rlcP->is_mxch, rlcP->rb_id, rlcP->output_sdu_size_to_write, rlcP->output_sdu_in_construction,rlcP->is_data_plane); + // msg("[RLC] DATA IND ON MOD_ID %d RB ID %d, size %d\n",rlc_pP->module_id, rlc_pP->rb_id, frameP,rlc_pP->output_sdu_size_to_write); + rlc_data_ind (rlc_pP->enb_module_id, rlc_pP->ue_module_id, frameP, eNB_flagP, rlc_pP->is_mxch, rlc_pP->rb_id, rlc_pP->output_sdu_size_to_write, rlc_pP->output_sdu_in_construction,rlc_pP->is_data_plane); #endif - rlcP->output_sdu_in_construction = NULL; + rlc_pP->output_sdu_in_construction = NULL; } else { - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n",rlcP->module_id, rlcP->rb_id, frame); + LOG_E(RLC, "[FRAME %5u][%s][RLC_UM][MOD %u/%u][RB %u][SEND_SDU] ERROR SIZE <= 0 ... DO NOTHING, SET SDU SIZE TO 0\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); } - rlcP->output_sdu_size_to_write = 0; + rlc_pP->output_sdu_size_to_write = 0; } } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h index 90160acc2c8e0b7d3fc6274b106f210029a6ebba..c4123b5dab38f4d6f6eba2b81ca990dcf63fab7c 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_reassembly.h @@ -65,20 +65,21 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis */ protected_rlc_um_reassembly(void rlc_um_clear_rx_sdu (rlc_um_entity_t *rlcP)); -/*! \fn void rlc_um_reassembly (u8_t * srcP, s32_t lengthP, rlc_um_entity_t *rlcP) +/*! \fn void rlc_um_reassembly (u8_t * srcP, s32_t lengthP, rlc_um_entity_t *rlcP, frame_t frame) * \brief Reassembly lengthP bytes to the end of the SDU in construction. * \param[in] srcP Pointer on data to be reassemblied. * \param[in] lengthP Length to reassembly. * \param[in] rlcP RLC UM protocol instance pointer. * \param[in] frame Frame index. */ -protected_rlc_um_reassembly(void rlc_um_reassembly (u8_t * srcP, s32_t lengthP, rlc_um_entity_t *rlcP, u32_t frame)); +protected_rlc_um_reassembly(void rlc_um_reassembly (u8_t * srcP, s32_t lengthP, rlc_um_entity_t *rlcP, frame_t frame)); -/*! \fn void rlc_um_send_sdu (rlc_um_entity_t *rlcP,u32_t frame) +/*! \fn void rlc_um_send_sdu (rlc_um_entity_t *rlcP,frame_t frame,eNB_flag_t eNB_flagP) * \brief Send SDU if any reassemblied to upper layer. * \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Boolean to know if rlcP is in eNB (1 or true), or in UE (0 or false). */ -protected_rlc_um_reassembly(void rlc_um_send_sdu (rlc_um_entity_t *rlcP,u32_t frame,u8 eNB_flag)); +protected_rlc_um_reassembly(void rlc_um_send_sdu (rlc_um_entity_t *rlcP,frame_t frameP,eNB_flag_t eNB_flagP)); /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c index 217066818e64fcfb56d34d8558843d838f0ec2f7..59cb7a3f40ee1cce37896a9af2b81efc9082f8af 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.c @@ -43,7 +43,7 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #define DEBUG_RLC_UM_RX //----------------------------------------------------------------------------- -void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) +void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP) //----------------------------------------------------------------------------- { /* @@ -73,21 +73,21 @@ void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) */ unsigned long sn = 0; unsigned long end_sn = 0; - char str[4]; - char time_out_str[11]; - int str_index; - char color[32]; + char str[4]; + char time_out_str[11]; + int str_index; + char color[32]; LOG_T(RLC, "\n"); LOG_T(RLC, "+-------------------------------------------------------------------------------------------------------+"); LOG_T(RLC, "\n"); - sprintf(time_out_str, "%010d", rlcP->t_reordering.frame_time_out); + sprintf(time_out_str, "%010d", rlc_pP->t_reordering.frame_time_out); time_out_str[10] = 0; LOG_T(RLC, "| RLC UM RB %02d VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d t-Reordering: %s %s %s |", - rlcP->rb_id, rlcP->vr_ur, rlcP->vr_ux, rlcP->vr_uh, - (rlcP->t_reordering.running)?" ON":"OFF", - (rlcP->t_reordering.running)?"Time-out frame:":" ", - (rlcP->t_reordering.running)?time_out_str:" "); + rlc_pP->rb_id, rlc_pP->vr_ur, rlc_pP->vr_ux, rlc_pP->vr_uh, + (rlc_pP->t_reordering.running)?" ON":"OFF", + (rlc_pP->t_reordering.running)?"Time-out frameP:":" ", + (rlc_pP->t_reordering.running)?time_out_str:" "); LOG_T(RLC, "\n"); LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+"); LOG_T(RLC, "\n"); @@ -95,7 +95,7 @@ void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) LOG_T(RLC, "\n"); LOG_T(RLC, "+------+------------------------------------------------------------------------------------------------+"); LOG_T(RLC, "\n"); - if (rlcP->rx_sn_length == 10) { + if (rlc_pP->rx_sn_length == 10) { end_sn = RLC_UM_SN_10_BITS_MODULO; } else { end_sn = RLC_UM_SN_5_BITS_MODULO; @@ -116,20 +116,20 @@ void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) LOG_T(RLC, "%s%s| %04d |", RLC_FG_COLOR_DEFAULT, RLC_NORMAL_VIDEO, sn); } strcpy(color, RLC_FG_COLOR_DEFAULT); - if (sn == rlcP->vr_ur) { + if (sn == rlc_pP->vr_ur) { str[str_index++] = 'R'; strcpy(color, RLC_FG_COLOR_BLUE); } - if (sn == rlcP->vr_ux) { + if (sn == rlc_pP->vr_ux) { str[str_index++] = 'X'; strcpy(color, RLC_FG_COLOR_ORANGE); } - if (sn == rlcP->vr_uh) { + if (sn == rlc_pP->vr_uh) { str[str_index++] = 'H'; strcpy(color, RLC_FG_COLOR_RED); } - if (rlc_um_get_pdu_from_dar_buffer(rlcP, sn)) { + if (rlc_um_get_pdu_from_dar_buffer(rlc_pP, sn)) { // test RLC_REVERSE_VIDEO if (str_index <= 2) str[str_index] = '.'; LOG_T(RLC, "%s%s%s", color, RLC_REVERSE_VIDEO, str); @@ -145,26 +145,34 @@ void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) //----------------------------------------------------------------------------- void -rlc_um_receive (struct rlc_um_entity *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP) +rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP) { //----------------------------------------------------------------------------- - mem_block_t *tb; - u8_t *first_byte; - u16_t tb_size_in_bytes; - - while ((tb = list_remove_head (&data_indP.data))) { - - first_byte = ((struct mac_tb_ind *) (tb->data))->data_ptr; - tb_size_in_bytes = ((struct mac_tb_ind *) (tb->data))->size; - - rlcP->stat_rx_data_bytes += tb_size_in_bytes; - rlcP->stat_rx_data_pdu += 1; - - if (tb_size_in_bytes > 0) { - rlc_um_receive_process_dar (rlcP, frame, eNB_flag, tb, (rlc_um_pdu_sn_10_t *)first_byte, tb_size_in_bytes); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", rlcP->module_id, rlcP->rb_id, frame, rlcP->vr_ur, rlcP->vr_ux, rlcP->vr_uh); - rlc_um_display_rx_window(rlcP); - } + mem_block_t *tb_p = NULL; + u8_t *first_byte_p = NULL; + u16_t tb_size_in_bytes = 0; + + while ((tb_p = list_remove_head (&data_indP.data))) { + + first_byte_p = ((struct mac_tb_ind *) (tb_p->data))->data_ptr; + tb_size_in_bytes = ((struct mac_tb_ind *) (tb_p->data))->size; + + rlc_pP->stat_rx_data_bytes += tb_size_in_bytes; + rlc_pP->stat_rx_data_pdu += 1; + + if (tb_size_in_bytes > 0) { + rlc_um_receive_process_dar (rlc_pP, frameP, eNB_flagP, tb_p, (rlc_um_pdu_sn_10_t *)first_byte_p, tb_size_in_bytes); + LOG_D(RLC, "[FRAME %05d][%s][RLC_UM][MOD %u/%u][RB %u] VR(UR)=%03d VR(UX)=%03d VR(UH)=%03d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + rlc_pP->vr_ur, + rlc_pP->vr_ux, + rlc_pP->vr_uh); + rlc_um_display_rx_window(rlc_pP); + } } } diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h index 82ecdbe1b0449461b331c8406a19a27ab7de17d2..b1a465fe20888b1055d7907dc3d4c98169c4be3b 100644 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_receiver.h @@ -59,18 +59,19 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis # include "rlc_um_entity.h" # include "mac_primitives.h" -/*! \fn void rlc_um_display_rx_window(struct rlc_um_entity *rlcP) +/*! \fn void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP) * \brief Display the content of the RX buffer, the output stream is targeted to TTY terminals because of escape sequences. -* \param[in] rlcP RLC UM protocol instance pointer. +* \param[in] rlc_pP RLC UM protocol instance pointer. */ -protected_rlc_um_receiver( void rlc_um_display_rx_window(struct rlc_um_entity *rlcP);) +protected_rlc_um_receiver( void rlc_um_display_rx_window(struct rlc_um_entity *rlc_pP);) -/*! \fn void rlc_um_receive (struct rlc_um_entity *rlcP, u32_t frame, struct mac_data_ind data_indP) +/*! \fn void rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, struct mac_data_ind data_indP) * \brief Handle the MAC data indication, retreive the transport blocks and send them one by one to the DAR process. -* \param[in] rlcP RLC UM protocol instance pointer. -* \param[in] frame Frame index. +* \param[in] rlc_pP RLC UM protocol instance pointer. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicated eNB (1) or UE (0). * \param[in] data_indP Data indication structure containing transport block received from MAC layer. */ -protected_rlc_um_receiver( void rlc_um_receive (struct rlc_um_entity *rlcP, u32_t frame, u8_t eNB_flag, struct mac_data_ind data_indP)); +protected_rlc_um_receiver( void rlc_um_receive (struct rlc_um_entity *rlc_pP, frame_t frameP, eNB_flag_t eNB_flagP, struct mac_data_ind data_indP)); /** @} */ # endif diff --git a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c index cd0ed1211fb46cb19c4ed17661a71d402e1a95be..91d6f9120a152249378252f2e0ebb5072cc1323c 100755 --- a/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c +++ b/openair2/LAYER2/RLC/UM_v9.3.0/rlc_um_segment.c @@ -42,24 +42,24 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "MAC_INTERFACE/extern.h" #include "UTIL/LOG/log.h" -#define RLC_UM_SEGMENT +//#define TRACE_RLC_UM_SEGMENT 1 //----------------------------------------------------------------------------- void -rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) +rlc_um_segment_10 (struct rlc_um_entity *rlc_pP,frame_t frameP) { //----------------------------------------------------------------------------- list_t pdus; signed int pdu_remaining_size; signed int test_pdu_remaining_size; - int nb_bytes_to_transmit = rlcP->nb_bytes_requested_by_mac; - rlc_um_pdu_sn_10_t *pdu; - struct mac_tb_req *pdu_tb_req; - mem_block_t *pdu_mem; + int nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac; + rlc_um_pdu_sn_10_t *pdu_p; + struct mac_tb_req *pdu_tb_req_p; + mem_block_t *pdu_mem_p; char *data; - char *data_sdu; - rlc_um_e_li_t *e_li; - struct rlc_um_tx_sdu_management *sdu_mngt; + char *data_sdu_p; + rlc_um_e_li_t *e_li_p; + struct rlc_um_tx_sdu_management *sdu_mngt_p; unsigned int li_length_in_bytes; unsigned int test_li_length_in_bytes; unsigned int test_remaining_size_to_substract; @@ -77,39 +77,89 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) unsigned int max_li_overhead; if (nb_bytes_to_transmit < 3) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] NO SEGMENTATION nb_bytes to transmit = %d\n", rlcP->module_id, rlcP->rb_id, frame, nb_bytes_to_transmit); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] NO SEGMENTATION nb_bytes to transmit = %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bytes_to_transmit); +#endif return; } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10\n", rlcP->module_id, rlcP->rb_id, frame); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10\n", rlc_pP->module_id, rlc_pP->rb_id, frameP); +#endif list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem = NULL; - - while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 nb_bytes_to_transmit %d BO %d\n", rlcP->module_id, rlcP->rb_id, frame, nb_bytes_to_transmit, rlcP->buffer_occupancy); - // pdu management - if (!pdu_mem) { - if (rlcP->nb_sdu <= 1) { + pdu_mem_p = NULL; + + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 nb_bytes_to_transmit %d BO %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bytes_to_transmit, + rlc_pP->buffer_occupancy); +#endif + // pdu_p management + if (!pdu_mem_p) { + if (rlc_pP->nb_sdu <= 1) { max_li_overhead = 0; } else { - max_li_overhead = (((rlcP->nb_sdu - 1) * 3) / 2) + ((rlcP->nb_sdu - 1) % 2); + max_li_overhead = (((rlc_pP->nb_sdu - 1) * 3) / 2) + ((rlc_pP->nb_sdu - 1) % 2); } - if (nb_bytes_to_transmit >= (rlcP->buffer_occupancy + rlcP->tx_header_min_length_in_bytes + max_li_overhead)) { - data_pdu_size = rlcP->buffer_occupancy + rlcP->tx_header_min_length_in_bytes + max_li_overhead; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); + if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) { + data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif } else { data_pdu_size = nb_bytes_to_transmit; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif } - if (!(pdu_mem = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP->module_id, rlcP->rb_id, frame); + if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 ERROR COULD NOT GET NEW PDU, EXIT\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif return; } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 get new PDU %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 get new PDU %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif pdu_remaining_size = data_pdu_size - 2; - pdu = (rlc_um_pdu_sn_10_t*) (&pdu_mem->data[sizeof(struct mac_tb_req)]); - pdu_tb_req = (struct mac_tb_req*) (pdu_mem->data); + pdu_p = (rlc_um_pdu_sn_10_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); + pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); - memset (pdu_mem->data, 0, sizeof (rlc_um_pdu_sn_10_t)+sizeof(struct mac_tb_req)); + memset (pdu_mem_p->data, 0, sizeof (rlc_um_pdu_sn_10_t)+sizeof(struct mac_tb_req)); li_length_in_bytes = 1; } //---------------------------------------- @@ -118,31 +168,31 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) continue_fill_pdu_with_sdu = 1; num_fill_sdu = 0; test_num_li = 0; - sdu_buffer_index = rlcP->current_sdu_index; + sdu_buffer_index = rlc_pP->current_sdu_index; test_pdu_remaining_size = pdu_remaining_size; test_li_length_in_bytes = 1; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - while ((rlcP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[sdu_buffer_index]->data)); + while ((rlc_pP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[sdu_buffer_index]->data)); - if (sdu_mngt->sdu_remaining_size > test_pdu_remaining_size) { + if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt->sdu_remaining_size == test_pdu_remaining_size) { + } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -150,15 +200,25 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { test_num_li += 1; num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); + test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; test_remaining_num_li_to_substract = 1; test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 sdu_mngt->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + test_pdu_remaining_size, + test_li_length_in_bytes ^ 3); +#endif // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -167,7 +227,7 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) test_remaining_num_li_to_substract = 0; pdu_remaining_size = pdu_remaining_size - 1; } - sdu_buffer_index = (sdu_buffer_index + 1) % rlcP->size_input_sdus_buffer; + sdu_buffer_index = (sdu_buffer_index + 1) % rlc_pP->size_input_sdus_buffer; } if (test_remaining_num_li_to_substract > 0) { // there is a LI that is not necessary @@ -175,12 +235,21 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; } //---------------------------------------- - // Do the real filling of the pdu + // Do the real filling of the pdu_p //---------------------------------------- - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] data shift %d Bytes num_li %d\n", rlcP->module_id, rlcP->rb_id, frame, ((test_num_li*3) +1) >> 1, test_num_li); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + ((test_num_li*3) +1) >> 1, + test_num_li); +#endif - data = ((char*)(&pdu->data[((test_num_li*3) +1) >> 1])); - e_li = (rlc_um_e_li_t*)(pdu->data); + data = ((char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); + e_li_p = (rlc_um_e_li_t*)(pdu_p->data); continue_fill_pdu_with_sdu = 1; li_length_in_bytes = 1; fill_num_li = 0; @@ -188,111 +257,187 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) fi_last_byte_pdu_is_last_byte_sdu = 0; if ( - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size == - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size) { + ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_remaining_size == + ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_size) { fi_first_byte_pdu_is_first_byte_sdu = 1; } - while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); - if (sdu_mngt->sdu_segmented_size == 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt, sdu_mngt->sdu_remaining_size); + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data)); + if (sdu_mngt_p->sdu_segmented_size == 0) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size); +#endif } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size, + sdu_mngt_p->sdu_size); +#endif } - data_sdu = &((rlcP->input_sdus[rlcP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt->sdu_segmented_size]); - - if (sdu_mngt->sdu_remaining_size > pdu_remaining_size) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 Filling all remaining PDU with %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, pdu_remaining_size); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 pdu_mem %p pdu_mem->data %p pdu %p pdu->data %p data %p data_sdu %p pdu_remaining_size %d\n", - rlcP->module_id,\ - rlcP->rb_id, - frame, - pdu_mem, - pdu_mem->data, - pdu, - pdu->data, - data, - data_sdu, - pdu_remaining_size); - - memcpy(data, data_sdu, pdu_remaining_size); - sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; - sdu_mngt->sdu_segmented_size = sdu_mngt->sdu_segmented_size + pdu_remaining_size; + data_sdu_p = &((rlc_pP->input_sdus[rlc_pP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]); + + if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling all remaining PDU with %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 pdu_mem_p %p pdu_mem_p->data %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_mem_p, + pdu_mem_p->data, + pdu_p, + pdu_p->data, + data, + data_sdu_p, + pdu_remaining_size); +#endif + + memcpy(data, data_sdu_p, pdu_remaining_size); + sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; + sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; fi_last_byte_pdu_is_last_byte_sdu = 0; // no LI - rlcP->buffer_occupancy -= pdu_remaining_size; + rlc_pP->buffer_occupancy -= pdu_remaining_size; continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - } else if (sdu_mngt->sdu_remaining_size == pdu_remaining_size) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", rlcP->module_id, rlcP->rb_id, frame, pdu_remaining_size); - memcpy(data, data_sdu, pdu_remaining_size); + } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); +#endif + memcpy(data, data_sdu_p, pdu_remaining_size); // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; fi_last_byte_pdu_is_last_byte_sdu = 1; // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - } else if ((sdu_mngt->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 Filling PDU with %d all remaining bytes of SDU\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size); - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); - data = &data[sdu_mngt->sdu_remaining_size]; + } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling PDU with %d all remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size); +#endif + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); + data = &data[sdu_mngt_p->sdu_remaining_size]; li_length_in_bytes = li_length_in_bytes ^ 3; fill_num_li += 1; if (li_length_in_bytes == 2) { if (fill_num_li == test_num_li) { - //e_li->e1 = 0; - e_li->b1 = 0; + //e_li_p->e1 = 0; + e_li_p->b1 = 0; } else { - //e_li->e1 = 1; - e_li->b1 = 0x80; + //e_li_p->e1 = 1; + e_li_p->b1 = 0x80; } - //e_li->li1 = sdu_mngt->sdu_remaining_size; - e_li->b1 = e_li->b1 | (sdu_mngt->sdu_remaining_size >> 4); - e_li->b2 = sdu_mngt->sdu_remaining_size << 4; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 set e_li->b1=%02X set e_li->b2=%02X fill_num_li=%d test_num_li=%d\n", rlcP->module_id, rlcP->rb_id, frame, e_li->b1, e_li->b2, fill_num_li, test_num_li); + //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); + e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b1, + e_li_p->b2, + fill_num_li, + test_num_li); +#endif } else { if (fill_num_li != test_num_li) { - //e_li->e2 = 1; - e_li->b2 = e_li->b2 | 0x08; + //e_li_p->e2 = 1; + e_li_p->b2 = e_li_p->b2 | 0x08; } - //e_li->li2 = sdu_mngt->sdu_remaining_size; - e_li->b2 = e_li->b2 | (sdu_mngt->sdu_remaining_size >> 8); - e_li->b3 = sdu_mngt->sdu_remaining_size & 0xFF; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 set e_li->b2=%02X set e_li->b3=%02X fill_num_li=%d test_num_li=%d\n", rlcP->module_id, rlcP->rb_id, frame, e_li->b2, e_li->b3, fill_num_li, test_num_li); - e_li++; + //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); + e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b2, + e_li_p->b3, + fill_num_li, + test_num_li); +#endif + e_li_p++; } // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; - pdu_remaining_size = pdu_remaining_size - (sdu_mngt->sdu_remaining_size + li_length_in_bytes); + pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes); } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT10 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size, pdu_remaining_size - sdu_mngt->sdu_remaining_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT10 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); +#endif #ifdef USER_MODE assert(1!=1); #endif - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; fi_last_byte_pdu_is_last_byte_sdu = 1; - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size; + pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; } } @@ -305,24 +450,24 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) if (!fi_last_byte_pdu_is_last_byte_sdu) { fi = fi + 1; } - pdu->b1 = (fi << 3); //pdu->b1 | + pdu_p->b1 = (fi << 3); //pdu_p->b1 | // set fist e bit if (fill_num_li > 0) { - pdu->b1 = pdu->b1 | 0x04; + pdu_p->b1 = pdu_p->b1 | 0x04; } - pdu->b1 = pdu->b1 | ((rlcP->vt_us >> 8) & 0x03); - pdu->b2 = rlcP->vt_us & 0xFF; - rlcP->vt_us = rlcP->vt_us+1; + pdu_p->b1 = pdu_p->b1 | ((rlc_pP->vt_us >> 8) & 0x03); + pdu_p->b2 = rlc_pP->vt_us & 0xFF; + rlc_pP->vt_us = rlc_pP->vt_us+1; - pdu_tb_req->data_ptr = (unsigned char*)pdu; - pdu_tb_req->tb_size = data_pdu_size - pdu_remaining_size; - list_add_tail_eurecom (pdu_mem, &rlcP->pdus_to_mac_layer); - //rlc_util_print_hex_octets(RLC, pdu_mem->data, data_pdu_size); - AssertFatal( pdu_tb_req->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req->tb_size); - pdu = NULL; - pdu_mem = NULL; + pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; + pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; + list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); + //rlc_util_print_hex_octets(RLC, pdu_mem_p->data, data_pdu_size); + AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT10: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); + pdu_p = NULL; + pdu_mem_p = NULL; //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; nb_bytes_to_transmit = 0; // 1 PDU only @@ -330,21 +475,21 @@ rlc_um_segment_10 (struct rlc_um_entity *rlcP,u32_t frame) } //----------------------------------------------------------------------------- void -rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) +rlc_um_segment_5 (struct rlc_um_entity *rlc_pP,frame_t frameP) { //----------------------------------------------------------------------------- list_t pdus; signed int pdu_remaining_size; signed int test_pdu_remaining_size; - int nb_bytes_to_transmit = rlcP->nb_bytes_requested_by_mac; - rlc_um_pdu_sn_5_t *pdu; - struct mac_tb_req *pdu_tb_req; - mem_block_t *pdu_mem; + int nb_bytes_to_transmit = rlc_pP->nb_bytes_requested_by_mac; + rlc_um_pdu_sn_5_t *pdu_p; + struct mac_tb_req *pdu_tb_req_p; + mem_block_t *pdu_mem_p; char *data; - char *data_sdu; - rlc_um_e_li_t *e_li; - struct rlc_um_tx_sdu_management *sdu_mngt; + char *data_sdu_p; + rlc_um_e_li_t *e_li_p; + struct rlc_um_tx_sdu_management *sdu_mngt_p; unsigned int li_length_in_bytes; unsigned int test_li_length_in_bytes; unsigned int test_remaining_size_to_substract; @@ -362,39 +507,94 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) unsigned int max_li_overhead; if (nb_bytes_to_transmit < 2) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] NO SEGMENTATION5 nb_bytes to transmit = %d\n", rlcP->module_id, rlcP->rb_id, frame, nb_bytes_to_transmit); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] NO SEGMENTATION5 nb_bytes to transmit = %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bytes_to_transmit); +#endif return; } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5\n", rlcP->module_id, rlcP->rb_id, frame); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif list_init (&pdus, NULL); // param string identifying the list is NULL - pdu_mem = NULL; - - while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 nb_bytes_to_transmit %d BO %d\n", rlcP->module_id, rlcP->rb_id, frame, nb_bytes_to_transmit, rlcP->buffer_occupancy); - // pdu management - if (!pdu_mem) { - if (rlcP->nb_sdu <= 1) { + pdu_mem_p = NULL; + + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (nb_bytes_to_transmit > 0)) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 nb_bytes_to_transmit %d BO %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + nb_bytes_to_transmit, + rlc_pP->buffer_occupancy); +#endif + // pdu_p management + if (!pdu_mem_p) { + if (rlc_pP->nb_sdu <= 1) { max_li_overhead = 0; } else { - max_li_overhead = (((rlcP->nb_sdu - 1) * 3) / 2) + ((rlcP->nb_sdu - 1) % 2); + max_li_overhead = (((rlc_pP->nb_sdu - 1) * 3) / 2) + ((rlc_pP->nb_sdu - 1) % 2); } - if (nb_bytes_to_transmit >= (rlcP->buffer_occupancy + rlcP->tx_header_min_length_in_bytes + max_li_overhead)) { - data_pdu_size = rlcP->buffer_occupancy + rlcP->tx_header_min_length_in_bytes + max_li_overhead; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); + if (nb_bytes_to_transmit >= (rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead)) { + data_pdu_size = rlc_pP->buffer_occupancy + rlc_pP->tx_header_min_length_in_bytes + max_li_overhead; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 alloc PDU size %d bytes to contain not all bytes requested by MAC but all BO of RLC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif } else { data_pdu_size = nb_bytes_to_transmit; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 alloc PDU size %d bytes to contain all bytes requested by MAC@1\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif } - if (!(pdu_mem = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { - LOG_E(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 ERROR COULD NOT GET NEW PDU, EXIT\n", rlcP->module_id, rlcP->rb_id, frame); + if (!(pdu_mem_p = get_free_mem_block (data_pdu_size + sizeof(struct mac_tb_req)))) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_E(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 ERROR COULD NOT GET NEW PDU, EXIT\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id); +#endif return; } - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 get new PDU %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, data_pdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 get new PDU %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + data_pdu_size); +#endif pdu_remaining_size = data_pdu_size - 1; - pdu = (rlc_um_pdu_sn_5_t*) (&pdu_mem->data[sizeof(struct mac_tb_req)]); - pdu_tb_req = (struct mac_tb_req*) (pdu_mem->data); + pdu_p = (rlc_um_pdu_sn_5_t*) (&pdu_mem_p->data[sizeof(struct mac_tb_req)]); + pdu_tb_req_p = (struct mac_tb_req*) (pdu_mem_p->data); - memset (pdu_mem->data, 0, sizeof (rlc_um_pdu_sn_5_t)+sizeof(struct mac_tb_req)); + memset (pdu_mem_p->data, 0, sizeof (rlc_um_pdu_sn_5_t)+sizeof(struct mac_tb_req)); li_length_in_bytes = 1; } //---------------------------------------- @@ -403,31 +603,31 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) continue_fill_pdu_with_sdu = 1; num_fill_sdu = 0; test_num_li = 0; - sdu_buffer_index = rlcP->current_sdu_index; + sdu_buffer_index = rlc_pP->current_sdu_index; test_pdu_remaining_size = pdu_remaining_size; test_li_length_in_bytes = 1; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - while ((rlcP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[sdu_buffer_index]->data)); + while ((rlc_pP->input_sdus[sdu_buffer_index]) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[sdu_buffer_index]->data)); - if (sdu_mngt->sdu_remaining_size > test_pdu_remaining_size) { + if (sdu_mngt_p->sdu_remaining_size > test_pdu_remaining_size) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if (sdu_mngt->sdu_remaining_size == test_pdu_remaining_size) { + } else if (sdu_mngt_p->sdu_remaining_size == test_pdu_remaining_size) { // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; test_pdu_remaining_size = 0; test_remaining_size_to_substract = 0; test_remaining_num_li_to_substract = 0; - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) == test_pdu_remaining_size ) { // no LI continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -436,15 +636,25 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) test_remaining_num_li_to_substract = 0; pdu_remaining_size = pdu_remaining_size - (test_li_length_in_bytes ^ 3); data_pdu_size -= (test_li_length_in_bytes ^ 3);//modifier pour duy - } else if ((sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { + } else if ((sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)) < test_pdu_remaining_size ) { test_num_li += 1; num_fill_sdu += 1; - test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); + test_pdu_remaining_size = test_pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + (test_li_length_in_bytes ^ 3)); test_remaining_size_to_substract = test_li_length_in_bytes ^ 3; test_remaining_num_li_to_substract = 1; test_li_length_in_bytes = test_li_length_in_bytes ^ 3; } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 sdu_mngt->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size, test_pdu_remaining_size, test_li_length_in_bytes ^ 3); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 sdu_mngt_p->sdu_remaining_size=%d test_pdu_remaining_size=%d test_li_length_in_bytes=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + test_pdu_remaining_size, + test_li_length_in_bytes ^ 3); +#endif // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; num_fill_sdu += 1; @@ -454,7 +664,7 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) pdu_remaining_size = pdu_remaining_size - 1; data_pdu_size -= 1;//modifier pour duy } - sdu_buffer_index = (sdu_buffer_index + 1) % rlcP->size_input_sdus_buffer; + sdu_buffer_index = (sdu_buffer_index + 1) % rlc_pP->size_input_sdus_buffer; } if (test_remaining_num_li_to_substract > 0) { // there is a LI that is not necessary @@ -462,12 +672,21 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) pdu_remaining_size = pdu_remaining_size - test_remaining_size_to_substract; } //---------------------------------------- - // Do the real filling of the pdu + // Do the real filling of the pdu_p //---------------------------------------- - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] data shift %d Bytes num_li %d\n", rlcP->module_id, rlcP->rb_id, frame, ((test_num_li*3) +1) >> 1, test_num_li); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] data shift %d Bytes num_li %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + ((test_num_li*3) +1) >> 1, + test_num_li); +#endif - data = ((char*)(&pdu->data[((test_num_li*3) +1) >> 1])); - e_li = (rlc_um_e_li_t*)(pdu->data); + data = ((char*)(&pdu_p->data[((test_num_li*3) +1) >> 1])); + e_li_p = (rlc_um_e_li_t*)(pdu_p->data); continue_fill_pdu_with_sdu = 1; li_length_in_bytes = 1; fill_num_li = 0; @@ -475,101 +694,185 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) fi_last_byte_pdu_is_last_byte_sdu = 0; if ( - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_remaining_size == - ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data))->sdu_size) { + ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_remaining_size == + ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data))->sdu_size) { fi_first_byte_pdu_is_first_byte_sdu = 1; } - while ((rlcP->input_sdus[rlcP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) { - sdu_mngt = ((struct rlc_um_tx_sdu_management *) (rlcP->input_sdus[rlcP->current_sdu_index]->data)); - if (sdu_mngt->sdu_segmented_size == 0) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt, sdu_mngt->sdu_remaining_size); + while ((rlc_pP->input_sdus[rlc_pP->current_sdu_index]) && (continue_fill_pdu_with_sdu > 0)) { + sdu_mngt_p = ((struct rlc_um_tx_sdu_management *) (rlc_pP->input_sdus[rlc_pP->current_sdu_index]->data)); + if (sdu_mngt_p->sdu_segmented_size == 0) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 GET NEW SDU %p AVAILABLE SIZE %d Bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size); +#endif } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt, sdu_mngt->sdu_remaining_size, sdu_mngt->sdu_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 GET AGAIN SDU %p REMAINING AVAILABLE SIZE %d Bytes / %d Bytes \n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p, + sdu_mngt_p->sdu_remaining_size, + sdu_mngt_p->sdu_size); +#endif } - data_sdu = &((rlcP->input_sdus[rlcP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt->sdu_segmented_size]); - - if (sdu_mngt->sdu_remaining_size > pdu_remaining_size) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 Filling all remaining PDU with %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, pdu_remaining_size); - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 pdu_mem %p pdu %p pdu->data %p data %p data_sdu %p pdu_remaining_size %d\n", rlcP->module_id, rlcP->rb_id, frame, pdu_mem, pdu, pdu->data, data, data_sdu,pdu_remaining_size); + data_sdu_p = &((rlc_pP->input_sdus[rlc_pP->current_sdu_index])->data[sizeof (struct rlc_um_tx_sdu_management) + sdu_mngt_p->sdu_segmented_size]); + + if (sdu_mngt_p->sdu_remaining_size > pdu_remaining_size) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling all remaining PDU with %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 pdu_mem_p %p pdu_p %p pdu_p->data %p data %p data_sdu_p %p pdu_remaining_size %d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_mem_p, + pdu_p, + pdu_p->data, + data, + data_sdu_p, + pdu_remaining_size); +#endif - memcpy(data, data_sdu, pdu_remaining_size); - sdu_mngt->sdu_remaining_size = sdu_mngt->sdu_remaining_size - pdu_remaining_size; - sdu_mngt->sdu_segmented_size = sdu_mngt->sdu_segmented_size + pdu_remaining_size; + memcpy(data, data_sdu_p, pdu_remaining_size); + sdu_mngt_p->sdu_remaining_size = sdu_mngt_p->sdu_remaining_size - pdu_remaining_size; + sdu_mngt_p->sdu_segmented_size = sdu_mngt_p->sdu_segmented_size + pdu_remaining_size; fi_last_byte_pdu_is_last_byte_sdu = 0; // no LI - rlcP->buffer_occupancy -= pdu_remaining_size; + rlc_pP->buffer_occupancy -= pdu_remaining_size; continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - } else if (sdu_mngt->sdu_remaining_size == pdu_remaining_size) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", rlcP->module_id, rlcP->rb_id, frame, pdu_remaining_size); - memcpy(data, data_sdu, pdu_remaining_size); - + } else if (sdu_mngt_p->sdu_remaining_size == pdu_remaining_size) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Exactly Filling remaining PDU with %d remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + pdu_remaining_size); + memcpy(data, data_sdu_p, pdu_remaining_size); +#endif // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; fi_last_byte_pdu_is_last_byte_sdu = 1; // fi will indicate end of PDU is end of SDU, no need for LI continue_fill_pdu_with_sdu = 0; pdu_remaining_size = 0; - } else if ((sdu_mngt->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 Filling PDU with %d all remaining bytes of SDU\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size); - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); - data = &data[sdu_mngt->sdu_remaining_size]; + } else if ((sdu_mngt_p->sdu_remaining_size + (li_length_in_bytes ^ 3)) < pdu_remaining_size ) { +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling PDU with %d all remaining bytes of SDU\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size); +#endif + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); + data = &data[sdu_mngt_p->sdu_remaining_size]; li_length_in_bytes = li_length_in_bytes ^ 3; fill_num_li += 1; if (li_length_in_bytes == 2) { if (fill_num_li == test_num_li) { - //e_li->e1 = 0; - e_li->b1 = 0; + //e_li_p->e1 = 0; + e_li_p->b1 = 0; } else { - //e_li->e1 = 1; - e_li->b1 = 0x80; + //e_li_p->e1 = 1; + e_li_p->b1 = 0x80; } - //e_li->li1 = sdu_mngt->sdu_remaining_size; - e_li->b1 = e_li->b1 | (sdu_mngt->sdu_remaining_size >> 4); - e_li->b2 = sdu_mngt->sdu_remaining_size << 4; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 set e_li->b1=%02X set e_li->b2=%02X fill_num_li=%d test_num_li=%d\n", rlcP->module_id, rlcP->rb_id, frame, e_li->b1, e_li->b2, fill_num_li, test_num_li); + //e_li_p->li1 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b1 = e_li_p->b1 | (sdu_mngt_p->sdu_remaining_size >> 4); + e_li_p->b2 = sdu_mngt_p->sdu_remaining_size << 4; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 set e_li_p->b1=%02X set e_li_p->b2=%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b1, + e_li_p->b2, + fill_num_li, + test_num_li); +#endif } else { if (fill_num_li != test_num_li) { - //e_li->e2 = 1; - e_li->b2 = e_li->b2 | 0x08; + //e_li_p->e2 = 1; + e_li_p->b2 = e_li_p->b2 | 0x08; } - //e_li->li2 = sdu_mngt->sdu_remaining_size; - e_li->b2 = e_li->b2 | (sdu_mngt->sdu_remaining_size >> 8); - e_li->b3 = sdu_mngt->sdu_remaining_size & 0xFF; - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 set e_li->b2=%02X set e_li->b3=%02X fill_num_li=%d test_num_li=%d\n", rlcP->module_id, rlcP->rb_id, frame, e_li->b2, e_li->b3, fill_num_li, test_num_li); - e_li++; + //e_li_p->li2 = sdu_mngt_p->sdu_remaining_size; + e_li_p->b2 = e_li_p->b2 | (sdu_mngt_p->sdu_remaining_size >> 8); + e_li_p->b3 = sdu_mngt_p->sdu_remaining_size & 0xFF; +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 set e_li_p->b2=%02X set e_li_p->b3=%02X fill_num_li=%d test_num_li=%d\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + e_li_p->b2, + e_li_p->b3, + fill_num_li, + test_num_li); +#endif + e_li_p++; } // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; - pdu_remaining_size = pdu_remaining_size - (sdu_mngt->sdu_remaining_size + li_length_in_bytes); + pdu_remaining_size = pdu_remaining_size - (sdu_mngt_p->sdu_remaining_size + li_length_in_bytes); } else { - LOG_D(RLC, "[RLC_UM][MOD %d][RB %d][FRAME %05d] SEGMENT5 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", rlcP->module_id, rlcP->rb_id, frame, sdu_mngt->sdu_remaining_size, pdu_remaining_size - sdu_mngt->sdu_remaining_size); +#if defined(TRACE_RLC_UM_SEGMENT) + LOG_D(RLC, "[FRAME %05u][%s][RLC_UM][MOD %u/%u][RB %u] SEGMENT5 Filling PDU with %d all remaining bytes of SDU and reduce TB size by %d bytes\n", + frameP, + (rlc_pP->is_enb) ? "eNB" : "UE", + rlc_pP->enb_module_id, + rlc_pP->ue_module_id, + rlc_pP->rb_id, + sdu_mngt_p->sdu_remaining_size, + pdu_remaining_size - sdu_mngt_p->sdu_remaining_size); +#endif #ifdef USER_MODE assert(1!=1); #endif - memcpy(data, data_sdu, sdu_mngt->sdu_remaining_size); + memcpy(data, data_sdu_p, sdu_mngt_p->sdu_remaining_size); // free SDU - rlcP->buffer_occupancy -= sdu_mngt->sdu_remaining_size; - free_mem_block (rlcP->input_sdus[rlcP->current_sdu_index]); - rlcP->input_sdus[rlcP->current_sdu_index] = NULL; - rlcP->nb_sdu -= 1; - rlcP->current_sdu_index = (rlcP->current_sdu_index + 1) % rlcP->size_input_sdus_buffer; + rlc_pP->buffer_occupancy -= sdu_mngt_p->sdu_remaining_size; + free_mem_block (rlc_pP->input_sdus[rlc_pP->current_sdu_index]); + rlc_pP->input_sdus[rlc_pP->current_sdu_index] = NULL; + rlc_pP->nb_sdu -= 1; + rlc_pP->current_sdu_index = (rlc_pP->current_sdu_index + 1) % rlc_pP->size_input_sdus_buffer; // reduce the size of the PDU continue_fill_pdu_with_sdu = 0; fi_last_byte_pdu_is_last_byte_sdu = 1; - pdu_remaining_size = pdu_remaining_size - sdu_mngt->sdu_remaining_size; + pdu_remaining_size = pdu_remaining_size - sdu_mngt_p->sdu_remaining_size; } } @@ -582,24 +885,24 @@ rlc_um_segment_5 (struct rlc_um_entity *rlcP,u32_t frame) if (!fi_last_byte_pdu_is_last_byte_sdu) { fi = fi + 1; } - pdu->b1 = (fi << 6); //pdu->b1 | + pdu_p->b1 = (fi << 6); //pdu_p->b1 | // set fist e bit if (fill_num_li > 0) { - pdu->b1 = pdu->b1 | 0x20; + pdu_p->b1 = pdu_p->b1 | 0x20; } - pdu->b1 = pdu->b1 | (rlcP->vt_us & 0x1F); - rlcP->vt_us = rlcP->vt_us+1; + pdu_p->b1 = pdu_p->b1 | (rlc_pP->vt_us & 0x1F); + rlc_pP->vt_us = rlc_pP->vt_us+1; - pdu_tb_req->data_ptr = (unsigned char*)pdu; - pdu_tb_req->tb_size = data_pdu_size - pdu_remaining_size; - list_add_tail_eurecom (pdu_mem, &rlcP->pdus_to_mac_layer); - rlc_util_print_hex_octets(RLC, (unsigned char*)pdu_mem->data, data_pdu_size); + pdu_tb_req_p->data_ptr = (unsigned char*)pdu_p; + pdu_tb_req_p->tb_size = data_pdu_size - pdu_remaining_size; + list_add_tail_eurecom (pdu_mem_p, &rlc_pP->pdus_to_mac_layer); + rlc_util_print_hex_octets(RLC, (unsigned char*)pdu_mem_p->data, data_pdu_size); - AssertFatal( pdu_tb_req->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req->tb_size); + AssertFatal( pdu_tb_req_p->tb_size > 0 , "SEGMENT5: FINAL RLC UM PDU LENGTH %d", pdu_tb_req_p->tb_size); - pdu = NULL; - pdu_mem = NULL; + pdu_p = NULL; + pdu_mem_p = NULL; //nb_bytes_to_transmit = nb_bytes_to_transmit - data_pdu_size; nb_bytes_to_transmit = 0; // 1 PDU only diff --git a/openair2/LAYER2/RLC/rlc.c b/openair2/LAYER2/RLC/rlc.c index cf8020cc69599bb56720ff6dbcbe59c201605b5c..f34cbf0472214b327559924f007c61e29e54b914 100644 --- a/openair2/LAYER2/RLC/rlc.c +++ b/openair2/LAYER2/RLC/rlc.c @@ -32,14 +32,15 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #include "mem_block.h" #include "../MAC/extern.h" #include "UTIL/LOG/log.h" +#include "UTIL/OCG/OCG_vars.h" #include "assertions.h" -extern void pdcp_data_ind (u8 eNB_id, u8 UE_id, u32_t frame, u8_t eNB_flag, u8_t MBMS_flag, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t * sduP, u8 is_data_plane); +extern void pdcp_data_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, u8_t MBMS_flag, rb_id_t rab_idP, sdu_size_t data_sizeP, mem_block_t * sdu_pP, u8 is_data_plane); -//#define DEBUG_RLC_PDCP_INTERFACE +#define DEBUG_RLC_PDCP_INTERFACE -//#define DEBUG_RLC_DATA_REQ 1 +#define DEBUG_RLC_DATA_REQ 1 //----------------------------------------------------------------------------- void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, unsigned long sizeP) @@ -80,9 +81,12 @@ void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* dataP, uns } //----------------------------------------------------------------------------- -rlc_op_status_t rlc_stat_req (module_id_t module_idP, - u32_t frame, - rb_id_t rb_idP, +rlc_op_status_t rlc_stat_req ( + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rb_id_t rb_idP, unsigned int* stat_tx_pdcp_sdu, unsigned int* stat_tx_pdcp_bytes, unsigned int* stat_tx_pdcp_sdu_discarded, @@ -111,324 +115,490 @@ rlc_op_status_t rlc_stat_req (module_id_t module_idP, unsigned int* stat_timer_poll_retransmit_timed_out, unsigned int* stat_timer_status_prohibit_timed_out) { //----------------------------------------------------------------------------- - if ((module_idP >= 0) && (module_idP < MAX_MODULES)) { - if ((rb_idP >= 0) && (rb_idP < MAX_RAB)) { - switch (rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type) { - case RLC_NONE: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_reordering_timed_out = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - break; - - case RLC_AM: - rlc_am_stat_req (&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], - stat_tx_pdcp_sdu, - stat_tx_pdcp_bytes, - stat_tx_pdcp_sdu_discarded, - stat_tx_pdcp_bytes_discarded, - stat_tx_data_pdu, - stat_tx_data_bytes, - stat_tx_retransmit_pdu_by_status, - stat_tx_retransmit_bytes_by_status, - stat_tx_retransmit_pdu, - stat_tx_retransmit_bytes, - stat_tx_control_pdu, - stat_tx_control_bytes, - stat_rx_pdcp_sdu, - stat_rx_pdcp_bytes, - stat_rx_data_pdus_duplicate, - stat_rx_data_bytes_duplicate, - stat_rx_data_pdu, - stat_rx_data_bytes, - stat_rx_data_pdu_dropped, - stat_rx_data_bytes_dropped, - stat_rx_data_pdu_out_of_window, - stat_rx_data_bytes_out_of_window, - stat_rx_control_pdu, - stat_rx_control_bytes, - stat_timer_reordering_timed_out, - stat_timer_poll_retransmit_timed_out, - stat_timer_status_prohibit_timed_out); - return RLC_OP_STATUS_OK; - break; - - case RLC_UM: - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - rlc_um_stat_req (&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], - stat_tx_pdcp_sdu, - stat_tx_pdcp_bytes, - stat_tx_pdcp_sdu_discarded, - stat_tx_pdcp_bytes_discarded, - stat_tx_data_pdu, - stat_tx_data_bytes, - stat_rx_pdcp_sdu, - stat_rx_pdcp_bytes, - stat_rx_data_pdus_duplicate, - stat_rx_data_bytes_duplicate, - stat_rx_data_pdu, - stat_rx_data_bytes, - stat_rx_data_pdu_dropped, - stat_rx_data_bytes_dropped, - stat_rx_data_pdu_out_of_window, - stat_rx_data_bytes_out_of_window, - stat_timer_reordering_timed_out); - return RLC_OP_STATUS_OK; - break; - - case RLC_TM: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_reordering_timed_out = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - break; - - default: - *stat_tx_pdcp_sdu = 0; - *stat_tx_pdcp_bytes = 0; - *stat_tx_pdcp_sdu_discarded = 0; - *stat_tx_pdcp_bytes_discarded = 0; - *stat_tx_data_pdu = 0; - *stat_tx_data_bytes = 0; - *stat_tx_retransmit_pdu_by_status = 0; - *stat_tx_retransmit_bytes_by_status = 0; - *stat_tx_retransmit_pdu = 0; - *stat_tx_retransmit_bytes = 0; - *stat_tx_control_pdu = 0; - *stat_tx_control_bytes = 0; - *stat_rx_pdcp_sdu = 0; - *stat_rx_pdcp_bytes = 0; - *stat_rx_data_pdus_duplicate = 0; - *stat_rx_data_bytes_duplicate = 0; - *stat_rx_data_pdu = 0; - *stat_rx_data_bytes = 0; - *stat_rx_data_pdu_dropped = 0; - *stat_rx_data_bytes_dropped = 0; - *stat_rx_data_pdu_out_of_window = 0; - *stat_rx_data_bytes_out_of_window = 0; - *stat_rx_control_pdu = 0; - *stat_rx_control_bytes = 0; - *stat_timer_reordering_timed_out = 0; - *stat_timer_poll_retransmit_timed_out = 0; - *stat_timer_status_prohibit_timed_out = 0; - return RLC_OP_STATUS_BAD_PARAMETER; - } - } else { - return RLC_OP_STATUS_BAD_PARAMETER; - } - } else { - return RLC_OP_STATUS_BAD_PARAMETER; - } + rlc_mode_t rlc_mode = RLC_NONE; + void *rlc = NULL; + +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif + AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "enB RLC not configured rb id %u module eNB id %u!\n", rb_idP, enb_mod_idP); + break; + case RLC_AM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am; + break; + case RLC_UM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um; + break; + case RLC_TM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm; + break; + default: + AssertFatal (0 , "enB RLC internal memory error rb id %u module eNB id %u!\n", rb_idP, enb_mod_idP); + } + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "UE RLC not configured rb id %u module ue id %u!\n", rb_idP, ue_mod_idP); + break; + case RLC_AM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.am; + break; + case RLC_UM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.um; + break; + case RLC_TM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm; + break; + default: + AssertFatal (0 , "UE RLC internal memory error rb id %u module ue id %u!\n", rb_idP, ue_mod_idP); + } + } + switch (rlc_mode) { + case RLC_NONE: + *stat_tx_pdcp_sdu = 0; + *stat_tx_pdcp_bytes = 0; + *stat_tx_pdcp_sdu_discarded = 0; + *stat_tx_pdcp_bytes_discarded = 0; + *stat_tx_data_pdu = 0; + *stat_tx_data_bytes = 0; + *stat_tx_retransmit_pdu_by_status = 0; + *stat_tx_retransmit_bytes_by_status = 0; + *stat_tx_retransmit_pdu = 0; + *stat_tx_retransmit_bytes = 0; + *stat_tx_control_pdu = 0; + *stat_tx_control_bytes = 0; + *stat_rx_pdcp_sdu = 0; + *stat_rx_pdcp_bytes = 0; + *stat_rx_data_pdus_duplicate = 0; + *stat_rx_data_bytes_duplicate = 0; + *stat_rx_data_pdu = 0; + *stat_rx_data_bytes = 0; + *stat_rx_data_pdu_dropped = 0; + *stat_rx_data_bytes_dropped = 0; + *stat_rx_data_pdu_out_of_window = 0; + *stat_rx_data_bytes_out_of_window = 0; + *stat_rx_control_pdu = 0; + *stat_rx_control_bytes = 0; + *stat_timer_reordering_timed_out = 0; + *stat_timer_poll_retransmit_timed_out = 0; + *stat_timer_status_prohibit_timed_out = 0; + return RLC_OP_STATUS_BAD_PARAMETER; + break; + + case RLC_AM: + rlc_am_stat_req((rlc_am_entity_t*)rlc, + stat_tx_pdcp_sdu, + stat_tx_pdcp_bytes, + stat_tx_pdcp_sdu_discarded, + stat_tx_pdcp_bytes_discarded, + stat_tx_data_pdu, + stat_tx_data_bytes, + stat_tx_retransmit_pdu_by_status, + stat_tx_retransmit_bytes_by_status, + stat_tx_retransmit_pdu, + stat_tx_retransmit_bytes, + stat_tx_control_pdu, + stat_tx_control_bytes, + stat_rx_pdcp_sdu, + stat_rx_pdcp_bytes, + stat_rx_data_pdus_duplicate, + stat_rx_data_bytes_duplicate, + stat_rx_data_pdu, + stat_rx_data_bytes, + stat_rx_data_pdu_dropped, + stat_rx_data_bytes_dropped, + stat_rx_data_pdu_out_of_window, + stat_rx_data_bytes_out_of_window, + stat_rx_control_pdu, + stat_rx_control_bytes, + stat_timer_reordering_timed_out, + stat_timer_poll_retransmit_timed_out, + stat_timer_status_prohibit_timed_out); + return RLC_OP_STATUS_OK; + break; + + case RLC_UM: + *stat_tx_retransmit_pdu_by_status = 0; + *stat_tx_retransmit_bytes_by_status = 0; + *stat_tx_retransmit_pdu = 0; + *stat_tx_retransmit_bytes = 0; + *stat_tx_control_pdu = 0; + *stat_tx_control_bytes = 0; + *stat_rx_data_pdu_dropped = 0; + *stat_rx_data_bytes_dropped = 0; + *stat_rx_data_pdu_out_of_window = 0; + *stat_rx_data_bytes_out_of_window = 0; + *stat_timer_poll_retransmit_timed_out = 0; + *stat_timer_status_prohibit_timed_out = 0; + rlc_um_stat_req ((rlc_um_entity_t*)rlc, + stat_tx_pdcp_sdu, + stat_tx_pdcp_bytes, + stat_tx_pdcp_sdu_discarded, + stat_tx_pdcp_bytes_discarded, + stat_tx_data_pdu, + stat_tx_data_bytes, + stat_rx_pdcp_sdu, + stat_rx_pdcp_bytes, + stat_rx_data_pdus_duplicate, + stat_rx_data_bytes_duplicate, + stat_rx_data_pdu, + stat_rx_data_bytes, + stat_rx_data_pdu_dropped, + stat_rx_data_bytes_dropped, + stat_rx_data_pdu_out_of_window, + stat_rx_data_bytes_out_of_window, + stat_timer_reordering_timed_out); + return RLC_OP_STATUS_OK; + break; + + case RLC_TM: + *stat_tx_pdcp_sdu = 0; + *stat_tx_pdcp_bytes = 0; + *stat_tx_pdcp_sdu_discarded = 0; + *stat_tx_pdcp_bytes_discarded = 0; + *stat_tx_data_pdu = 0; + *stat_tx_data_bytes = 0; + *stat_tx_retransmit_pdu_by_status = 0; + *stat_tx_retransmit_bytes_by_status = 0; + *stat_tx_retransmit_pdu = 0; + *stat_tx_retransmit_bytes = 0; + *stat_tx_control_pdu = 0; + *stat_tx_control_bytes = 0; + *stat_rx_pdcp_sdu = 0; + *stat_rx_pdcp_bytes = 0; + *stat_rx_data_pdus_duplicate = 0; + *stat_rx_data_bytes_duplicate = 0; + *stat_rx_data_pdu = 0; + *stat_rx_data_bytes = 0; + *stat_rx_data_pdu_dropped = 0; + *stat_rx_data_bytes_dropped = 0; + *stat_rx_data_pdu_out_of_window = 0; + *stat_rx_data_bytes_out_of_window = 0; + *stat_rx_control_pdu = 0; + *stat_rx_control_bytes = 0; + *stat_timer_reordering_timed_out = 0; + *stat_timer_poll_retransmit_timed_out = 0; + *stat_timer_status_prohibit_timed_out = 0; + return RLC_OP_STATUS_BAD_PARAMETER; + break; + + default: + *stat_tx_pdcp_sdu = 0; + *stat_tx_pdcp_bytes = 0; + *stat_tx_pdcp_sdu_discarded = 0; + *stat_tx_pdcp_bytes_discarded = 0; + *stat_tx_data_pdu = 0; + *stat_tx_data_bytes = 0; + *stat_tx_retransmit_pdu_by_status = 0; + *stat_tx_retransmit_bytes_by_status = 0; + *stat_tx_retransmit_pdu = 0; + *stat_tx_retransmit_bytes = 0; + *stat_tx_control_pdu = 0; + *stat_tx_control_bytes = 0; + *stat_rx_pdcp_sdu = 0; + *stat_rx_pdcp_bytes = 0; + *stat_rx_data_pdus_duplicate = 0; + *stat_rx_data_bytes_duplicate = 0; + *stat_rx_data_pdu = 0; + *stat_rx_data_bytes = 0; + *stat_rx_data_pdu_dropped = 0; + *stat_rx_data_bytes_dropped = 0; + *stat_rx_data_pdu_out_of_window = 0; + *stat_rx_data_bytes_out_of_window = 0; + *stat_rx_control_pdu = 0; + *stat_rx_control_bytes = 0; + + *stat_timer_poll_retransmit_timed_out = 0; + *stat_timer_status_prohibit_timed_out = 0; + return RLC_OP_STATUS_BAD_PARAMETER; + } } //----------------------------------------------------------------------------- -rlc_op_status_t rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sduP) { +rlc_op_status_t rlc_data_req (module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + MBMS_flag_t MBMS_flagP, + rb_id_t rb_idP, + mui_t muiP, + confirm_t confirmP, + sdu_size_t sdu_sizeP, + mem_block_t *sdu_pP) { //----------------------------------------------------------------------------- - mem_block_t* new_sdu; + mem_block_t *new_sdu = NULL; + rlc_mode_t rlc_mode = RLC_NONE; + void *rlc = NULL; #ifdef Rel10 - rb_id_t mbms_rb_id = 0; + rb_id_t mbms_rb_id = 0; #endif #ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,"rlc_data_req: module_idP %d (%d), rb_idP %d (%d), muip %d, confirmP %d, sud_sizeP %d, sduP %p\n", - module_idP,MAX_MODULES,rb_idP,MAX_RAB,muiP,confirmP,sdu_sizeP,sduP); + LOG_D(RLC,"rlc_data_req: %s enb id %u ue id %u, rb_id %u (MAX %d), muip %d, confirmP %d, sud_sizeP %d, sdu_pP %p\n", + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + NB_RAB_MAX, + muiP, + confirmP, + sdu_sizeP, + sdu_pP); #endif #ifdef Rel10 - DevCheck((module_idP < MAX_MODULES), module_idP, MAX_MODULES, MBMS_flagP); #else - DevCheck((module_idP < MAX_MODULES) && (MBMS_flagP == 0), module_idP, MAX_MODULES, MBMS_flagP); + AssertFatal(MBMS_flagP == 0, "MBMS_flagP %u", MBMS_flagP); #endif - DevCheck(rb_idP < MAX_RAB, rb_idP, MAX_RB, 0); - DevAssert(sduP != NULL); +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif + AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + DevAssert(sdu_pP != NULL); DevCheck(sdu_sizeP > 0, sdu_sizeP, 0, 0); #ifndef Rel10 DevCheck(MBMS_flagP == 0, MBMS_flagP, 0, 0); #endif + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "enB RLC not configured rb id %u module %u!\n", rb_idP, enb_mod_idP); + break; + case RLC_AM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am; + break; + case RLC_UM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um; + break; + case RLC_TM: + rlc = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm; + break; + default: + AssertFatal (0 , "enB RLC internal memory error rb id %u module %u!\n", rb_idP, enb_mod_idP); + } + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "UE RLC not configured rb id %u module %u!\n", rb_idP, ue_mod_idP); + break; + case RLC_AM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.am; + break; + case RLC_UM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.um; + break; + case RLC_TM: + rlc = (void*)&rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm; + break; + default: + AssertFatal (0 , "UE RLC internal memory error rb id %u module %u!\n", rb_idP, ue_mod_idP); + } + } + + if (MBMS_flagP == 0) { - LOG_D(RLC, "[FRAME %05d][RLC][MOD %02d][RB %02d] Display of rlc_data_req:\n", - frame, module_idP, rb_idP); - rlc_util_print_hex_octets(RLC, (unsigned char*)sduP->data, sdu_sizeP); + LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][RB %u] Display of rlc_data_req:\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); + rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP); #ifdef DEBUG_RLC_DATA_REQ - LOG_D(RLC,"RLC_TYPE : %d ",rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type); + LOG_D(RLC,"RLC_TYPE : %d ",rlc_mode); #endif - switch (rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type) { - case RLC_NONE: - free_mem_block(sduP); - LOG_E(RLC, "Received RLC_NONE as rlc_type for module_idP %d, rb_id %d, eNB_flag %d\n", module_idP, rb_idP, eNB_flagP); - return RLC_OP_STATUS_BAD_PARAMETER; + switch (rlc_mode) { + case RLC_NONE: + free_mem_block(sdu_pP); + LOG_E(RLC, "Received RLC_NONE as rlc_type for %s eNB id %u, ue id %u, rb_id %u\n", + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); + return RLC_OP_STATUS_BAD_PARAMETER; - case RLC_AM: + case RLC_AM: #ifdef DEBUG_RLC_DATA_REQ - msg("RLC_AM\n"); + msg("RLC_AM\n"); #endif - new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc)); - - if (new_sdu != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu->data, 0, sizeof (struct rlc_am_data_req_alloc)); - memcpy (&new_sdu->data[sizeof (struct rlc_am_data_req_alloc)], &sduP->data[0], sdu_sizeP); - - ((struct rlc_am_data_req *) (new_sdu->data))->data_size = sdu_sizeP; - ((struct rlc_am_data_req *) (new_sdu->data))->conf = confirmP; - ((struct rlc_am_data_req *) (new_sdu->data))->mui = muiP; - ((struct rlc_am_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_am_data_req_alloc); - free_mem_block(sduP); - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - - if (rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].is_data_plane) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][PDCP][MOD %02d][RB %02d][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][MOD %02d][RB %02d]\n", - frame, module_idP, rb_idP, sdu_sizeP, module_idP, rb_idP); - } else { - if (eNB_flagP) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, rb_idP); - } else { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, rb_idP); - } - } - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_am_data_req(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], frame, new_sdu); - return RLC_OP_STATUS_OK; - } else { - return RLC_OP_STATUS_INTERNAL_ERROR; - } - break; - - case RLC_UM: - new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc)); - - if (new_sdu != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu->data, 0, sizeof (struct rlc_um_data_req_alloc)); - memcpy (&new_sdu->data[sizeof (struct rlc_um_data_req_alloc)], &sduP->data[0], sdu_sizeP); - - ((struct rlc_um_data_req *) (new_sdu->data))->data_size = sdu_sizeP; - ((struct rlc_um_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); - free_mem_block(sduP); - - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - if (rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].is_data_plane) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][PDCP][MOD %02d][RB %02d][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, rb_idP, sdu_sizeP, module_idP, rb_idP); - } else { - if (eNB_flagP) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, rb_idP); - } else { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, rb_idP); - } - } - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_um_data_req(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], frame, new_sdu); - - //free_mem_block(new_sdu); - return RLC_OP_STATUS_OK; - } else { - return RLC_OP_STATUS_INTERNAL_ERROR; - } - break; - - case RLC_TM: - new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_tm_data_req_alloc)); - - if (new_sdu != NULL) { - // PROCESS OF COMPRESSION HERE: - memset (new_sdu->data, 0, sizeof (struct rlc_tm_data_req_alloc)); - memcpy (&new_sdu->data[sizeof (struct rlc_tm_data_req_alloc)], &sduP->data[0], sdu_sizeP); - - ((struct rlc_tm_data_req *) (new_sdu->data))->data_size = sdu_sizeP; - ((struct rlc_tm_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_tm_data_req_alloc); - free_mem_block(sduP); - LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - if (rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].is_data_plane) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][PDCP][MOD %02d][RB %02d][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][MOD %02d][RB %02d]\n", - frame, module_idP, rb_idP, sdu_sizeP, module_idP, rb_idP); - } else { - if (eNB_flagP) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][MOD %02d][RB %02d]\n", - frame, module_idP, rb_idP, sdu_sizeP, module_idP, rb_idP); - } else { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][MOD %02d][RB %02d]\n", - frame, module_idP, rb_idP, sdu_sizeP, module_idP, rb_idP); - } - } - LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_tm_data_req(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], new_sdu); - return RLC_OP_STATUS_OK; - } else { - //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__); - return RLC_OP_STATUS_INTERNAL_ERROR; - } - break; - - default: - free_mem_block(sduP); - //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : no RLC found for this radio bearer %d\n", __FILE__, __LINE__, rb_idP); - return RLC_OP_STATUS_INTERNAL_ERROR; + new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_am_data_req_alloc)); + + if (new_sdu != NULL) { + // PROCESS OF COMPRESSION HERE: + memset (new_sdu->data, 0, sizeof (struct rlc_am_data_req_alloc)); + memcpy (&new_sdu->data[sizeof (struct rlc_am_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); + + ((struct rlc_am_data_req *) (new_sdu->data))->data_size = sdu_sizeP; + ((struct rlc_am_data_req *) (new_sdu->data))->conf = confirmP; + ((struct rlc_am_data_req *) (new_sdu->data))->mui = muiP; + ((struct rlc_am_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_am_data_req_alloc); + free_mem_block(sdu_pP); + LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); + + if (((rlc_am_entity_t*)rlc)->is_data_plane) { + LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + ue_mod_idP, + rb_idP, + rb_idP); + } else { + LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_AM_DATA_REQ/%d Bytes --->][RLC_AM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + } + LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); + rlc_am_data_req((rlc_am_entity_t*)rlc, frame, new_sdu); + return RLC_OP_STATUS_OK; + } else { + return RLC_OP_STATUS_INTERNAL_ERROR; + } + break; + + case RLC_UM: + new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc)); + + if (new_sdu != NULL) { + // PROCESS OF COMPRESSION HERE: + memset (new_sdu->data, 0, sizeof (struct rlc_um_data_req_alloc)); + memcpy (&new_sdu->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); + + ((struct rlc_um_data_req *) (new_sdu->data))->data_size = sdu_sizeP; + ((struct rlc_um_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); + free_mem_block(sdu_pP); + + LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); + if (((rlc_am_entity_t*)rlc)->is_data_plane) { + LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + } else { + LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_UM_DATA_REQ/%d Bytes --->][RLC_UM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + } + LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); + rlc_um_data_req((rlc_um_entity_t*)rlc, frame, new_sdu); + //free_mem_block(new_sdu); + return RLC_OP_STATUS_OK; + } else { + return RLC_OP_STATUS_INTERNAL_ERROR; + } + break; + + case RLC_TM: + new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_tm_data_req_alloc)); + + if (new_sdu != NULL) { + // PROCESS OF COMPRESSION HERE: + memset (new_sdu->data, 0, sizeof (struct rlc_tm_data_req_alloc)); + memcpy (&new_sdu->data[sizeof (struct rlc_tm_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); + + ((struct rlc_tm_data_req *) (new_sdu->data))->data_size = sdu_sizeP; + ((struct rlc_tm_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_tm_data_req_alloc); + free_mem_block(sdu_pP); + LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); + if (((rlc_tm_entity_t*)rlc)->is_data_plane) { + LOG_D(RLC, "[FRAME %5u][%s][PDCP][INST %u/%u][RB %u][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + } else { + LOG_D(RLC, "[FRAME %5u][%s][RRC][INST %u/%u][][--- RLC_TM_DATA_REQ/%d Bytes --->][RLC_TM][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); } + LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); + rlc_tm_data_req((rlc_tm_entity_t*)rlc, new_sdu); + return RLC_OP_STATUS_OK; + } else { + //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : out of memory\n", __FILE__, __LINE__); + return RLC_OP_STATUS_INTERNAL_ERROR; + } + break; + + default: + free_mem_block(sdu_pP); + return RLC_OP_STATUS_INTERNAL_ERROR; + + } #ifdef Rel10 } else { /* MBMS_flag != 0 */ @@ -439,28 +609,53 @@ rlc_op_status_t rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_ mbms_rb_id = rb_idP + (maxDRB + 3); } // LOG_I(RLC,"DUY rlc_data_req: mbms_rb_id in RLC instant is: %d\n", mbms_rb_id); - if (sduP != NULL) { + if (sdu_pP != NULL) { if (sdu_sizeP > 0) { LOG_I(RLC,"received a packet with size %d for MBMS \n", sdu_sizeP); new_sdu = get_free_mem_block (sdu_sizeP + sizeof (struct rlc_um_data_req_alloc)); if (new_sdu != NULL) { // PROCESS OF COMPRESSION HERE: memset (new_sdu->data, 0, sizeof (struct rlc_um_data_req_alloc)); - memcpy (&new_sdu->data[sizeof (struct rlc_um_data_req_alloc)], &sduP->data[0], sdu_sizeP); + memcpy (&new_sdu->data[sizeof (struct rlc_um_data_req_alloc)], &sdu_pP->data[0], sdu_sizeP); ((struct rlc_um_data_req *) (new_sdu->data))->data_size = sdu_sizeP; ((struct rlc_um_data_req *) (new_sdu->data))->data_offset = sizeof (struct rlc_um_data_req_alloc); - free_mem_block(sduP); + free_mem_block(sdu_pP); LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); if (rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[mbms_rb_id].rlc_index].is_data_plane) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][PDCP][MOD %02d][RB %02d][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, mbms_rb_id, sdu_sizeP, module_idP, mbms_rb_id); + LOG_D(RLC, "[FRAME %5u][PDCP][INST %u/%u][RB %u][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + mbms_rb_id, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP, + mbms_rb_id); } else { if (eNB_flagP) { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, mbms_rb_id); + LOG_D(RLC, "[FRAME %5u][RRC_eNB][INST %u/%u][][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP, + mbms_rb_id); } else { - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][MOD %02d][RB %02d]\n", - frame, module_idP, sdu_sizeP, module_idP, mbms_rb_id); + LOG_D(RLC, "[FRAME %5u][RRC_UE][INST %u/%u][][--- RLC_UM_DATA_REQ/%d Bytes (MBMS) --->][RLC_UM][INST %u/%u][RB %u]\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP, + mbms_rb_id); } } LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); @@ -483,7 +678,7 @@ rlc_op_status_t rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_ } #else } else {/* MBMS_flag != 0 */ - free_mem_block(sduP); + free_mem_block(sdu_pP); LOG_E(RLC, "MBMS_flag != 0 while Rel10 is not defined...\n"); //handle_event(ERROR,"FILE %s FONCTION rlc_data_req() LINE %s : parameter module_id out of bounds :%d\n", __FILE__, __LINE__, module_idP); return RLC_OP_STATUS_BAD_PARAMETER; @@ -492,71 +687,126 @@ rlc_op_status_t rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_ } //----------------------------------------------------------------------------- -void rlc_data_ind (module_id_t module_idP, u8_t eNB_id, u8_t UE_id, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sduP, boolean_t is_data_planeP) { +void rlc_data_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sdu_pP, boolean_t is_data_planeP) { //----------------------------------------------------------------------------- - char *from_str; - char *to_str; - u8_t from_value; - u8_t to_value; - - if (eNB_flag == 0) { - from_str = "UE"; - to_str = "eNB"; - from_value = UE_id; - to_value = eNB_id; + rlc_mode_t rlc_mode = RLC_NONE; + + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; } else { - from_str = "eNB"; - to_str = "UE"; - from_value = eNB_id; - to_value = UE_id; + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; } - LOG_D(RLC, "[FRAME %05d][RLC][MOD %02d][RB %02d] Display of rlc_data_ind:\n", frame, module_idP, rb_idP); - rlc_util_print_hex_octets(RLC, (unsigned char*)sduP->data, sdu_sizeP); - //check_mem_area(); - // now demux is done at PDCP - // if ((is_data_planeP)) { -#ifdef DEBUG_RLC_PDCP_INTERFACE - msg("[RLC] TTI %d, INST %d : Receiving SDU (%p) of size %d bytes to Rb_id %d\n", - frame, module_idP, - sduP, - sdu_sizeP, - rb_idP); -#endif //DEBUG_RLC_PDCP_INTERFACE - switch (rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type) { - case RLC_AM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_AM][%s %02d][RB %02d][--- RLC_DATA_IND/%d Bytes --->][PDCP][%s %02d][RB %02d]\n", - frame, from_str, from_value, rb_idP, sdu_sizeP, to_str, to_value, rb_idP); - break; - case RLC_UM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_UM][%s %02d][RB %02d][--- RLC_DATA_IND/%d Bytes --->][PDCP][%s %02d][RB %02d]\n", - frame, from_str, from_value, rb_idP, sdu_sizeP, to_str, to_value, rb_idP); - break; - case RLC_TM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_TM][%s %02d][RB %02d][--- RLC_DATA_IND/%d Bytes --->][PDCP][%s %02d][RB %02d]\n", - frame, from_str, from_value, rb_idP, sdu_sizeP, to_str, to_value, rb_idP); - break; - } - pdcp_data_ind (eNB_id, UE_id, frame, eNB_flag, MBMS_flagP, rb_idP % NB_RB_MAX, sdu_sizeP, sduP, is_data_planeP); + + LOG_D(RLC, "[FRAME %5u][%s][RLC][INST %u/%u][RB %u] Display of rlc_data_ind: size %u\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP); + + rlc_util_print_hex_octets(RLC, (unsigned char*)sdu_pP->data, sdu_sizeP); + // now demux is done at PDCP + // if ((is_data_planeP)) { + + + switch (rlc_mode) { + case RLC_AM: + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][INST %u/%u][RB %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + break; + case RLC_UM: + LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][INST %u/%u][RB %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + break; + case RLC_TM: + LOG_D(RLC, "[FRAME %5u][%s][RLC_TM][INST %u/%u][RB %u][--- RLC_DATA_IND/%d Bytes --->][PDCP][INST %u/%u][RB %u]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP, + sdu_sizeP, + enb_mod_idP, + ue_mod_idP, + rb_idP); + break; + } + pdcp_data_ind (enb_mod_idP, ue_mod_idP, frame, eNB_flagP, MBMS_flagP, rb_idP % NB_RB_MAX, sdu_sizeP, sdu_pP, is_data_planeP); } //----------------------------------------------------------------------------- -void rlc_data_conf (module_id_t module_idP, u32_t frame, u8_t eNB_flag, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP, boolean_t is_data_planeP) { +void rlc_data_conf (module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rb_id_t rb_idP, + mui_t muiP, + rlc_tx_status_t statusP, + boolean_t is_data_planeP) { //----------------------------------------------------------------------------- + rlc_mode_t rlc_mode = RLC_NONE; + + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; + } if (!(is_data_planeP)) { if (rlc_rrc_data_conf != NULL) { LOG_D(RLC, "%s\n",RLC_FG_BRIGHT_COLOR_RED); - switch (rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type) { + switch (rlc_mode) { case RLC_AM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_AM][MOD %02d][RB %02d][--- RLC_DATA_CONF /MUI %d --->][RRC_%s][MOD %02d][][RLC_DATA_CONF/ MUI %d]\n",frame, module_idP,rb_idP, ( eNB_flag == 1) ? "eNB":"UE", muiP, module_idP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_AM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + muiP, + enb_mod_idP, + ue_mod_idP, + muiP); break; case RLC_UM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_UM][MOD %02d][RB %02d][--- RLC_DATA_CONF /MUI %d --->][RRC_%s][MOD %02d][][RLC_DATA_CONF/ MUI %d]\n",frame, module_idP,rb_idP, ( eNB_flag == 1) ? "eNB":"UE", muiP, module_idP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_UM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + muiP, + enb_mod_idP, + ue_mod_idP, + muiP); break; case RLC_TM: - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RLC_TM][MOD %02d][RB %02d][--- RLC_DATA_CONF /MUI %d --->][RRC_%s][MOD %02d][][RLC_DATA_CONF/ MUI %d]\n",frame, module_idP,rb_idP, ( eNB_flag == 1) ? "eNB":"UE", muiP, module_idP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_TM][INST %u/%u][RB %u][--- RLC_DATA_CONF /MUI %d --->][RRC][INST %u/%u][][RLC_DATA_CONF/ MUI %d]\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + muiP, + enb_mod_idP, + ue_mod_idP, + muiP); break; } LOG_D(RLC, "%s\n",RLC_FG_COLOR_DEFAULT); - rlc_rrc_data_conf (module_idP , rb_idP , muiP, statusP); + rlc_rrc_data_conf (enb_mod_idP , ue_mod_idP, eNB_flagP, rb_idP , muiP, statusP); } } } @@ -565,14 +815,42 @@ int rlc_module_init (void) { //----------------------------------------------------------------------------- - int i; + int k; + module_id_t module_id1; + module_id_t module_id2; + rb_id_t rb_id; + LOG_D(RLC, "MODULE INIT\n"); rlc_rrc_data_ind = NULL; rlc_rrc_data_conf = NULL; - memset(rlc, 0, sizeof(rlc_t) * MAX_MODULES); - for (i=0; i < MAX_MODULES; i++) { - memset(rlc[i].m_lcid2rbid, -1, sizeof(rb_id_t)*RLC_MAX_LC); + + + for (module_id1=0; module_id1 < NUMBER_OF_UE_MAX; module_id1++) { + for (k=0; k < RLC_MAX_LC; k++) { + lcid2rbid_ue[module_id1][k] = RLC_RB_UNALLOCATED; + } + for (k=0; k < 16*29; k++) { + memset(&rlc_mbms_array_ue[module_id1][k], 0, sizeof(rlc_mbms_t)); + } + for (rb_id=0; rb_id < NB_RB_MAX; rb_id++) { + memset(&rlc_array_ue[module_id1][rb_id], 0, sizeof(rlc_t)); + } } + + for (module_id1=0; module_id1 < NUMBER_OF_eNB_MAX; module_id1++) { + for (k=0; k < 16*29; k++) { + memset(&rlc_mbms_array_eNB[module_id1][k], 0, sizeof(rlc_mbms_t)); + } + for (module_id2=0; module_id2 < NUMBER_OF_UE_MAX; module_id2++) { + for (rb_id=0; rb_id < NB_RB_MAX; rb_id++) { + memset(&rlc_array_eNB[module_id1][module_id2][rb_id], 0, sizeof(rlc_t)); + } + for (k=0; k < RLC_MAX_LC; k++) { + lcid2rbid_eNB[module_id1][module_id2][k] = RLC_RB_UNALLOCATED; + } + } + } + pool_buffer_init(); return(0); diff --git a/openair2/LAYER2/RLC/rlc.h b/openair2/LAYER2/RLC/rlc.h index 018617739c8c33679527105e1ff0dd31b8e4e7a6..c7890225da8bae6e7d879bc2968a53354da36dff 100755 --- a/openair2/LAYER2/RLC/rlc.h +++ b/openair2/LAYER2/RLC/rlc.h @@ -113,6 +113,8 @@ Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis #define RLC_MUI_UNDEFINED 0 +#define RLC_RB_UNALLOCATED (rb_id_t)0 + /*! \struct rlc_info_t * \brief Structure containing RLC protocol configuration parameters. @@ -134,7 +136,7 @@ typedef struct { u32_t pdus_in_buffer; /*!< \brief Number of PDUs buffered in RLC protocol instance (OBSOLETE). */ u32_t head_sdu_creation_time; /*!< \brief Head SDU creation time. */ u32_t head_sdu_remaining_size_to_send; /*!< \brief remaining size of sdu: could be the total size or the remaining size of already segmented sdu */ - u32_t head_sdu_is_segmented; /*!< \brief 0 if head SDU has not been segmented, 1 if already segmeneted */ + u32_t head_sdu_is_segmented; /*!< \brief 0 if head SDU has not been segmented, 1 if already segmeneted */ } mac_rlc_status_resp_t; @@ -154,58 +156,52 @@ typedef struct { //----------------------------------------------------------------------------- // PRIVATE INTERNALS OF RLC //----------------------------------------------------------------------------- -#define RLC_MAX_NUM_INSTANCES_RLC_AM ((maxDRB * MAX_MOBILES_PER_RG)/2) -#ifdef Rel10 -#define RLC_MAX_NUM_INSTANCES_RLC_UM ((maxDRB * MAX_MOBILES_PER_RG)/2 + maxSessionPerPMCH * maxServiceCount) -#else -#define RLC_MAX_NUM_INSTANCES_RLC_UM ((maxDRB * MAX_MOBILES_PER_RG)/2) -#endif -#define RLC_MAX_NUM_INSTANCES_RLC_TM (MAX_MOBILES_PER_RG) #ifdef Rel10 -#define RLC_MAX_RB ((maxDRB + 3) * MAX_MOBILES_PER_RG + maxSessionPerPMCH * maxServiceCount) +#define RLC_MAX_LC ((max_val_DRB_Identity+1) * NUMBER_OF_UE_MAX + maxSessionPerPMCH * maxServiceCount) #else -#define RLC_MAX_RB ((maxDRB + 3)* MAX_MOBILES_PER_RG) +#define RLC_MAX_LC ((max_val_DRB_Identity+1)* NUMBER_OF_UE_MAX) #endif -#ifdef Rel10 -#define RLC_MAX_LC ((max_val_DRB_Identity+1) * MAX_MOBILES_PER_RG + maxSessionPerPMCH * maxServiceCount) -#else -#define RLC_MAX_LC ((max_val_DRB_Identity+1)* MAX_MOBILES_PER_RG) -#endif +protected_rlc(void (*rlc_rrc_data_ind) (module_id_t, module_id_t, frame_t, eNB_flag_t, rb_id_t , sdu_size_t , u8_t* );) +protected_rlc(void (*rlc_rrc_data_conf) (module_id_t , module_id_t , u8_t, rb_id_t , mui_t, rlc_tx_status_t );) +typedef void (rrc_data_ind_cb_t)(module_id_t eNB_inst, module_id_t UE_inst, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, u8_t* sduP); +typedef void (rrc_data_conf_cb_t)(module_id_t eNB_inst, module_id_t UE_inst, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP); -protected_rlc(void (*rlc_rrc_data_ind) (u8_t, u8_t, u32_t, u8_t, rb_id_t , sdu_size_t , u8_t* );) -protected_rlc(void (*rlc_rrc_data_conf) (module_id_t , rb_id_t , mui_t, rlc_tx_status_t );) -typedef void (rrc_data_ind_cb_t)(u8_t eNB_id, u8_t UE_id, u32_t frame, u8_t eNB_flag, rb_id_t rb_idP, sdu_size_t sdu_sizeP, u8_t* sduP); -typedef void (rrc_data_conf_cb_t)(module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP); - -/*! \struct rlc_pointer_t -* \brief Structure helping finding the right RLC protocol instance in a rlc_t structure. -*/ -typedef struct rlc_pointer_t { - rlc_mode_t rlc_type; /*!< \brief Is RLC protocol instance is AM, UM or TM. */ - int rlc_index; /*!< \brief Index of RLC protocol instance in rlc_t/m_rlc_Xm_array[]. */ -} rlc_pointer_t; /*! \struct rlc_t * \brief Structure to be instanciated to allocate memory for RLC protocol instances. */ typedef struct rlc_t { - //int m_mbms_rlc_pointer[maxSessionPerPMCH][maxServiceCount]; /*!< \brief Link between (service id, session id) and (implicit) RLC UM protocol instance. */ - signed long int m_lcid2rbid[RLC_MAX_LC]; /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ - rlc_pointer_t m_rlc_pointer[RLC_MAX_RB]; /*!< \brief Link between radio bearer ID and RLC protocol instance. */ - rlc_am_entity_t m_rlc_am_array[RLC_MAX_NUM_INSTANCES_RLC_AM]; /*!< \brief RLC AM protocol instances. */ - rlc_um_entity_t m_rlc_um_array[RLC_MAX_NUM_INSTANCES_RLC_UM]; /*!< \brief RLC UM protocol instances. */ - rlc_tm_entity_t m_rlc_tm_array[RLC_MAX_NUM_INSTANCES_RLC_TM]; /*!< \brief RLC TM protocol instances. */ - char m_mscgen_trace[260]; - unsigned char m_mscgen_trace_length; + rlc_mode_t mode; + union { + rlc_am_entity_t am; + rlc_um_entity_t um; + rlc_tm_entity_t tm; + } rlc; }rlc_t; -// RK-LG was protected, public for debug -/*! \var rlc_t rlc[MAX_MODULES] -\brief Global var for RLC layer, allocate memory for RLC protocol instances. +typedef struct rlc_mbms_s { + mbms_session_id_t session_id; // lcid + mbms_service_id_t service_id; + rb_id_t rb_id; + module_id_t instanciated_instance; +} rlc_mbms_t; + +public_rlc(rlc_mbms_t rlc_mbms_array_ue[NUMBER_OF_UE_MAX][16*29];) // MAX_SERVICEx MAX_SESSION +public_rlc(rlc_mbms_t rlc_mbms_array_eNB[NUMBER_OF_eNB_MAX][16*29];) // MAX_SERVICEx MAX_SESSION + +public_rlc(rb_id_t lcid2rbid_ue[NUMBER_OF_UE_MAX][RLC_MAX_LC];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +public_rlc(rb_id_t lcid2rbid_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][RLC_MAX_LC];) /*!< \brief Pairing logical channel identifier with radio bearer identifer. */ +/*! \var rlc_t rlc_array_ue[NUMBER_OF_UE_MAX][NB_RB_MAX] +\brief Global var for RLC layer, allocate memory for RLC UE protocol instances. +*/ +public_rlc(rlc_t rlc_array_ue[NUMBER_OF_UE_MAX][NB_RB_MAX];) + +/*! \var rlc_t rlc_array_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][NB_RB_MAX] +\brief Global var for RLC layer, allocate memory for RLC UE protocol instances. */ -public_rlc(rlc_t rlc[MAX_MODULES];) +public_rlc(rlc_t rlc_array_eNB[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX][NB_RB_MAX];) /*! \fn tbs_size_t mac_rlc_serialize_tb (char* bufferP, list_t transport_blocksP) * \brief Serialize a list of transport blocks coming from RLC in order to be processed by MAC. @@ -230,11 +226,12 @@ private_rlc_mac(struct mac_data_ind mac_rlc_deserialize_tb (char*, tb_size_t, // PUBLIC INTERFACE WITH RRC //----------------------------------------------------------------------------- #ifdef Rel10 -/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t UE_index, SRB_ToAddMod_t* srb2addmod, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, MBMS_SessionInfoList_r9_t *SessionInfo_listP) +/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, u8_t UE_index, SRB_ToAddMod_t* srb2addmod, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, MBMS_SessionInfoList_r9_t *SessionInfo_listP) * \brief Function for RRC to configure a Radio Bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] UE_index Index of UE in eNB RRC * \param[in] srb2add_listP SRB configuration list to be created. * \param[in] drb2add_listP DRB configuration list to be created. @@ -242,60 +239,66 @@ private_rlc_mac(struct mac_data_ind mac_rlc_deserialize_tb (char*, tb_size_t, * \param[in] pmch_info_listP eMBMS pmch info list to be created. * \return A status about the processing, OK or error code. */ -public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t, u32_t, u8_t, u8_t UE_index, SRB_ToAddModList_t*, DRB_ToAddModList_t*, DRB_ToReleaseList_t*, PMCH_InfoList_r9_t *pmch_info_listP);) +public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t, module_id_t, frame_t, eNB_flag_t, u8_t UE_index, SRB_ToAddModList_t*, DRB_ToAddModList_t*, DRB_ToReleaseList_t*, PMCH_InfoList_r9_t *pmch_info_listP);) #else -/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t UE_index, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, MBMS_SessionInfoList_r9_t *SessionInfo_listP) +/*! \fn rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, MBMS_SessionInfoList_r9_t *SessionInfo_listP) * \brief Function for RRC to configure a Radio Bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) -* \param[in] UE_index Index of UE in eNB RRC +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] srb2add_listP SRB configuration list to be created. * \param[in] drb2add_listP DRB configuration list to be created. * \param[in] drb2release_listP DRB configuration list to be released. * \return A status about the processing, OK or error code. */ -public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t, u32_t, u8_t, u8_t UE_index, SRB_ToAddModList_t*, DRB_ToAddModList_t*, DRB_ToReleaseList_t*);) +public_rlc_rrc( rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t, module_id_t, frame_t, eNB_flag_t, SRB_ToAddModList_t*, DRB_ToAddModList_t*, DRB_ToReleaseList_t*);) #endif -/*! \fn rlc_op_status_t rrc_rlc_remove_rlc (module_id_t module_idP, u32_t frame, rb_id_t rb_idP) +/*! \fn rlc_op_status_t rrc_rlc_remove_rlc (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP) * \brief Remove a RLC protocol instance from a radio bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] rb_idP Radio bearer identifier. * \return A status about the processing, OK or error code. */ -private_rlc_rrc(rlc_op_status_t rrc_rlc_remove_rlc (module_id_t, u32_t, rb_id_t);) +private_rlc_rrc(rlc_op_status_t rrc_rlc_remove_rlc (module_id_t , module_id_t , frame_t , eNB_flag_t , rb_id_t );) -/*! \fn rlc_op_status_t rrc_rlc_add_rlc (module_id_t module_idP, u32_t frameP, rb_id_t rb_idP, chan_id_t chan_idP, rlc_mode_t rlc_modeP) +/*! \fn rlc_op_status_t rrc_rlc_add_rlc (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, logical_chan_id_t chan_idP, rlc_mode_t rlc_modeP) * \brief Add a RLC protocol instance to a radio bearer. -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. * \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] rb_idP Radio bearer identifier. * \param[in] chan_idP Logical channel identifier. * \param[in] rlc_modeP Mode of RLC (AM, UM, TM). * \return A status about the processing, OK or error code. */ -private_rlc_rrc(rlc_op_status_t rrc_rlc_add_rlc (module_id_t, u32_t, rb_id_t, chan_id_t, rlc_mode_t);) +private_rlc_rrc(rlc_op_status_t rrc_rlc_add_rlc (module_id_t, module_id_t, frame_t, eNB_flag_t, rb_id_t, logical_chan_id_t, rlc_mode_t);) -/*! \fn rlc_op_status_t rrc_rlc_config_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, config_action_t actionP, rb_id_t rb_idP, rb_type_t rb_typeP, rlc_info_t rlc_infoP) +/*! \fn rlc_op_status_t rrc_rlc_config_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, config_action_t actionP, rb_id_t rb_idP, rb_type_t rb_typeP, rlc_info_t rlc_infoP) * \brief Function for RRC to configure a Radio Bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] actionP Action for this radio bearer (add, modify, remove). * \param[in] rb_idP Radio bearer identifier. * \param[in] rb_typeP Type of radio bearer (signalling, data). * \param[in] rlc_infoP RLC configuration parameters issued from Radio Resource Manager. * \return A status about the processing, OK or error code. */ -public_rlc_rrc( rlc_op_status_t rrc_rlc_config_req (module_id_t, u32_t, u8_t , config_action_t, rb_id_t, rb_type_t, rlc_info_t );) +public_rlc_rrc( rlc_op_status_t rrc_rlc_config_req (module_id_t, module_id_t, frame_t, eNB_flag_t , config_action_t, rb_id_t, rb_type_t, rlc_info_t );) -/*! \fn rlc_op_status_t rrc_rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP) +/*! \fn rlc_op_status_t rrc_rlc_data_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP) * \brief Function for RRC to send a SDU through a Signalling Radio Bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index -* \param[in] eNB_flag Flag to indicate eNB (1) or UE (0) +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index +* \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] MBMS_flag Flag to indicate whether this is an MBMS service (1) or not (0) * \param[in] rb_idP Radio bearer identifier. * \param[in] muiP Message Unit identifier. @@ -304,9 +307,9 @@ public_rlc_rrc( rlc_op_status_t rrc_rlc_config_req (module_id_t, u32_t, u8_t , * \param[in] sduP SDU. * \return A status about the processing, OK or error code. */ -public_rlc_rrc( rlc_op_status_t rrc_rlc_data_req (module_id_t, u32_t, u8_t, u8_t, rb_id_t, mui_t, confirm_t, sdu_size_t, char *);) +public_rlc_rrc( rlc_op_status_t rrc_rlc_data_req (module_id_t, module_id_t, frame_t, eNB_flag_t, MBMS_flag_t, rb_id_t, mui_t, confirm_t, sdu_size_t, char *);) -/*! \fn void rrc_rlc_register_rrc ( void (*rrc_data_indP) (module_id_t module_idP, u32_t frame, u8_t eNB_flag, rb_id_t rb_idP, sdu_size_t sdu_sizeP, char* sduP), void (*rrc_data_confP) (module_id_t module_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP) +/*! \fn void rrc_rlc_register_rrc ( void (*rrc_data_indP) (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, char* sduP), void (*rrc_data_confP) (module_id_t enb_mod_idP, module_id_t ue_mod_idP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP) * \brief This function is called by RRC to register its DATA-INDICATE and DATA-CONFIRM handlers to RLC layer. * \param[in] rrc_data_indP Pointer on RRC data indicate function. * \param[in] rrc_data_confP Pointer on RRC data confirm callback function. @@ -316,55 +319,59 @@ public_rlc_rrc(void rrc_rlc_register_rrc (rrc_data_ind_cb_t rrc_data_indP, rrc_d //----------------------------------------------------------------------------- // PUBLIC INTERFACE WITH MAC //----------------------------------------------------------------------------- -/*! \fn tbs_size_t mac_rlc_data_req (module_id_t module_idP, u32_t frame, u8_t MBMS_flagP, chan_id_t rb_idP, char* bufferP) +/*! \fn tbs_size_t mac_rlc_data_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, char* bufferP) * \brief Interface with MAC layer, map data request to the RLC corresponding to the radio bearer. -* \param [in] module_idP Virtualized module identifier. -* \param [in] frame Frame index +* \param [in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param [in] ue_mod_idP Virtualized ue module identifier. +* \param [in] frameP Frame index +* \param [in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param [in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) * \param [in] rb_idP Radio bearer identifier. * \param [in,out] bufferP Memory area to fill with the bytes requested by MAC. * \return A status about the processing, OK or error code. */ -public_rlc_mac(tbs_size_t mac_rlc_data_req (module_id_t, u32_t, u8_t, chan_id_t, char*);) +public_rlc_mac(tbs_size_t mac_rlc_data_req (module_id_t, module_id_t, frame_t, eNB_flag_t, MBMS_flag_t, logical_chan_id_t, char*);) -/*! \fn void mac_rlc_data_ind (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t MBMS_flagP, chan_id_t rb_idP, u32_t frame, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) +/*! \fn void mac_rlc_data_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, u32_t frameP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) * \brief Interface with MAC layer, deserialize the transport blocks sent by MAC, then map data indication to the RLC instance corresponding to the radio bearer identifier. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index * \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) * \param[in] rb_idP Radio bearer identifier. -* \param[in] frame Frame index. +* \param[in] frameP Frame index. * \param[in] bufferP Memory area containing the transport blocks sent by MAC. * \param[in] tb_sizeP Size of a transport block in bits. * \param[in] num_tbP Number of transport blocks. * \param[in] crcs Array of CRC decoding. */ -public_rlc_mac(void mac_rlc_data_ind (module_id_t, u32_t, u8_t, u8_t, chan_id_t, char*, tb_size_t, num_tb_t, crc_t* );) +public_rlc_mac(void mac_rlc_data_ind (module_id_t, module_id_t, frame_t, eNB_flag_t, MBMS_flag_t, logical_chan_id_t, char*, tb_size_t, num_tb_t, crc_t* );) -/*! \fn mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t module_idP, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, chan_id_t rb_idP, tb_size_t tb_sizeP) +/*! \fn mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, logical_chan_id_t rb_idP, tb_size_t tb_sizeP) * \brief Interface with MAC layer, request and set the number of bytes scheduled for transmission by the RLC instance corresponding to the radio bearer identifier. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. -* \param[in] eNB_flag Flag to indicate eNB operation (1 true, 0 false) +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. +* \param[in] eNB_flagP Flag to indicate eNB operation (1 true, 0 false) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) * \param[in] rb_idP Radio bearer identifier. * \param[in] tb_sizeP Size of a transport block set in bytes. * \return The maximum number of bytes that the RLC instance can send in the next transmission sequence. */ -public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t, u32_t, u8_t, u8_t, chan_id_t, tb_size_t );) +public_rlc_mac(mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t, module_id_t, frame_t, eNB_flag_t, MBMS_flag_t, logical_chan_id_t, tb_size_t );) //----------------------------------------------------------------------------- // PUBLIC RLC CONSTANTS //----------------------------------------------------------------------------- /** RLC null type identifier. */ -#define RLC_NONE 0 +#define RLC_NONE (rlc_mode_t)0 /** RLC AM type identifier. */ -#define RLC_AM 1 +#define RLC_AM (rlc_mode_t)1 /** RLC UM type identifier. */ -#define RLC_UM 2 +#define RLC_UM (rlc_mode_t)2 /** RLC TM type identifier. */ -#define RLC_TM 4 +#define RLC_TM (rlc_mode_t)4 #define RLC_MBMS_NO 0 #define RLC_MBMS_YES 1 @@ -384,10 +391,11 @@ public_rlc(void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* -/*! \fn rlc_op_status_t rlc_data_req(module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sduP) +/*! \fn rlc_op_status_t rlc_data_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, mem_block_t *sduP) * \brief Interface with higher layers, map request to the RLC corresponding to the radio bearer. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index. +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index. * \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) * \param[in] rb_idP Radio bearer identifier. @@ -397,12 +405,13 @@ public_rlc(void rlc_util_print_hex_octets(comp_name_t componentP, unsigned char* * \param[in] sduP SDU. * \return A status about the processing, OK or error code. */ -public_rlc(rlc_op_status_t rlc_data_req (module_id_t, u32_t, u8_t, u8_t,rb_id_t, mui_t, confirm_t, sdu_size_t, mem_block_t*);) +public_rlc(rlc_op_status_t rlc_data_req (module_id_t , module_id_t , frame_t , eNB_flag_t , MBMS_flag_t , rb_id_t , mui_t , confirm_t , sdu_size_t , mem_block_t *);) -/*! \fn void rlc_data_ind (module_id_t module_idP, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sduP, boolean_t is_data_planeP) +/*! \fn void rlc_data_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sduP, boolean_t is_data_planeP) { * \brief Interface with higher layers, route SDUs coming from RLC protocol instances to upper layer instance. -* \param[in] module_idP Virtualized module identifier. -* \param[in] frame Frame index +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP Frame index * \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] MBMS_flagP Flag to indicate whether this is the MBMS service (1) or not (0) * \param[in] rb_idP Radio bearer identifier. @@ -410,12 +419,13 @@ public_rlc(rlc_op_status_t rlc_data_req (module_id_t, u32_t, u8_t, u8_t,rb_i * \param[in] sduP SDU. * \param[in] is_data_planeP Boolean, is data radio bearer or not. */ -public_rlc(void rlc_data_ind (module_id_t module_idP, u8_t eNB_id, u8_t UE_id, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, rb_id_t, sdu_size_t, mem_block_t*, boolean_t);) +public_rlc(void rlc_data_ind (module_id_t , module_id_t , frame_t , eNB_flag_t , MBMS_flag_t , rb_id_t, sdu_size_t, mem_block_t*, boolean_t);) -/*! \fn void rlc_data_conf (module_id_t module_idP, u32_t frameP, u8_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP, boolean_t is_data_planeP) +/*! \fn void rlc_data_conf (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, rlc_tx_status_t statusP, boolean_t is_data_planeP) * \brief Interface with higher layers, confirm to upper layer the transmission status for a SDU stamped with a MUI, scheduled for transmission. -* \param[in] module_idP Virtualized module identifier. +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. * \param[in] frameP Frame index * \param[in] eNB_flagP Flag to indicate eNB (1) or UE (0) * \param[in] rb_idP Radio bearer identifier. @@ -423,12 +433,15 @@ public_rlc(void rlc_data_ind (module_id_t module_idP, u8_t eNB_id * \param[in] statusP Status of the transmission (RLC_SDU_CONFIRM_YES, RLC_SDU_CONFIRM_NO). * \param[in] is_data_planeP Boolean, is data radio bearer or not. */ -public_rlc(void rlc_data_conf (module_id_t, u32_t, u8_t , rb_id_t, mui_t, rlc_tx_status_t, boolean_t );) +public_rlc(void rlc_data_conf (module_id_t, module_id_t, frame_t, eNB_flag_t , rb_id_t, mui_t, rlc_tx_status_t, boolean_t );) -/*! \fn rlc_op_status_t rlc_stat_req (module_id_t module_idP, - u32_t frame, - rb_id_t rb_idP, +/*! \fn rlc_op_status_t rlc_stat_req ( + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rb_id_t rb_idP, unsigned int* stat_tx_pdcp_sdu, unsigned int* stat_tx_pdcp_bytes, unsigned int* stat_tx_pdcp_sdu_discarded, @@ -458,8 +471,10 @@ public_rlc(void rlc_data_conf (module_id_t, u32_t, u8_t , rb_id_t, unsigned int* stat_timer_status_prohibit_timed_out) * \brief Request RLC statistics of a particular radio bearer. -* \param[in] module_idP . -* \param[in] frame +* \param[in] enb_mod_idP Virtualized enb module identifier, Not used if eNB_flagP = 0. +* \param[in] ue_mod_idP Virtualized ue module identifier. +* \param[in] frameP +* \param[in] eNB_flagP * \param[in] rb_idP . * \param[out] stat_tx_pdcp_sdu Number of SDUs coming from upper layers. * \param[out] stat_tx_pdcp_bytes Number of bytes coming from upper layers. @@ -490,9 +505,12 @@ public_rlc(void rlc_data_conf (module_id_t, u32_t, u8_t , rb_id_t, * \param[out] stat_timer_status_prohibit_timed_out Number of times the timer "status_prohibit" has timed-out. */ -public_rlc(rlc_op_status_t rlc_stat_req (module_id_t module_idP, - u32_t frame, - rb_id_t rb_idP, +public_rlc(rlc_op_status_t rlc_stat_req ( + module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rb_id_t rb_idP, unsigned int* stat_tx_pdcp_sdu, unsigned int* stat_tx_pdcp_bytes, unsigned int* stat_tx_pdcp_sdu_discarded, diff --git a/openair2/LAYER2/RLC/rlc_mac.c b/openair2/LAYER2/RLC/rlc_mac.c index d596f3d517eaf9ad260e543e478371cd5e369043..19ed4ad53263afc41251e35d591c27ab637a9027 100644 --- a/openair2/LAYER2/RLC/rlc_mac.c +++ b/openair2/LAYER2/RLC/rlc_mac.c @@ -11,16 +11,17 @@ #include "rlc.h" #include "LAYER2/MAC/extern.h" #include "UTIL/LOG/log.h" +#include "UTIL/OCG/OCG_vars.h" +#include "assertions.h" -#define DEBUG_MAC_INTERFACE +#define DEBUG_MAC_INTERFACE 1 -// tb_size_t in bytes //----------------------------------------------------------------------------- -struct mac_data_ind mac_rlc_deserialize_tb (char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcsP) { +struct mac_data_ind mac_rlc_deserialize_tb (char* buffer_pP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs_pP) { //----------------------------------------------------------------------------- struct mac_data_ind data_ind; - mem_block_t* tb; + mem_block_t* tb_p; num_tb_t nb_tb_read; tbs_size_t tbs_size; @@ -29,25 +30,25 @@ struct mac_data_ind mac_rlc_deserialize_tb (char* bufferP, tb_size_t tb_sizeP, n list_init(&data_ind.data, NULL); while (num_tbP > 0) { - tb = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_sizeP); - if (tb != NULL) { - ((struct mac_tb_ind *) (tb->data))->first_bit = 0; - ((struct mac_tb_ind *) (tb->data))->data_ptr = (u8_t*)&tb->data[sizeof (mac_rlc_max_rx_header_size_t)]; - ((struct mac_tb_ind *) (tb->data))->size = tb_sizeP; - if (crcsP) - ((struct mac_tb_ind *) (tb->data))->error_indication = crcsP[nb_tb_read]; + tb_p = get_free_mem_block(sizeof (mac_rlc_max_rx_header_size_t) + tb_sizeP); + if (tb_p != NULL) { + ((struct mac_tb_ind *) (tb_p->data))->first_bit = 0; + ((struct mac_tb_ind *) (tb_p->data))->data_ptr = (u8_t*)&tb_p->data[sizeof (mac_rlc_max_rx_header_size_t)]; + ((struct mac_tb_ind *) (tb_p->data))->size = tb_sizeP; + if (crcs_pP) + ((struct mac_tb_ind *) (tb_p->data))->error_indication = crcs_pP[nb_tb_read]; else - ((struct mac_tb_ind *) (tb->data))->error_indication = 0; + ((struct mac_tb_ind *) (tb_p->data))->error_indication = 0; - memcpy(((struct mac_tb_ind *) (tb->data))->data_ptr, &bufferP[tbs_size], tb_sizeP); + memcpy(((struct mac_tb_ind *) (tb_p->data))->data_ptr, &buffer_pP[tbs_size], tb_sizeP); #ifdef DEBUG_MAC_INTERFACE LOG_T(RLC, "[MAC-RLC] DUMP RX PDU(%d bytes):\n", tb_sizeP); - rlc_util_print_hex_octets(RLC, ((struct mac_tb_ind *) (tb->data))->data_ptr, tb_sizeP); + rlc_util_print_hex_octets(RLC, ((struct mac_tb_ind *) (tb_p->data))->data_ptr, tb_sizeP); #endif nb_tb_read = nb_tb_read + 1; tbs_size = tbs_size + tb_sizeP; - list_add_tail_eurecom(tb, &data_ind.data); + list_add_tail_eurecom(tb_p, &data_ind.data); } num_tbP = num_tbP - 1; } @@ -57,200 +58,382 @@ struct mac_data_ind mac_rlc_deserialize_tb (char* bufferP, tb_size_t tb_sizeP, n return data_ind; } //----------------------------------------------------------------------------- -tbs_size_t mac_rlc_serialize_tb (char* bufferP, list_t transport_blocksP) { +tbs_size_t mac_rlc_serialize_tb (char* buffer_pP, list_t transport_blocksP) { //----------------------------------------------------------------------------- - mem_block_t* tb; + mem_block_t* tb_p; tbs_size_t tbs_size; tbs_size_t tb_size; tbs_size = 0; while (transport_blocksP.nb_elements > 0) { - tb = list_remove_head (&transport_blocksP); - if (tb != NULL) { - tb_size = ((struct mac_tb_req *) (tb->data))->tb_size; + tb_p = list_remove_head (&transport_blocksP); + if (tb_p != NULL) { + tb_size = ((struct mac_tb_req *) (tb_p->data))->tb_size; #ifdef DEBUG_MAC_INTERFACE LOG_T(RLC, "[MAC-RLC] DUMP TX PDU(%d bytes):\n", tb_size); - rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb->data))->data_ptr, tb_size); + rlc_util_print_hex_octets(RLC, ((struct mac_tb_req *) (tb_p->data))->data_ptr, tb_size); #endif - memcpy(&bufferP[tbs_size], &((struct mac_tb_req *) (tb->data))->data_ptr[0], tb_size); + memcpy(&buffer_pP[tbs_size], &((struct mac_tb_req *) (tb_p->data))->data_ptr[0], tb_size); tbs_size = tbs_size + tb_size; - free_mem_block(tb); + free_mem_block(tb_p); } } return tbs_size; } //----------------------------------------------------------------------------- -tbs_size_t mac_rlc_data_req (module_id_t module_idP, u32_t frame, u8_t MBMS_flagP, chan_id_t channel_idP, char* bufferP) { +tbs_size_t mac_rlc_data_req (module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + MBMS_flag_t MBMS_flagP, + logical_chan_id_t channel_idP, + char *buffer_pP) { //----------------------------------------------------------------------------- struct mac_data_req data_request; - rb_id_t rb_id; + rb_id_t rb_id = 0; + rlc_mode_t rlc_mode = RLC_NONE; + void *rlc_p = NULL; + #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "\n[RLC] Inst %d(%d): MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", - module_idP,MAX_MODULES, channel_idP, RLC_MAX_LC, RLC_MAX_RB); - + LOG_D(RLC, "\n[RLC] Inst %s enb id %d ue id %d: MAC_RLC_DATA_REQ channel %d (%d) MAX RB %d, Num_tb %d\n", + (eNB_flagP) ? "eNB" : "UE", enb_mod_idP, ue_mod_idP, channel_idP, RLC_MAX_LC, NB_RB_MAX); + #endif // DEBUG_MAC_INTERFACE + if (MBMS_flagP) + AssertFatal (channel_idP < RLC_MAX_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_LC); + else + AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); - if ((module_idP >= 0) && (module_idP < MAX_MODULES)) { - if ((channel_idP >= 0) && (channel_idP < RLC_MAX_LC)) { - rb_id = rlc[module_idP].m_lcid2rbid[channel_idP]; - if ((rb_id > 0) && (rb_id < RLC_MAX_RB)) { - switch (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type) { - case RLC_NONE: - //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); - break; - - case RLC_AM: - data_request = rlc_am_mac_data_request(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame); - return mac_rlc_serialize_tb(bufferP, data_request.data); - break; - - case RLC_UM: - data_request = rlc_um_mac_data_request(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame); - return mac_rlc_serialize_tb(bufferP, data_request.data); - break; - - case RLC_TM: - data_request = rlc_tm_mac_data_request(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame); - return mac_rlc_serialize_tb(bufferP, data_request.data); - break; - - default:; - //handle_event(ERROR,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no RLC found for this radio bearer %d\n", __FILE__, __LINE__, channel_idP); - } - } else { - LOG_E(RLC, "%s() : radio bearer id out of bounds :%d\n", __FUNCTION__, rb_id); - } - } else { - //handle_event(ERROR,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : parameter rb_id out of bounds :%d\n", __FILE__, __LINE__, channel_idP); - LOG_E(RLC, "%s() : parameter channel_id out of bounds :%d\n", __FUNCTION__, channel_idP); - return(-1); - } - } else { - LOG_E(RLC, "%s() : parameter module_id out of bounds :%d\n", __FUNCTION__, module_idP); - } - return (tbs_size_t)0; + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + + + if (eNB_flagP) { + rb_id = lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][channel_idP]; + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "enB RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, enb_mod_idP); + return (tbs_size_t)0; + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "enB RLC internal memory error rb id %u lcid %u module %u!\n", rb_id, channel_idP, enb_mod_idP); + } + } else { + rb_id = lcid2rbid_ue[ue_mod_idP][channel_idP]; + rlc_mode = rlc_array_ue[ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "UE RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_mod_idP); + return (tbs_size_t)0; + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "UE RLC internal memory error rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_mod_idP); + } + } + + switch (rlc_mode) { + case RLC_NONE: + break; + + case RLC_AM: + data_request = rlc_am_mac_data_request((rlc_am_entity_t*)rlc_p, frameP); + return mac_rlc_serialize_tb(buffer_pP, data_request.data); + break; + + case RLC_UM: + data_request = rlc_um_mac_data_request((rlc_um_entity_t*)rlc_p, frameP); + return mac_rlc_serialize_tb(buffer_pP, data_request.data); + break; + + case RLC_TM: + data_request = rlc_tm_mac_data_request((rlc_tm_entity_t*)rlc_p, frameP); + return mac_rlc_serialize_tb(buffer_pP, data_request.data); + break; + + default:; + } + return (tbs_size_t)0; } //----------------------------------------------------------------------------- -void mac_rlc_data_ind (module_id_t module_idP, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, chan_id_t channel_idP, char* bufferP, tb_size_t tb_sizeP, num_tb_t num_tbP, crc_t *crcs) { +void mac_rlc_data_ind (module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + MBMS_flag_t MBMS_flagP, + logical_chan_id_t channel_idP, + char *buffer_pP, + tb_size_t tb_sizeP, + num_tb_t num_tbP, + crc_t *crcs_pP) { //----------------------------------------------------------------------------- - rb_id_t rb_id; + rb_id_t rb_id = 0; + rlc_mode_t rlc_mode = RLC_NONE; + void *rlc_p = NULL; #ifdef DEBUG_MAC_INTERFACE if (num_tbP) { - LOG_D(RLC, "\n[RLC] Inst %d(%d): MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n", - module_idP,MAX_MODULES, channel_idP, RLC_MAX_LC, RLC_MAX_RB, num_tbP); + LOG_D(RLC, "[Frame %5u][%s][RLC][MOD %u/%u] MAC_RLC_DATA_IND on channel %d (%d), rb max %d, Num_tb %d\n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + channel_idP, + RLC_MAX_LC, + NB_RB_MAX, + num_tbP); } #endif // DEBUG_MAC_INTERFACE + if (MBMS_flagP) + AssertFatal (channel_idP < RLC_MAX_LC, "channel id is too high (%u/%d)!\n", channel_idP, RLC_MAX_LC); + else + AssertFatal (channel_idP < NB_RB_MAX, "channel id is too high (%u/%d)!\n", channel_idP, NB_RB_MAX); - if ((module_idP >= 0) && (module_idP < MAX_MODULES)) { - if ((channel_idP >= 0) && (channel_idP < RLC_MAX_LC)) { - rb_id = rlc[module_idP].m_lcid2rbid[channel_idP]; - if ((rb_id > 0) && (rb_id < RLC_MAX_RB)) { - //if (num_tbP > 0) { - struct mac_data_ind data_ind = mac_rlc_deserialize_tb(bufferP, tb_sizeP, num_tbP, crcs); + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); - switch (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type) { - case RLC_NONE: - //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, rb_idP); - LOG_W(RLC, " FONCTION mac_rlc_data_ind() : no radio bearer configured :%d\n", rb_id); - break; + if (eNB_flagP) { + rb_id = lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][channel_idP]; + AssertFatal (rb_id < NB_RB_MAX, "enB RB id is too high (%u/%d) lcid %u enb module %u ue module id %u!\n", rb_id, NB_RB_MAX, channel_idP, enb_mod_idP, ue_mod_idP); + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "enB RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, enb_mod_idP); + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "enB RLC internal memory error rb id %u lcid %u module %u!\n", rb_id, channel_idP, enb_mod_idP); + } + } else { + rb_id = lcid2rbid_ue[ue_mod_idP][channel_idP]; + AssertFatal (rb_id < NB_RB_MAX, "UE RB id is too high (%u/%d) lcid %u enb module %u ue module id %u!\n", rb_id, NB_RB_MAX, channel_idP, enb_mod_idP, ue_mod_idP); + rlc_mode = rlc_array_ue[ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "UE RLC not configured rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_mod_idP); + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "UE RLC internal memory error rb id %u lcid %u module %u!\n", rb_id, channel_idP, ue_mod_idP); + } + } + struct mac_data_ind data_ind = mac_rlc_deserialize_tb(buffer_pP, tb_sizeP, num_tbP, crcs_pP); + switch (rlc_mode) { + case RLC_NONE: + //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); + break; - case RLC_AM: + case RLC_AM: #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_AM MOD_ID %d RB_INDEX %d (%d) MOD_ID_RLC %d\n", module_idP, rlc[module_idP].m_rlc_pointer[rb_id].rlc_index, rb_id, rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index].module_id); + LOG_D(RLC, "MAC DATA IND TO RLC_AM MOD_ID %s enb id %u ue id %u \n", (eNB_flagP) ? "eNB" : "UE", enb_mod_idP, ue_mod_idP); #endif + rlc_am_mac_data_indication((rlc_am_entity_t*)rlc_p, frameP, eNB_flagP, data_ind); + break; - rlc_am_mac_data_indication(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame, eNB_flag, data_ind); - break; - - case RLC_UM: + case RLC_UM: #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_UM MOD_ID %d RB_INDEX %d MOD_ID_RLC %d\n", module_idP, rlc[module_idP].m_rlc_pointer[rb_id].rlc_index, rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index].module_id); + LOG_D(RLC, "MAC DATA IND TO RLC_UM MOD_ID %s enb id %u ue id %u \n", (eNB_flagP) ? "eNB" : "UE", enb_mod_idP, ue_mod_idP); #endif - rlc_um_mac_data_indication(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame, eNB_flag, data_ind); - break; + rlc_um_mac_data_indication((rlc_um_entity_t*)rlc_p, frameP, eNB_flagP, data_ind); + break; - case RLC_TM: + case RLC_TM: #ifdef DEBUG_MAC_INTERFACE - LOG_D(RLC, "MAC DATA IND TO RLC_TM MOD_ID %d RB_INDEX %d MOD_ID_RLC %d\n", module_idP, rlc[module_idP].m_rlc_pointer[rb_id].rlc_index, rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index].module_id); + LOG_D(RLC, "MAC DATA IND TO RLC_TM MOD_ID %s enb id %u ue id %u \n", (eNB_flagP) ? "eNB" : "UE", enb_mod_idP, ue_mod_idP); #endif - rlc_tm_mac_data_indication(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], frame, eNB_flag, data_ind); - break; - - default: - //handle_event(ERROR,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no RLC found for this radio bearer %d\n", __FILE__, __LINE__, rb_idP); - LOG_W(RLC, "FILE FONCTION mac_rlc_data_ind() LINE : no RLC found for this radio bearer %d\n", rb_id); - ; - - } - } else { - LOG_E(RLC, "%s() : radio bearer id out of bounds : rb is %d\n", __FUNCTION__, rb_id); - } - } else { - LOG_E(RLC, "%s() : parameter channel_id out of bounds : channel is %d\n", __FUNCTION__, channel_idP); - } - } else { - LOG_E(RLC, "%s() : parameter module_id out of bounds : module id is %d\n", __FUNCTION__, module_idP); + rlc_tm_mac_data_indication((rlc_tm_entity_t*)rlc_p, frameP, eNB_flagP, data_ind); + break; } } //----------------------------------------------------------------------------- -mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t module_idP, u32_t frame, u8_t eNB_flag, u8_t MBMS_flagP, chan_id_t channel_idP, tb_size_t tb_sizeP) { +mac_rlc_status_resp_t mac_rlc_status_ind (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, logical_chan_id_t channel_idP, tb_size_t tb_sizeP) { //----------------------------------------------------------------------------- - rb_id_t rb_id = 0; mac_rlc_status_resp_t mac_rlc_status_resp; + struct mac_status_ind tx_status; + struct mac_status_resp status_resp; + rb_id_t rb_id = 0; + rlc_mode_t rlc_mode = RLC_NONE; + void *rlc_p = NULL; + + memset (&mac_rlc_status_resp, 0, sizeof(mac_rlc_status_resp_t)); + memset (&tx_status , 0, sizeof(struct mac_status_ind)); + + if (MBMS_flagP) + AssertFatal (channel_idP < RLC_MAX_LC, "%s channel id is too high (%u/%d) enb module id %u ue module id %u!\n",(eNB_flagP) ? "eNB" : "UE", channel_idP, RLC_MAX_LC, enb_mod_idP, ue_mod_idP); + else + AssertFatal (channel_idP < NB_RB_MAX, "%s channel id is too high (%u/%d) enb module id %u ue module id %u!\n",(eNB_flagP) ? "eNB" : "UE", channel_idP, NB_RB_MAX, enb_mod_idP, ue_mod_idP); + + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); + - mac_rlc_status_resp.bytes_in_buffer = 0; - mac_rlc_status_resp.pdus_in_buffer = 0; - - if ((module_idP >= 0) && (module_idP < MAX_MODULES)) { - if ((channel_idP >= 0) && (channel_idP < RLC_MAX_LC)) { - rb_id = rlc[module_idP].m_lcid2rbid[channel_idP]; - if ((rb_id > 0) && (rb_id < RLC_MAX_RB)) { - struct mac_status_resp status_resp; - struct mac_status_ind tx_status; - switch (rlc[module_idP].m_rlc_pointer[channel_idP].rlc_type) { - case RLC_NONE: - //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); - break; - - case RLC_AM: - status_resp = rlc_am_mac_status_indication(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[channel_idP].rlc_index], frame, tb_sizeP, tx_status); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; - mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; - mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; - return mac_rlc_status_resp; - break; - - case RLC_UM: - //msg("[RLC_UM][MOD %d] mac_rlc_status_ind tb_size %d\n", module_idP, tb_sizeP); - status_resp = rlc_um_mac_status_indication(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[channel_idP].rlc_index], frame, eNB_flag, tb_sizeP, tx_status); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; - mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; - mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; - mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; - return mac_rlc_status_resp; - break; - - case RLC_TM: - status_resp = rlc_tm_mac_status_indication(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[channel_idP].rlc_index], frame, tb_sizeP, tx_status); - mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; - mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; - return mac_rlc_status_resp; - break; - - default:; - //handle_event(ERROR,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no RLC found for this radio bearer %d\n", __FILE__, __LINE__, channel_idP); - - } - } else { - // two many traces because MAC probe inactive channels. LOG_E(RLC, "%s(Mod=%d, eNB_flag=%d, mbms flag=%d,channel_id=%d) : radio bearer id out of bounds :%d \n", __FUNCTION__, module_idP, eNB_flag, MBMS_flagP, channel_idP, rb_id); - } - } else { - LOG_E(RLC, "%s() : parameter channel_id out of bounds :%d\n", __FUNCTION__, channel_idP); + if (eNB_flagP) { + rb_id = lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][channel_idP]; + if (rb_id >= NB_RB_MAX) { + /*LOG_D(RLC, "[FRAME %05d][%s][RLC][MOD %u/%u] MAC STATUS IND TO NOT CONFIGURED BEARER lc id %u \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + channel_idP);*/ + return mac_rlc_status_resp; + } + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + //LOG_E (RLC, "enB RLC not configured rb id %u lcid %u enb id %u ue id %u!\n", rb_id, channel_idP, enb_mod_idP, ue_mod_idP); + return mac_rlc_status_resp; + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "enB RLC internal memory error rb id %u lcid %u enb id %u ue id %u!\n", rb_id, channel_idP, enb_mod_idP, ue_mod_idP); } } else { - LOG_E(RLC, "%s() : parameter module_id out of bounds :%d\n", __FUNCTION__, module_idP); + rb_id = lcid2rbid_ue[ue_mod_idP][channel_idP]; + if (rb_id >= NB_RB_MAX) { + /*LOG_D(RLC, "[FRAME %05d][%s][RLC][MOD %u/%u] MAC STATUS IND TO NOT CONFIGURED BEARER lc id %u \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + channel_idP);*/ + return mac_rlc_status_resp; + } + rlc_mode = rlc_array_ue[ue_mod_idP][rb_id].mode; + switch (rlc_mode) { + case RLC_NONE: + AssertFatal (0 , "UE RLC not configured rb id %u lcid %u enb id %u ue id %u!\n", rb_id, channel_idP, enb_mod_idP, ue_mod_idP); + return mac_rlc_status_resp; + break; + case RLC_AM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.am; + break; + case RLC_UM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.um; + break; + case RLC_TM: + rlc_p = (void*)&rlc_array_ue[ue_mod_idP][rb_id].rlc.tm; + break; + default: + AssertFatal (0 , "UE RLC internal memory error rb id %u lcid %u enb id %u ue id %u!\n", rb_id, channel_idP, enb_mod_idP, ue_mod_idP); + } + } + + switch (rlc_mode) { + case RLC_NONE: + //handle_event(WARNING,"FILE %s FONCTION mac_rlc_data_ind() LINE %s : no radio bearer configured :%d\n", __FILE__, __LINE__, channel_idP); + break; + + case RLC_AM: + status_resp = rlc_am_mac_status_indication((rlc_am_entity_t*)rlc_p, frameP, tb_sizeP, tx_status); + mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; + mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; + mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; + mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; + return mac_rlc_status_resp; + break; + + case RLC_UM: + status_resp = rlc_um_mac_status_indication((rlc_um_entity_t*)rlc_p, frameP, eNB_flagP, tb_sizeP, tx_status); + mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; + mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; + mac_rlc_status_resp.head_sdu_creation_time = status_resp.head_sdu_creation_time; + mac_rlc_status_resp.head_sdu_remaining_size_to_send = status_resp.head_sdu_remaining_size_to_send; + mac_rlc_status_resp.head_sdu_is_segmented = status_resp.head_sdu_is_segmented; + return mac_rlc_status_resp; + break; + + case RLC_TM: + status_resp = rlc_tm_mac_status_indication((rlc_tm_entity_t*)rlc_p, frameP, tb_sizeP, tx_status); + mac_rlc_status_resp.bytes_in_buffer = status_resp.buffer_occupancy_in_bytes; + mac_rlc_status_resp.pdus_in_buffer = status_resp.buffer_occupancy_in_pdus; + return mac_rlc_status_resp; + break; + + default:; } return mac_rlc_status_resp; } diff --git a/openair2/LAYER2/RLC/rlc_mpls.c b/openair2/LAYER2/RLC/rlc_mpls.c index 71b4596ee55853cae0e33252ecd16696dc77d2fc..0fddf648c69fb85c668f1383790b9acc0157b500 100644 --- a/openair2/LAYER2/RLC/rlc_mpls.c +++ b/openair2/LAYER2/RLC/rlc_mpls.c @@ -11,9 +11,9 @@ //----------------------------------------------------------------------------- -rlc_op_status_t mpls_rlc_data_req (module_id_t module_idP, u32_t frame, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sduP) { +rlc_op_status_t mpls_rlc_data_req (module_id_t enb_module_idP, module_id_t ue_module_idP, u32_t frame, rb_id_t rb_idP, sdu_size_t sdu_sizeP, mem_block_t* sduP) { //----------------------------------------------------------------------------- // third arg should be set to 1 or 0 - return rlc_data_req(module_idP, frame, 0, 0,rb_idP, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, sdu_sizeP, sduP); + return rlc_data_req(enb_module_idP, ue_module_idP, frame, 0, 0,rb_idP, RLC_MUI_UNDEFINED, RLC_SDU_CONFIRM_NO, sdu_sizeP, sduP); } diff --git a/openair2/LAYER2/RLC/rlc_rrc.c b/openair2/LAYER2/RLC/rlc_rrc.c index 2ff2951b5819fedbf17f84750279748d1fbfdded..cdec049c4e51acb0e8e335b4142f0293aaa8b217 100644 --- a/openair2/LAYER2/RLC/rlc_rrc.c +++ b/openair2/LAYER2/RLC/rlc_rrc.c @@ -12,7 +12,9 @@ #include "rlc_um.h" #include "rlc_tm.h" #include "UTIL/LOG/log.h" - +#ifdef OAI_EMU +#include "UTIL/OCG/OCG_vars.h" +#endif #include "RLC-Config.h" #include "DRB-ToAddMod.h" #include "DRB-ToAddModList.h" @@ -24,20 +26,21 @@ #endif #include "LAYER2/MAC/extern.h" +#include "assertions.h" //----------------------------------------------------------------------------- #ifdef Rel10 -rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u8_t eNB_flagP, u8_t UE_index, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, PMCH_InfoList_r9_t *pmch_info_listP) { +rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP, PMCH_InfoList_r9_t *pmch_info_listP) { #else -rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u8_t eNB_flagP, u8_t UE_index, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP) { +rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, SRB_ToAddModList_t* srb2add_listP, DRB_ToAddModList_t* drb2add_listP, DRB_ToReleaseList_t* drb2release_listP) { #endif//----------------------------------------------------------------------------- - long int rb_id = 0; - long int lc_id = 0; - DRB_Identity_t drb_id = 0; - DRB_Identity_t* pdrb_id = NULL; - long int cnt = 0; - SRB_ToAddMod_t* srb_toaddmod = NULL; - DRB_ToAddMod_t* drb_toaddmod = NULL; - rlc_mode_t rlc_type; + rb_id_t rb_id = 0; + logical_chan_id_t lc_id = 0; + DRB_Identity_t drb_id = 0; + DRB_Identity_t* pdrb_id = NULL; + long int cnt = 0; + SRB_ToAddMod_t *srb_toaddmod = NULL; + DRB_ToAddMod_t *drb_toaddmod = NULL; + rlc_mode_t rlc_mode = RLC_NONE; #ifdef Rel10 long int cnt2 = 0; // long int mrb_id = 0; @@ -49,12 +52,39 @@ rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u DL_UM_RLC_t dl_um_rlc; #endif - LOG_D(RLC, "[RLC_RRC][MOD_id %d]CONFIG REQ ASN1 \n",module_idP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP); + +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif if (srb2add_listP != NULL) { for (cnt=0;cnt<srb2add_listP->list.count;cnt++) { - rb_id = (UE_index * NB_RB_MAX) + srb2add_listP->list.array[cnt]->srb_Identity; + rb_id = srb2add_listP->list.array[cnt]->srb_Identity; - rlc_type = rlc[module_idP].m_rlc_pointer[rb_id].rlc_type; + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_id].mode; + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_id].mode; + } LOG_D(RLC, "Adding SRB %d, rb_id %d\n",srb2add_listP->list.array[cnt]->srb_Identity,rb_id); srb_toaddmod = srb2add_listP->list.array[cnt]; @@ -67,97 +97,151 @@ rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u case RLC_Config_PR_NOTHING: break; case RLC_Config_PR_am: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, rb_id, rb_id, RLC_AM) == RLC_OP_STATUS_OK) { - config_req_rlc_am_asn1 (&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, rb_id, RLC_AM) == RLC_OP_STATUS_OK) { + config_req_rlc_am_asn1 ( frameP, - eNB_flagP, - module_idP, + eNB_flagP, + enb_mod_idP, + ue_mod_idP, &srb_toaddmod->rlc_Config->choice.explicitValue.choice.am, rb_id, SIGNALLING_RADIO_BEARER); } else { - LOG_E(RLC, "[RLC_RRC][MOD_id %d] ERROR IN ALLOCATING SRB %d \n",module_idP, rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d AM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] SRB %d AM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } break; case RLC_Config_PR_um_Bi_Directional: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, &srb_toaddmod->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.ul_UM_RLC, &srb_toaddmod->rlc_Config->choice.explicitValue.choice.um_Bi_Directional.dl_UM_RLC, rb_id, SIGNALLING_RADIO_BEARER); } else { - LOG_E(RLC, "[RLC_RRC][MOD_id %d] ERROR IN ALLOCATING SRB %d \n",module_idP, rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } break; case RLC_Config_PR_um_Uni_Directional_UL: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, &srb_toaddmod->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, rb_id, SIGNALLING_RADIO_BEARER); } else { - LOG_E(RLC, "[RLC_RRC][MOD_id %d] ERROR IN ALLOCATING SRB %d \n",module_idP, rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } break; case RLC_Config_PR_um_Uni_Directional_DL: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, rb_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, NULL, &srb_toaddmod->rlc_Config->choice.explicitValue.choice.um_Uni_Directional_DL.dl_UM_RLC, rb_id, SIGNALLING_RADIO_BEARER); } else { - LOG_E(RLC, "[RLC_RRC][MOD_id %d] ERROR IN ALLOCATING SRB %d \n",module_idP, rb_id); + LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] ERROR IN ALLOCATING SRB %d \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] SRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } break; default: - LOG_E(RLC, "[RLC_RRC][MOD_id %d] UNKNOWN RLC CONFIG %d \n", - module_idP, srb_toaddmod->rlc_Config->choice.explicitValue.present); + LOG_E(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] UNKNOWN RLC CONFIG %d \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + srb_toaddmod->rlc_Config->choice.explicitValue.present); break; } break; case SRB_ToAddMod__rlc_Config_PR_defaultValue: #warning TO DO SRB_ToAddMod__rlc_Config_PR_defaultValue - if (rlc_type == RLC_NONE) { - rrc_rlc_add_rlc (module_idP, frameP, rb_id, rb_id, RLC_UM); - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_id, rb_id, RLC_UM); + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, NULL, // TO DO DEFAULT CONFIG NULL, // TO DO DEFAULT CONFIG rb_id, SIGNALLING_RADIO_BEARER); } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] SRB %d DEFAULT UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, rb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] SRB %d DEFAULT UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_id); } break; default:; @@ -169,87 +253,115 @@ rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u for (cnt=0;cnt<drb2add_listP->list.count;cnt++) { drb_toaddmod = drb2add_listP->list.array[cnt]; - drb_id = (UE_index * NB_RB_MAX) + *drb_toaddmod->logicalChannelIdentity;//drb_toaddmod->drb_Identity; - rlc_type = rlc[module_idP].m_rlc_pointer[drb_id].rlc_type; - LOG_D(RLC, "Adding DRB %d, rb_id %d\n",*drb_toaddmod->logicalChannelIdentity,drb_id); - - if (drb_toaddmod->logicalChannelIdentity != null) { - lc_id = (UE_index * NB_RB_MAX) + *drb_toaddmod->logicalChannelIdentity; + drb_id = *drb_toaddmod->logicalChannelIdentity;//drb_toaddmod->drb_Identity; + lc_id = drb_id; + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][drb_id].mode; } else { - lc_id = drb_id; -#warning TO DO set a default drb id if not provided by upper layers for a DRB - LOG_W(RLC, "[RLC_RRC][MOD_id %d] rlc[module_id].m_lcid2rbid[lc_id=%d] not set\n",module_idP, lc_id); + rlc_mode = rlc_array_ue[ue_mod_idP][drb_id].mode; } + LOG_D(RLC, "Adding DRB %d, rb_id %d\n",*drb_toaddmod->logicalChannelIdentity,drb_id); + + if (drb_toaddmod->rlc_Config) { switch (drb_toaddmod->rlc_Config->present) { case RLC_Config_PR_NOTHING: break; case RLC_Config_PR_am: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, drb_id, lc_id, RLC_AM) == RLC_OP_STATUS_OK) { - config_req_rlc_am_asn1 (&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[drb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, drb_id, lc_id, RLC_AM) == RLC_OP_STATUS_OK) { + config_req_rlc_am_asn1 ( frameP, eNB_flagP, - module_idP, + enb_mod_idP, + ue_mod_idP, &drb_toaddmod->rlc_Config->choice.am, drb_id, RADIO_ACCESS_BEARER); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] DRB %d AM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, drb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] DRB %d AM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + drb_id); } break; case RLC_Config_PR_um_Bi_Directional: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[drb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, &drb_toaddmod->rlc_Config->choice.um_Bi_Directional.ul_UM_RLC, &drb_toaddmod->rlc_Config->choice.um_Bi_Directional.dl_UM_RLC, drb_id, RADIO_ACCESS_BEARER); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, drb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + drb_id); } break; case RLC_Config_PR_um_Uni_Directional_UL: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[drb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, &drb_toaddmod->rlc_Config->choice.um_Uni_Directional_UL.ul_UM_RLC, NULL, drb_id, RADIO_ACCESS_BEARER); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, drb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + drb_id); } break; case RLC_Config_PR_um_Uni_Directional_DL: - if (rlc_type == RLC_NONE) { - if (rrc_rlc_add_rlc (module_idP, frameP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { - config_req_rlc_um_asn1(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[drb_id].rlc_index], + if (rlc_mode == RLC_NONE) { + if (rrc_rlc_add_rlc (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, drb_id, lc_id, RLC_UM) == RLC_OP_STATUS_OK) { + config_req_rlc_um_asn1( frameP, eNB_flagP, RLC_MBMS_NO, - module_idP, + enb_mod_idP, + ue_mod_idP, NULL, &drb_toaddmod->rlc_Config->choice.um_Uni_Directional_DL.dl_UM_RLC, drb_id, RADIO_ACCESS_BEARER); } } else { - LOG_D(RLC, "[RLC_RRC][MOD_id %d] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n",module_idP, drb_id); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] DRB %d UM ALREADY CONFIGURED, TO DO MODIFY \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + drb_id); } break; default: - LOG_W(RLC, "[RLC_RRC][MOD_id %d][RB %d] unknown drb_toaddmod->rlc_Config->present \n",module_idP,drb_id); + LOG_W(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u][RB %u] unknown drb_toaddmod->rlc_Config->present \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + drb_id); } } } @@ -257,80 +369,85 @@ rlc_op_status_t rrc_rlc_config_asn1_req (module_id_t module_idP, u32_t frameP, u if (drb2release_listP != NULL) { for (cnt=0;cnt<drb2release_listP->list.count;cnt++) { pdrb_id = drb2release_listP->list.array[cnt]; - rrc_rlc_remove_rlc(module_idP, (UE_index * NB_RB_MAX) + *pdrb_id, frameP); + rrc_rlc_remove_rlc(enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, *pdrb_id); } } - #ifdef Rel10 if (pmch_info_listP != NULL) { - LOG_I(RLC,"[%s %d] Config RLC instance for MBMS\n", (eNB_flagP) ? "eNB" : "UE", (eNB_flagP) ? module_idP : module_idP - NB_eNB_INST); + LOG_I(RLC,"[%s %d] Config RLC instance for MBMS\n", (eNB_flagP) ? "eNB" : "UE", (eNB_flagP) ? module_idP : module_idP - NB_eNB_INST); - for (cnt=0;cnt<pmch_info_listP->list.count;cnt++) { - pmch_info_r9 = pmch_info_listP->list.array[cnt]; + for (cnt=0;cnt<pmch_info_listP->list.count;cnt++) { + pmch_info_r9 = pmch_info_listP->list.array[cnt]; - for (cnt2=0;cnt2<pmch_info_r9->mbms_SessionInfoList_r9.list.count;cnt2++) { - mbms_session = pmch_info_r9->mbms_SessionInfoList_r9.list.array[cnt2]; - - if (mbms_session->logicalChannelIdentity_r9 > 0) { + for (cnt2=0;cnt2<pmch_info_r9->mbms_SessionInfoList_r9.list.count;cnt2++) { + mbms_session = pmch_info_r9->mbms_SessionInfoList_r9.list.array[cnt2]; - // lc_id = (NUMBER_OF_UE_MAX*NB_RB_MAX) + mbms_session->logicalChannelIdentity_r9; - // test this one and tell Lionel - if (eNB_flagP) { - /* SR: (maxDRB = 11 + 3) * 16 = 224... */ - lc_id = mbms_session->logicalChannelIdentity_r9 + (maxDRB + 3) * MAX_MOBILES_PER_RG; - } else { - lc_id = mbms_session->logicalChannelIdentity_r9 + (maxDRB + 3); + if (mbms_session->logicalChannelIdentity_r9 > 0) { + + // lc_id = (NUMBER_OF_UE_MAX*NB_RB_MAX) + mbms_session->logicalChannelIdentity_r9; + // test this one and tell Lionel + if (eNB_flagP) { + /* SR: (maxDRB = 11 + 3) * 16 = 224... */ + lc_id = mbms_session->logicalChannelIdentity_r9 + (maxDRB + 3) * MAX_MOBILES_PER_RG; + } else { + lc_id = mbms_session->logicalChannelIdentity_r9 + (maxDRB + 3); + } + + /* + if (mbms_session->sessionId_r9 != NULL) { + mbms_session_id = mbms_session->sessionId_r9->buf[0]; + } else { + mbms_session_id = mbms_session->logicalChannelIdentity_r9; + } + */ + mbms_service_id = mbms_session->tmgi_r9.serviceId_r9.buf[2];// can use the pmch_index, here is the value 'cnt' + rb_id = (mbms_service_id * maxSessionPerPMCH) + lc_id; + + if (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type == RLC_NONE) { + rlc_status = rrc_rlc_add_rlc (module_idP, frameP, rb_id, lc_id, RLC_UM); + if (rlc_status != RLC_OP_STATUS_OK ) { + LOG_D(RLC, "[RLC_RRC] COULD NOT ALLOCATE RLC UM INSTANCE\n"); + continue;//? return rlc_status; + } + } else if (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type != RLC_UM) { + LOG_E(RLC, "[RLC_RRC] MBMS ERROR IN CONFIG, RLC FOUND ALREADY CONFIGURED FOR MBMS BEARER IS NOT UM\n"); + continue; + } + dl_um_rlc.sn_FieldLength = SN_FieldLength_size5; + dl_um_rlc.t_Reordering = T_Reordering_ms0; + + config_req_rlc_um_asn1 ( + frameP, + eNB_flagP, + RLC_MBMS_YES, + enb_mod_idP, + ue_mod_idP, + NULL, + &dl_um_rlc, + rb_id, + RADIO_ACCESS_BEARER); + } else { + LOG_D(RLC, "[RLC_RRC] Invalid LogicalChannelIdentity for MTCH --- Value 0 is reserved for MCCH\n"); + lc_id = -1; + } } - - /* - if (mbms_session->sessionId_r9 != NULL) { - mbms_session_id = mbms_session->sessionId_r9->buf[0]; - } else { - mbms_session_id = mbms_session->logicalChannelIdentity_r9; - } - */ - mbms_service_id = mbms_session->tmgi_r9.serviceId_r9.buf[2];// can use the pmch_index, here is the value 'cnt' - rb_id = (mbms_service_id * maxSessionPerPMCH) + lc_id; - - if (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type == RLC_NONE) { - rlc_status = rrc_rlc_add_rlc (module_idP, frameP, rb_id, lc_id, RLC_UM); - if (rlc_status != RLC_OP_STATUS_OK ) { - LOG_D(RLC, "[RLC_RRC] COULD NOT ALLOCATE RLC UM INSTANCE\n"); - continue;//? return rlc_status; - } - } else if (rlc[module_idP].m_rlc_pointer[rb_id].rlc_type != RLC_UM) { - LOG_E(RLC, "[RLC_RRC] MBMS ERROR IN CONFIG, RLC FOUND ALREADY CONFIGURED FOR MBMS BEARER IS NOT UM\n"); - continue; - } - dl_um_rlc.sn_FieldLength = SN_FieldLength_size5; - dl_um_rlc.t_Reordering = T_Reordering_ms0; - - config_req_rlc_um_asn1 (&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_id].rlc_index], - frameP, - eNB_flagP, - RLC_MBMS_YES, - module_idP, - NULL, - &dl_um_rlc, - rb_id, - RADIO_ACCESS_BEARER); - } else { - LOG_D(RLC, "[RLC_RRC] Invalid LogicalChannelIdentity for MTCH --- Value 0 is reserved for MCCH\n"); - lc_id = -1; - } } - } } #endif - LOG_D(RLC, "[RLC_RRC][MOD_id %d]CONFIG REQ ASN1 END \n",module_idP); + LOG_D(RLC, "[FRAME %5u][%s][RLC_RRC][MOD %u/%u] CONFIG REQ ASN1 END \n", + frameP, + (eNB_flagP) ? "eNB" : "UE", + eNB_flagP, + enb_mod_idP, + ue_mod_idP); return RLC_OP_STATUS_OK; } //----------------------------------------------------------------------------- rlc_op_status_t -rb_release_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t module_idP) +rb_release_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t enb_mod_idP, module_id_t ue_mod_idP) { //----------------------------------------------------------------------------- rlc_tm_cleanup(rlcP); @@ -338,7 +455,7 @@ rb_release_rlc_tm (struct rlc_tm_entity *rlcP, module_id_t module_idP) } //----------------------------------------------------------------------------- rlc_op_status_t -rb_release_rlc_um (struct rlc_um_entity *rlcP, module_id_t module_idP) +rb_release_rlc_um (struct rlc_um_entity *rlcP, module_id_t enb_mod_idP, module_id_t ue_mod_idP) { //----------------------------------------------------------------------------- rlc_um_cleanup(rlcP); @@ -346,201 +463,437 @@ rb_release_rlc_um (struct rlc_um_entity *rlcP, module_id_t module_idP) } //----------------------------------------------------------------------------- rlc_op_status_t -rb_release_rlc_am (struct rlc_am_entity *rlcP, u32_t frame, module_id_t module_idP) +rb_release_rlc_am (struct rlc_am_entity *rlcP, frame_t frameP, module_id_t enb_mod_idP, module_id_t ue_mod_idP) { //----------------------------------------------------------------------------- rlc_am_cleanup(rlcP,frame); return RLC_OP_STATUS_OK; } //----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_remove_rlc (module_id_t module_idP, rb_id_t rb_idP, u32_t frame) { +rlc_op_status_t rrc_rlc_remove_rlc (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP) { //----------------------------------------------------------------------------- - int lcid = 0; - int rlc_mode = rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type; - // - rlc_op_status_t status; - - if ( rb_idP >= RLC_MAX_RB ) { - LOG_E(RLC,"Got wrong radio bearer id %d\n",rb_idP); - return RLC_OP_STATUS_BAD_PARAMETER; - } + logical_chan_id_t lcid = 0; + rlc_mode_t rlc_mode = RLC_NONE; + rlc_op_status_t status; - switch (rlc_mode) { - case RLC_AM: - LOG_D(RLC, "[RLC_RRC][MOD_id %d] RELEASE RAB AM %d \n", module_idP, rb_idP); - status = rb_release_rlc_am(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], frame, module_idP); - rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].allocation = 0; - break; - case RLC_TM: - LOG_D(RLC, "[RLC_RRC][MOD_id %d] RELEASE RAB TM %d \n",module_idP,rb_idP); - status = rb_release_rlc_tm(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], module_idP); - rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].allocation = 0; - break; - case RLC_UM: - LOG_D(RLC, "[RLC_RRC][MOD_id %d] RELEASE RAB UM %d \n",module_idP,rb_idP); - status = rb_release_rlc_um(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], module_idP); - rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index].allocation = 0; - break; - default: - LOG_E(RLC, "[RLC_RRC][MOD_id %d] RELEASE RAB %d RLC_MODE %d INDEX %d\n",module_idP,rb_idP,rlc_mode, rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index); - mac_xface->macphy_exit("[RLC]REMOVE RB ERROR: UNKNOWN RLC MODE"); - return RLC_OP_STATUS_BAD_PARAMETER; - break; - } - - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type = RLC_NONE; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index = -1; +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif - // remove pairing between lcid and rbid - while (( lcid < RLC_MAX_LC) && (rlc[module_idP].m_lcid2rbid[lcid] != rb_idP)) { - lcid++; - } - if (lcid < RLC_MAX_LC) { - rlc[module_idP].m_lcid2rbid[lcid] = -1; - } + AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); - return status; + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_AM: + LOG_D(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u] RELEASE RB AM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am.channel_id; + AssertFatal (lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC AM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid], rb_idP); + lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_am(&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am, frame, enb_mod_idP, ue_mod_idP); + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am.allocation = 0; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + case RLC_TM: + LOG_D(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u] RELEASE RB TM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm.channel_id; + AssertFatal (lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC TM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid], rb_idP); + lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_tm(&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm, enb_mod_idP, ue_mod_idP); + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm.allocation = 0; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + case RLC_UM: + LOG_D(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u] RELEASE RB UM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um.channel_id; + AssertFatal (lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC UM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid], rb_idP); + lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_um(&rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um, enb_mod_idP, ue_mod_idP); + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um.allocation = 0; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + default: + LOG_E(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u] RELEASE RB mode %d\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + rlc_mode); + return RLC_OP_STATUS_BAD_PARAMETER; + break; + } + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; + switch (rlc_mode) { + case RLC_AM: + LOG_D(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] RELEASE RB AM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_ue[ue_mod_idP][rb_idP].rlc.am.channel_id; + AssertFatal (lcid2rbid_ue[ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC AM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_ue[ue_mod_idP][lcid], rb_idP); + lcid2rbid_ue[ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_am(&rlc_array_ue[ue_mod_idP][rb_idP].rlc.am, frame, enb_mod_idP, ue_mod_idP); + rlc_array_ue[ue_mod_idP][rb_idP].rlc.am.allocation = 0; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + case RLC_TM: + LOG_D(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] RELEASE RB TM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm.channel_id; + AssertFatal (lcid2rbid_ue[ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC TM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_ue[ue_mod_idP][lcid], rb_idP); + lcid2rbid_ue[ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_tm(&rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm, enb_mod_idP, ue_mod_idP); + rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm.allocation = 0; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + case RLC_UM: + LOG_D(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] RELEASE RB UM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + lcid = rlc_array_ue[ue_mod_idP][rb_idP].rlc.um.channel_id; + AssertFatal (lcid2rbid_ue[ue_mod_idP][lcid] == rb_idP, "Mismatch in RLC UM LC %u/RB %u mapping for RB %u\n", lcid, lcid2rbid_ue[ue_mod_idP][lcid], rb_idP); + lcid2rbid_ue[ue_mod_idP][lcid] = RLC_RB_UNALLOCATED; + status = rb_release_rlc_um(&rlc_array_ue[ue_mod_idP][rb_idP].rlc.um, enb_mod_idP, ue_mod_idP); + rlc_array_ue[ue_mod_idP][rb_idP].rlc.um.allocation = 0; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_NONE; + break; + default: + LOG_E(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] RELEASE RB mode %d\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + rlc_mode); + return RLC_OP_STATUS_BAD_PARAMETER; + break; + } + } + return status; } //----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_add_rlc (module_id_t module_idP, u32_t frameP, rb_id_t rb_idP, chan_id_t chan_idP, rlc_mode_t rlc_modeP) { +rlc_op_status_t rrc_rlc_add_rlc (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, logical_chan_id_t chan_idP, rlc_mode_t rlc_modeP) { //----------------------------------------------------------------------------- - unsigned int index; - unsigned int index_max; - unsigned int allocation; + rlc_mode_t rlc_mode = RLC_NONE; + unsigned int allocation; - switch (rlc_modeP) { +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif + AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); + AssertFatal (chan_idP < RLC_MAX_LC, "LC id is too high (%u/%d)!\n", chan_idP, RLC_MAX_LC); + + if (eNB_flagP) { + rlc_mode = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode; + if (rlc_mode != RLC_NONE) { + LOG_E(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB RB IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } + AssertFatal (lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][chan_idP] == RLC_RB_UNALLOCATED, "Bad LC RB %u mapping in RLC layer, channel id %u already configured!\n", rb_idP, chan_idP); + lcid2rbid_eNB[enb_mod_idP][ue_mod_idP][chan_idP] = rb_idP; + switch (rlc_modeP) { case RLC_AM: - index_max = RLC_MAX_NUM_INSTANCES_RLC_AM; + allocation = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am.allocation; + if (!(allocation)) { + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.am.allocation = 1; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_AM; + LOG_I(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB AM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB AM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; case RLC_TM: - index_max = RLC_MAX_NUM_INSTANCES_RLC_TM; + allocation = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm.allocation; + if (!(allocation)) { + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.tm.allocation = 1; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_TM; + LOG_I(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB TM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB TM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; case RLC_UM: - index_max = RLC_MAX_NUM_INSTANCES_RLC_UM; + allocation = rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um.allocation; + if (!(allocation)) { + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].rlc.um.allocation = 1; + rlc_array_eNB[enb_mod_idP][ue_mod_idP][rb_idP].mode = RLC_UM; + LOG_I(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB UM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB UM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; default: - LOG_E(RLC,"Got bad RLC type %d\n",rlc_modeP); + LOG_E(RLC, "[Frame %05u][eNB][RLC_RRC][INST %u/%u][RB %u] %s BAD PARAMETER RLC MODE %d\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + __FUNCTION__, + rlc_modeP); return RLC_OP_STATUS_BAD_PARAMETER; - } - - if ((chan_idP >= RLC_MAX_LC ) || (chan_idP < 1)) { - LOG_E(RLC,"Got wrong channel id %d\n",chan_idP); - exit (-1); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - if (rb_idP >= RLC_MAX_RB ) { - LOG_E(RLC,"Got wrong radio bearer id %d\n",rb_idP); - exit (-1); - return RLC_OP_STATUS_BAD_PARAMETER; - } - - if (rlc[module_idP].m_lcid2rbid[chan_idP] != -1) { - LOG_E(RLC,"Error in RLC config channel ID already configured %d(module_id %d, state %d)\n", - chan_idP, module_idP, rlc[module_idP].m_lcid2rbid[chan_idP]); - exit (-1); - return RLC_OP_STATUS_BAD_PARAMETER; - } - for (index = 0; index < index_max; index++) { + } + } else { + rlc_mode = rlc_array_ue[ue_mod_idP][rb_idP].mode; + if (rlc_mode != RLC_NONE) { + LOG_E(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB RB IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } + AssertFatal (lcid2rbid_ue[ue_mod_idP][chan_idP] == RLC_RB_UNALLOCATED, "Bad LC RB %u mapping in RLC layer, channel id %u already configured!\n", rb_idP, chan_idP); + lcid2rbid_ue[ue_mod_idP][chan_idP] = rb_idP; switch (rlc_modeP) { - case RLC_AM: - - allocation = rlc[module_idP].m_rlc_am_array[index].allocation; - if (!(allocation)) { - rlc[module_idP].m_rlc_am_array[index].allocation = 1; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index = index; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type = rlc_modeP; - rlc[module_idP].m_lcid2rbid[chan_idP] = rb_idP; - LOG_I(RLC, "[RLC_RRC][MOD ID %d][RB %d][LCH Id %d] ADD RB AM INDEX IS %d\n", module_idP, rb_idP, chan_idP, index); - LOG_D(RLC, "[MSC_NEW][FRAME %05d][RLC_AM][MOD %02d][RB %02d]\n", frameP, module_idP,rb_idP); - return RLC_OP_STATUS_OK; - } else { - LOG_D(RLC,"[RLC_RRC][MOD ID %d][RB %d] ADD RB AM INDEX %d IS ALREADY ALLOCATED\n", module_idP, rb_idP, index); - } + case RLC_AM: + allocation = rlc_array_ue[ue_mod_idP][rb_idP].rlc.am.allocation; + if (!(allocation)) { + rlc_array_ue[ue_mod_idP][rb_idP].rlc.am.allocation = 1; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_AM; + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB AM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB AM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; - case RLC_TM: - allocation = rlc[module_idP].m_rlc_tm_array[index].allocation; - if (!(allocation)) { - rlc[module_idP].m_rlc_tm_array[index].allocation = 1; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index = index; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type = rlc_modeP; - rlc[module_idP].m_lcid2rbid[chan_idP] = rb_idP; - LOG_I(RLC, "[RLC_RRC][MOD ID %d][RB %d][LCH Id %d] ADD RB TM INDEX IS %d\n", module_idP, rb_idP, chan_idP, index); - LOG_D(RLC, "[MSC_NEW][FRAME %05d][RLC_TM][MOD %02d][RB %02d]\n", frameP, module_idP, rb_idP); - return RLC_OP_STATUS_OK; - } else { - LOG_D(RLC,"[RLC_RRC][MOD ID %d][RB %d] ADD RB TM INDEX %d IS ALLOCATED\n", module_idP, rb_idP, index); - } + case RLC_TM: + allocation = rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm.allocation; + if (!(allocation)) { + rlc_array_ue[ue_mod_idP][rb_idP].rlc.tm.allocation = 1; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_TM; + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB TM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB TM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; - case RLC_UM: - allocation = rlc[module_idP].m_rlc_um_array[index].allocation; - if (!(allocation)) { - rlc[module_idP].m_rlc_um_array[index].allocation = 1; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index = index; - rlc[module_idP].m_rlc_pointer[rb_idP].rlc_type = rlc_modeP; - rlc[module_idP].m_lcid2rbid[chan_idP] = rb_idP; - LOG_I(RLC, "[RLC_RRC][MOD ID %d][RB %d][LCH Id %d] ADD RB UM INDEX IS %d RLC_MODE %d\n", module_idP, rb_idP, index, chan_idP, rlc_modeP); - LOG_D(RLC, "[MSC_NEW][FRAME %05d][RLC_UM][MOD %02d][RB %02d]\n", frameP, module_idP, rb_idP); - return RLC_OP_STATUS_OK; - } else { - LOG_D(RLC,"[RLC_RRC][MOD ID %d][RB %d] ADD RB UM INDEX %d IS ALREADY ALLOCATED\n", module_idP, rb_idP, index); - } + case RLC_UM: + allocation = rlc_array_ue[ue_mod_idP][rb_idP].rlc.um.allocation; + if (!(allocation)) { + rlc_array_ue[ue_mod_idP][rb_idP].rlc.um.allocation = 1; + rlc_array_ue[ue_mod_idP][rb_idP].mode = RLC_UM; + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB UM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + } else { + LOG_D(RLC,"[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u][LCH Id %d] ADD RB UM IS ALREADY ALLOCATED\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + chan_idP); + return RLC_OP_STATUS_BAD_PARAMETER; + } break; - default: - LOG_E(RLC, "[RLC_RRC][MOD ID %d][RB %d] ADD RB WITH INDEX %d ERROR\n", module_idP, rb_idP, index); - mac_xface->macphy_exit(""); - return RLC_OP_STATUS_BAD_PARAMETER; + default: + LOG_E(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] %s BAD PARAMETER RLC MODE %d\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP, + __FUNCTION__, + rlc_modeP); + return RLC_OP_STATUS_BAD_PARAMETER; } } - LOG_C(RLC, "[RLC_RRC][ADD_RB] Out of Ressources\n"); - mac_xface->macphy_exit(""); - - return RLC_OP_STATUS_OUT_OF_RESSOURCES; + return RLC_OP_STATUS_OK; } //----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_config_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, config_action_t actionP, rb_id_t rb_idP, rb_type_t rb_typeP, rlc_info_t rlc_infoP) { +rlc_op_status_t rrc_rlc_config_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, config_action_t actionP, rb_id_t rb_idP, rb_type_t rb_typeP, rlc_info_t rlc_infoP) { //----------------------------------------------------------------------------- - msg("[RLC][MOD_id %d] CONFIG_REQ for Rab %d\n",module_idP,rb_idP); -#warning TO DO rrc_rlc_config_req rlc_op_status_t status; + LOG_D(RLC, "[FRAME %05u][%s][RLC][MOD %u/%u] CONFIG_REQ for Rab %u\n", + frame, + (eNB_flagP) ? "eNB" : "UE", + enb_mod_idP, + ue_mod_idP, + rb_idP); + +#ifdef OAI_EMU + AssertFatal (enb_mod_idP >= oai_emulation.info.first_enb_local, + "eNB module id is too low (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local); + AssertFatal (enb_mod_idP < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local), + "eNB module id is too high (%u/%d)!\n", + enb_mod_idP, + oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); + AssertFatal (ue_mod_idP >= oai_emulation.info.first_ue_local, + "UE module id is too low (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local); + AssertFatal (ue_mod_idP < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local), + "UE module id is too high (%u/%d)!\n", + ue_mod_idP, + oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); +#endif + AssertFatal (rb_idP < NB_RB_MAX, "RB id is too high (%u/%d)!\n", rb_idP, NB_RB_MAX); +#warning TO DO rrc_rlc_config_req + switch (actionP) { case ACTION_ADD: - if (rb_typeP != SIGNALLING_RADIO_BEARER) { - LOG_D(PDCP, "[MSC_NEW][FRAME %05d][PDCP][MOD %02d][RB %02d]\n", frame, module_idP, rb_idP); - } - if ((status = rrc_rlc_add_rlc(module_idP, frame, rb_idP, rb_idP, rlc_infoP.rlc_mode)) != RLC_OP_STATUS_OK) { + if ((status = rrc_rlc_add_rlc(enb_mod_idP, ue_mod_idP, frame, eNB_flagP, rb_idP, rb_idP, rlc_infoP.rlc_mode)) != RLC_OP_STATUS_OK) { return status; } case ACTION_MODIFY: switch (rlc_infoP.rlc_mode) { case RLC_AM: - LOG_D(RLC, "[RLC_RRC][MOD ID %d][RB %d] MODIFY RB AM\n", module_idP, rb_idP); - config_req_rlc_am(&rlc[module_idP].m_rlc_am_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], - frame, + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB AM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + + config_req_rlc_am( + frame, eNB_flagP, - module_idP, - &rlc_infoP.rlc.rlc_am_info, - rb_idP, rb_typeP); + enb_mod_idP, + ue_mod_idP, + &rlc_infoP.rlc.rlc_am_info, + rb_idP, + rb_typeP); break; case RLC_UM: - LOG_D(RLC, "[RLC_RRC][MOD ID %d][RB %d] MODIFY RB UM\n", module_idP, rb_idP); - config_req_rlc_um(&rlc[module_idP].m_rlc_um_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], - frame, + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB UM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + config_req_rlc_um( + frame, eNB_flagP, - module_idP, - &rlc_infoP.rlc.rlc_um_info, - rb_idP, rb_typeP); + enb_mod_idP, + ue_mod_idP, + &rlc_infoP.rlc.rlc_um_info, + rb_idP, + rb_typeP); break; case RLC_TM: - LOG_D(RLC, "[RLC_RRC][MOD ID %d][RB %d] MODIFY RB TM\n", module_idP, rb_idP); - config_req_rlc_tm(&rlc[module_idP].m_rlc_tm_array[rlc[module_idP].m_rlc_pointer[rb_idP].rlc_index], - frame, + LOG_I(RLC, "[Frame %05u][UE][RLC_RRC][INST %u/%u][RB %u] MODIFY RB TM\n", + frame, + enb_mod_idP, + ue_mod_idP, + rb_idP); + config_req_rlc_tm( + frame, eNB_flagP, - module_idP, - &rlc_infoP.rlc.rlc_tm_info, - rb_idP, rb_typeP); + enb_mod_idP, + ue_mod_idP, + &rlc_infoP.rlc.rlc_tm_info, + rb_idP, + rb_typeP); break; default: return RLC_OP_STATUS_BAD_PARAMETER; @@ -548,7 +901,7 @@ rlc_op_status_t rrc_rlc_config_req (module_id_t module_idP, u32_t frame, u8_t break; case ACTION_REMOVE: - return rrc_rlc_remove_rlc(module_idP, rb_idP,frame); + return rrc_rlc_remove_rlc(enb_mod_idP, ue_mod_idP, rb_idP, frame, eNB_flagP); break; default: return RLC_OP_STATUS_BAD_PARAMETER; @@ -557,16 +910,14 @@ rlc_op_status_t rrc_rlc_config_req (module_id_t module_idP, u32_t frame, u8_t return RLC_OP_STATUS_OK; } //----------------------------------------------------------------------------- -rlc_op_status_t rrc_rlc_data_req (module_id_t module_idP, u32_t frame, u8_t eNB_flagP, u8_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP) { +rlc_op_status_t rrc_rlc_data_req (module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, MBMS_flag_t MBMS_flagP, rb_id_t rb_idP, mui_t muiP, confirm_t confirmP, sdu_size_t sdu_sizeP, char* sduP) { //----------------------------------------------------------------------------- mem_block_t* sdu; - u8_t UE_id = module_idP - NB_eNB_INST; sdu = get_free_mem_block(sdu_sizeP); if (sdu != NULL) { - // msg("[RRC_RLC] MEM_ALLOC %p\n",sdu); memcpy (sdu->data, sduP, sdu_sizeP); - return rlc_data_req(module_idP, frame, eNB_flagP, MBMS_flagP, rb_idP /* + (UE_id * NB_RB_MAX) */, muiP, confirmP, sdu_sizeP, sdu); + return rlc_data_req(enb_mod_idP, ue_mod_idP, frame, eNB_flagP, MBMS_flagP, rb_idP, muiP, confirmP, sdu_sizeP, sdu); } else { return RLC_OP_STATUS_INTERNAL_ERROR; } diff --git a/openair2/NAS/DRIVER/MESH/Makefile b/openair2/NAS/DRIVER/MESH/Makefile index 31d8f1f8217b5763c0f7208932803d6d260c701d..68876a77173b929bef50736834163dcd71e2fe3e 100755 --- a/openair2/NAS/DRIVER/MESH/Makefile +++ b/openair2/NAS/DRIVER/MESH/Makefile @@ -60,7 +60,7 @@ GT301 = $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_301),-DKERNEL_VERSION_GREATER_ # EXTRA COMPILER FLAGS #################################################### EXTRA_CFLAGS = -fno-common $(if $(IS_KERNEL_SUBVERSION_GREATER_THAN_20),-mregparm=3 -fno-stack-protector -mpreferred-stack-boundary=4) $(if $(SET_X64),-DARCH_64,) $(if $(SET_X64),-mcmodel=kernel,) $(if $(SET_X64),-m64,) $(GT2622) $(GT2629) $(V3) $(GT32) $(GT301) - +EXTRA_CFLAGS += -I$(OPENAIR2_DIR) ifdef NAS_NETLINK EXTRA_CFLAGS += -DNAS_NETLINK else diff --git a/openair2/NAS/DRIVER/MESH/common.c b/openair2/NAS/DRIVER/MESH/common.c index eb3e8b2ce1c742b628f4f86ecd7307393692e861..b1c6ce99f1f37340124fda1387fae35a6b0351c9 100755 --- a/openair2/NAS/DRIVER/MESH/common.c +++ b/openair2/NAS/DRIVER/MESH/common.c @@ -361,7 +361,7 @@ void nas_COMMON_del_send(struct sk_buff *skb, struct cx_entity *cx, struct class void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct classifier_entity *gc,int inst){ //--------------------------------------------------------------------------- - struct pdcp_data_req_header_t pdcph; + struct pdcp_data_req_header_s pdcph; struct nas_priv *priv=netdev_priv(nasdev[inst]); #ifdef LOOPBACK_TEST int i; @@ -479,7 +479,7 @@ void nas_COMMON_QOS_send(struct sk_buff *skb, struct cx_entity *cx, struct class void nas_COMMON_QOS_receive(){ //--------------------------------------------------------------------------- u8 sapi; - struct pdcp_data_ind_header_t pdcph; + struct pdcp_data_ind_header_s pdcph; unsigned char data_buffer[2048]; struct classifier_entity *rclass; struct nas_priv *priv; @@ -540,7 +540,7 @@ void nas_COMMON_QOS_receive(){ void nas_COMMON_QOS_receive(struct nlmsghdr *nlh) { - struct pdcp_data_ind_header_t *pdcph = (struct pdcp_data_ind_header_t *)NLMSG_DATA(nlh); + struct pdcp_data_ind_header_s *pdcph = (struct pdcp_data_ind_header_s *)NLMSG_DATA(nlh); struct classifier_entity *rclass; struct nas_priv *priv; diff --git a/openair2/NAS/DRIVER/MESH/constant.h b/openair2/NAS/DRIVER/MESH/constant.h index 368d4e1cf5390309cd4bf6269a9c440d139033d9..46eb5f32e05e9b05e04527c459b6b9c6bb5f44db 100755 --- a/openair2/NAS/DRIVER/MESH/constant.h +++ b/openair2/NAS/DRIVER/MESH/constant.h @@ -92,27 +92,27 @@ // Radio Bearers #define NAS_RB_ESTABLISHING 0x24 #define NAS_RB_RELEASING 0x28 -#define NAS_RB_DCH 0x2A +#define NAS_RB_DCH 0x2A #define NAS_TIMER_ESTABLISHMENT_DEFAULT 12 -#define NAS_TIMER_RELEASE_DEFAULT 2 -#define NAS_TIMER_IDLE UINT_MAX -#define NAS_TIMER_TICK HZ +#define NAS_TIMER_RELEASE_DEFAULT 2 +#define NAS_TIMER_IDLE UINT_MAX +#define NAS_TIMER_TICK HZ -#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_t) -#define NAS_IPV4_SIZE 20 -#define NAS_IPV6_SIZE 40 +#define NAS_PDCPH_SIZE sizeof(struct pdcp_data_req_header_s) +#define NAS_IPV4_SIZE 20 +#define NAS_IPV6_SIZE 40 -#define NAS_DIRECTION_SEND 0 -#define NAS_DIRECTION_RECEIVE 1 -#define NAS_DIRECTION_FORWARD 2 +#define NAS_DIRECTION_SEND 0 +#define NAS_DIRECTION_RECEIVE 1 +#define NAS_DIRECTION_FORWARD 2 // function number -#define NAS_FCT_DEL_SEND 1 -#define NAS_FCT_QOS_SEND 2 -#define NAS_FCT_DC_SEND 3 -#define NAS_FCT_CTL_SEND 4 +#define NAS_FCT_DEL_SEND 1 +#define NAS_FCT_QOS_SEND 2 +#define NAS_FCT_DC_SEND 3 +#define NAS_FCT_CTL_SEND 4 // type of IOCTL command #define NAS_IOCTL_RRM 0x89F0 diff --git a/openair2/NAS/DRIVER/MESH/local.h b/openair2/NAS/DRIVER/MESH/local.h index 7b05591f6d04934adcd0b9836b92505aa83d7fa7..f6ad46c44ac835d4694343eb1cebcd0df7928b2b 100755 --- a/openair2/NAS/DRIVER/MESH/local.h +++ b/openair2/NAS/DRIVER/MESH/local.h @@ -69,6 +69,7 @@ #include "constant.h" #include "sap.h" #include "rrc_nas_primitives.h" +#include "COMMON/platform_types.h" struct rb_entity { @@ -166,18 +167,18 @@ struct ipversion { #endif }; -typedef struct pdcp_data_req_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; - int traffic_type; +typedef struct pdcp_data_req_header_s { + rb_id_t rb_id; + sdu_size_t data_size; + signed int inst; + traffic_type_t traffic_type; } pdcp_data_req_header_t; -typedef struct pdcp_data_ind_header_t { - unsigned int rb_id; - unsigned int data_size; - int inst; - int dummy; +typedef struct pdcp_data_ind_header_s { + rb_id_t rb_id; + sdu_size_t data_size; + signed int inst; + traffic_type_t dummy_traffic_type; } pdcp_data_ind_header_t; extern struct net_device *nasdev[NB_INSTANCES_MAX]; diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c index 8a7e3b4b201dd4108d5330b0279e382c07bd4794..12d1fa4d2c3541957554fd621956e7a768ade168 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.c @@ -87,124 +87,124 @@ #include "openair_rrc_L2_interface.h" /********************************************************************************************************************/ -s8 mac_rrc_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb,u8 *Buffer,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area){ +s8 mac_rrc_data_req(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, u8 nb_tbP,u8 *buffer_pP, eNB_flag_t eNB_flagP, u8 eNB_indexP, u8 mbsfn_sync_areaP){ /********************************************************************************************************************/ #ifdef CELLULAR - return(rrc_L2_data_req_rx(Mod_id,Srb_id,Nb_tb,Buffer,eNB_index)); + return(rrc_L2_data_req_rx(module_idP,srb_idP,nb_tbP,buffer_pP,eNB_indexP)); #else - return(mac_rrc_lite_data_req(Mod_id,frame,Srb_id,Nb_tb,Buffer,eNB_flag,eNB_index,mbsfn_sync_area)); + return(mac_rrc_lite_data_req(module_idP,frameP,srb_idP,nb_tbP,buffer_pP,eNB_flagP,eNB_indexP,mbsfn_sync_areaP)); #endif //CELLULAR } /********************************************************************************************************************/ -s8 mac_rrc_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu,u16 Sdu_len,u8 eNB_flag, u8 eNB_index,u8 mbsfn_sync_area){ +s8 mac_rrc_data_ind(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, u8 *sduP, sdu_size_t sdu_lenP, eNB_flag_t eNB_flagP, u8 eNB_indexP,u8 mbsfn_sync_area){ /********************************************************************************************************************/ #ifdef CELLULAR - return(rrc_L2_mac_data_ind_rx(Mod_id, Srb_id, Sdu, Sdu_len, eNB_index)); + return(rrc_L2_mac_data_ind_rx(module_idP, Srb_id, Sdu, Sdu_len, eNB_indexP)); #else - return(mac_rrc_lite_data_ind(Mod_id,frame,Srb_id,Sdu,Sdu_len,eNB_flag,eNB_index,mbsfn_sync_area)); + return(mac_rrc_lite_data_ind(module_idP,frameP,srb_idP,sduP,sdu_lenP,eNB_flagP,eNB_indexP,mbsfn_sync_area)); #endif //CELLULAR } /********************************************************************************************************************/ -void rlcrrc_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag, unsigned int Srb_id, unsigned int Sdu_size,u8 *Buffer){ +void rlcrrc_data_ind(module_id_t enb_instP, module_id_t ue_instP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t srb_idP, sdu_size_t sdu_lenP,u8 *buffer_pP){ /********************************************************************************************************************/ #ifdef CELLULAR - rrc_L2_rlc_data_ind_rx(Mod_id,Srb_id, Sdu_size, Buffer); + rrc_L2_rlc_data_ind_rx(module_idP,Srb_id, sdu_lenP, buffer_pP); #else // now this is called from PDCP - //rlcrrc_lite_data_ind(Mod_id,frame,eNB_flag,Srb_id,Sdu_size,Buffer); - rrc_lite_data_ind(eNB_id, UE_id,frame,eNB_flag,Srb_id,Sdu_size,Buffer); + //rlcrrc_lite_data_ind(module_idP,frameP,eNB_flag,Srb_id,Sdu_size,Buffer); + rrc_lite_data_ind(enb_instP, ue_instP,frameP,eNB_flagP,srb_idP,sdu_lenP,buffer_pP); #endif //CELLULAR } /********************************************************************************************************************/ -u8 pdcp_rrc_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int rb_id, u32 muiP, u32 confirmP, - unsigned int sdu_buffer_size, u8* sdu_buffer, u8 mode) { +u8 pdcp_rrc_data_req(module_id_t enb_instP, module_id_t ue_instP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, boolean_t confirmP, + sdu_size_t sdu_buffer_sizeP, u8* sdu_buffer_pP, u8 modeP) { /********************************************************************************************************************/ #ifdef CELLULAR - return pdcp_data_req( module_id, frame, eNB_flag, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer, mode); + return pdcp_data_req( module_id, frameP, eNB_flag, rb_id, muiP, confirmP, sdu_buffer_sizeP, sdu_buffer_pP, modeP); #else - return rrc_lite_data_req (eNB_id, UE_id, frame, eNB_flag, rb_id, muiP, confirmP, sdu_buffer_size, sdu_buffer, mode); + return rrc_lite_data_req (enb_instP, ue_instP, frameP, eNB_flagP, rb_idP, muiP, confirmP, sdu_buffer_sizeP, sdu_buffer_pP, modeP); #endif } /********************************************************************************************************************/ -void pdcp_rrc_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag, unsigned int Srb_id, unsigned int Sdu_size,u8 *Buffer){ +void pdcp_rrc_data_ind(module_id_t enb_instP, module_id_t ue_instP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t srb_idP, sdu_size_t sdu_sizeP,u8 *buffer_pP){ /********************************************************************************************************************/ #ifdef CELLULAR - rrc_L2_rlc_data_ind_rx(Mod_id,Srb_id, Sdu_size, Buffer); + rrc_L2_rlc_data_ind_rx(module_idP,srb_idP, sdu_sizeP, buffer_pP); #else // now this is called from PDCP - //rlcrrc_lite_data_ind(Mod_id,frame,eNB_flag,Srb_id,Sdu_size,Buffer); - rrc_lite_data_ind(eNB_id, UE_id,frame,eNB_flag,Srb_id,Sdu_size,Buffer); + //rlcrrc_lite_data_ind(module_idP,frameP,eNB_flag,Srb_id,Sdu_size,Buffer); + rrc_lite_data_ind(enb_instP, ue_instP,frameP,eNB_flagP,srb_idP,sdu_sizeP,buffer_pP); #endif //CELLULAR } /********************************************************************************************************************/ -void mac_rrc_meas_ind(u8 Mod_id,MAC_MEAS_REQ_ENTRY *Meas_entry){ +void mac_rrc_meas_ind(module_id_t module_idP,MAC_MEAS_REQ_ENTRY *Meas_entry_pP){ /********************************************************************************************************************/ #ifdef CELLULAR rrc_L2_mac_meas_ind_rx (); #else - // mac_rrc_meas_ind(Mod_id,Meas_entry); + // mac_rrc_meas_ind(module_idP,Meas_entry_pP); #endif //CELLULAR } /********************************************************************************************************************/ -void mac_sync_ind(u8 Mod_id,u8 Status){ +void mac_sync_ind(module_id_t module_idP,u8 Status){ /********************************************************************************************************************/ #ifdef CELLULAR - rrc_L2_sync_ind_rx(Mod_id); + rrc_L2_sync_ind_rx(module_idP); #else - mac_lite_sync_ind(Mod_id,Status); + mac_lite_sync_ind(module_idP,Status); #endif //CELLULAR } /********************************************************************************************************************/ -void mac_in_sync_ind(u8 Mod_id,u32 frame, u16 eNB_index){ +void mac_in_sync_ind(module_id_t module_idP,frame_t frameP, u16 eNB_indexP){ /********************************************************************************************************************/ #ifdef CELLULAR - rrc_L2_sync_ind_rx(Mod_id); + rrc_L2_sync_ind_rx(module_idP); #else - rrc_lite_in_sync_ind(Mod_id,frame,eNB_index); + rrc_lite_in_sync_ind(module_idP,frameP,eNB_indexP); #endif } /********************************************************************************************************************/ -void mac_out_of_sync_ind(u8 Mod_id,u32 frame, u16 eNB_index){ +void mac_out_of_sync_ind(module_id_t module_idP,frame_t frameP, u16 eNB_indexP){ /********************************************************************************************************************/ #ifdef CELLULAR rrc_L2_out_sync_ind_rx(); #else - rrc_lite_out_of_sync_ind(Mod_id,frame,eNB_index); + rrc_lite_out_of_sync_ind(module_idP,frameP,eNB_indexP); #endif //CELLULAR } /********************************************************************************************************************/ -int mac_get_rrc_status(u8 Mod_id,u8 eNB_flag,u8 index) { +int mac_get_rrc_status(module_id_t module_idP,eNB_flag_t eNB_flagP,u8 indexP) { /********************************************************************************************************************/ #ifdef CELLULAR - return (rrc_L2_get_rrc_status(Mod_id,eNB_flag,index)); + return (rrc_L2_get_rrc_status(module_idP,eNB_flagP,indexP)); #else - return mac_get_rrc_lite_status(Mod_id, eNB_flag, index); + return mac_get_rrc_lite_status(module_idP, eNB_flagP, indexP); #endif //CELLULAR } /********************************************************************************************************************/ -char openair_rrc_ue_init(u8 Mod_id, unsigned char eNB_index){ +char openair_rrc_ue_init(module_id_t module_idP, unsigned char eNB_indexP){ /********************************************************************************************************************/ #ifdef CELLULAR - return (rrc_L2_ue_init(Mod_id,eNB_index)); + return (rrc_L2_ue_init(module_idP,eNB_indexP)); #else - return openair_rrc_lite_ue_init(Mod_id, eNB_index); + return openair_rrc_lite_ue_init(module_idP, eNB_indexP); #endif //CELLULAR } /********************************************************************************************************************/ -char openair_rrc_eNB_init(u8 Mod_id){ +char openair_rrc_eNB_init(module_id_t module_idP){ /********************************************************************************************************************/ #ifdef CELLULAR - return( rrc_L2_eNB_init(Mod_id)); + return( rrc_L2_eNB_init(module_idP)); #else - return openair_rrc_lite_eNB_init(Mod_id); + return openair_rrc_lite_eNB_init(module_idP); #endif //CELLULAR } diff --git a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h index 17330fa69a4175b560f6e59101b162d3d4dca444..9280787a57636f7720539118a5ee84949c9fa624 100644 --- a/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h +++ b/openair2/RRC/L2_INTERFACE/openair_rrc_L2_interface.h @@ -39,32 +39,33 @@ #define __OPENAIR_RRC_L2_INTERFACE_H__ #include "COMMON/mac_rrc_primitives.h" +#include "COMMON/platform_types.h" -s8 mac_rrc_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, u8 eNB_flag, u8 eNB_index, - u8 mbsfn_sync_area); +s8 mac_rrc_data_req(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, u8 nb_tbP, u8 *buffer_pP, eNB_flag_t eNB_flagP, u8 eNB_indexP, + u8 mbsfn_sync_areaP); -s8 mac_rrc_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 Sdu_len, u8 eNB_flag, u8 eNB_index, - u8 mbsfn_sync_area); +s8 mac_rrc_data_ind(module_id_t module_idP, frame_t frameP, rb_id_t srb_idP, u8 *sduP, sdu_size_t sdu_lenP, eNB_flag_t eNB_flagP, u8 eNB_index, + u8 mbsfn_sync_areaP); -void mac_lite_sync_ind(u8 Mod_id, u8 status); +void mac_lite_sync_ind(module_id_t module_idP, u8 statusP); -void mac_rrc_meas_ind(u8, MAC_MEAS_REQ_ENTRY*); +void mac_rrc_meas_ind(module_id_t, MAC_MEAS_REQ_ENTRY*); -void rlcrrc_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag, unsigned int Rb_id, u32 sdu_size, u8 *Buffer); +void rlcrrc_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, sdu_size_t sdu_sizeP, u8 *buffer_pP); -u8 pdcp_rrc_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int rb_id, u32 muiP, u32 confirmP, - unsigned int sdu_buffer_size, u8* sdu_buffer, u8 mode); +u8 pdcp_rrc_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, boolean_t confirmP, + sdu_size_t sdu_buffer_size, u8* sdu_buffer, u8 mode); -void pdcp_rrc_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag, unsigned int Srb_id, unsigned int Sdu_size, u8 *Buffer); +void pdcp_rrc_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t srb_idP, sdu_size_t sdu_sizeP, u8 *buffer_pP); -void mac_out_of_sync_ind(u8 Mod_id, u32 frame, u16 CH_index); +void mac_out_of_sync_ind(module_id_t module_idP, frame_t frameP, u16 CH_index); -char openair_rrc_eNB_init(u8 Mod_id); +char openair_rrc_eNB_init(module_id_t module_idP); -char openair_rrc_ue_init(u8 Mod_id, unsigned char eNB_index); +char openair_rrc_ue_init(module_id_t module_idP, unsigned char eNB_indexP); -int mac_get_rrc_status(u8 Mod_id, u8 eNB_flag, u8 index); +int mac_get_rrc_status(module_id_t module_idP, eNB_flag_t eNB_flagP, u8 indexP); -void mac_in_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index); +void mac_in_sync_ind(module_id_t module_idP, frame_t frameP, u16 eNB_indexP); #endif diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c index a18acbe04f381e75a794523b8f7f2e887b16594a..0052b292b89fc7b7a04a24eb80384678eff8d6a1 100644 --- a/openair2/RRC/LITE/L2_interface.c +++ b/openair2/RRC/LITE/L2_interface.c @@ -60,10 +60,10 @@ extern UE_MAC_INST *UE_mac_inst; //#define RRC_DATA_REQ_DEBUG #define DEBUG_RRC -u32 mui=0; +mui_t mui=0; //-------------------------------------------------------------------------------------------// -s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, u8 eNB_flag, u8 eNB_index, +s8 mac_rrc_lite_data_req(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 Nb_tb, u8 *buffer_pP, eNB_flag_t eNB_flagP, u8 eNB_index, u8 mbsfn_sync_area) { //-------------------------------------------------------------------------------------------// SRB_INFO *Srb_info; @@ -71,21 +71,21 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, #ifdef DEBUG_RRC int i; - LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_id,Srb_id); + LOG_D(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id); #endif - if( eNB_flag == 1){ + if( eNB_flagP == 1){ if((Srb_id & RAB_OFFSET) == BCCH){ - if(eNB_rrc_inst[Mod_id].SI.Active==0) return 0; + if(eNB_rrc_inst[Mod_idP].SI.Active==0) return 0; // All even frames transmit SIB in SF 5 - if (eNB_rrc_inst[Mod_id].sizeof_SIB1 == 255) { - LOG_E(RRC,"[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_id); + if (eNB_rrc_inst[Mod_idP].sizeof_SIB1 == 255) { + LOG_E(RRC,"[eNB %d] MAC Request for SIB1 and SIB1 not initialized\n",Mod_idP); mac_xface->macphy_exit(""); } - if ((frame%2) == 0) { - memcpy(&Buffer[0],eNB_rrc_inst[Mod_id].SIB1,eNB_rrc_inst[Mod_id].sizeof_SIB1); + if ((frameP%2) == 0) { + memcpy(&buffer_pP[0],eNB_rrc_inst[Mod_idP].SIB1,eNB_rrc_inst[Mod_idP].sizeof_SIB1); #if defined(ENABLE_ITTI) { @@ -100,7 +100,7 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ); - RRC_MAC_BCCH_DATA_REQ (message_p).frame = frame; + RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP; RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib1_size; memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu)); memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_id].SIB1, sib1_size); @@ -111,21 +111,21 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, #endif #ifdef DEBUG_RRC - LOG_D(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_id,frame); - for (i=0;i<eNB_rrc_inst[Mod_id].sizeof_SIB1;i++) - LOG_T(RRC,"%x.",Buffer[i]); + LOG_D(RRC,"[eNB %d] Frame %d : BCCH request => SIB 1\n",Mod_idP,frameP); + for (i=0;i<eNB_rrc_inst[Mod_idP].sizeof_SIB1;i++) + LOG_T(RRC,"%x.",buffer_pP[i]); LOG_T(RRC,"\n"); #endif - return (eNB_rrc_inst[Mod_id].sizeof_SIB1); + return (eNB_rrc_inst[Mod_idP].sizeof_SIB1); } // All RFN mod 8 transmit SIB2-3 in SF 5 - else if ((frame%8) == 1){ - memcpy(&Buffer[0],eNB_rrc_inst[Mod_id].SIB23,eNB_rrc_inst[Mod_id].sizeof_SIB23); + else if ((frameP%8) == 1){ + memcpy(&buffer_pP[0],eNB_rrc_inst[Mod_idP].SIB23,eNB_rrc_inst[Mod_idP].sizeof_SIB23); #if defined(ENABLE_ITTI) { MessageDef *message_p; - int sib23_size = eNB_rrc_inst[Mod_id].sizeof_SIB23; + int sib23_size = eNB_rrc_inst[Mod_idP].sizeof_SIB23; int sdu_size = sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu); if (sib23_size > sdu_size) @@ -135,23 +135,23 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_BCCH_DATA_REQ); - RRC_MAC_BCCH_DATA_REQ (message_p).frame = frame; + RRC_MAC_BCCH_DATA_REQ (message_p).frame = frameP; RRC_MAC_BCCH_DATA_REQ (message_p).sdu_size = sib23_size; memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu)); - memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_id].SIB23, sib23_size); + memcpy (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_idP].SIB23, sib23_size); RRC_MAC_BCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_id, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); } #endif #ifdef DEBUG_RRC - LOG_D(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_id,frame); - for (i=0;i<eNB_rrc_inst[Mod_id].sizeof_SIB23;i++) - LOG_T(RRC,"%x.",Buffer[i]); + LOG_D(RRC,"[eNB %d] Frame %d BCCH request => SIB 2-3\n",Mod_idP,frameP); + for (i=0;i<eNB_rrc_inst[Mod_idP].sizeof_SIB23;i++) + LOG_T(RRC,"%x.",buffer_pP[i]); LOG_T(RRC,"\n"); #endif - return(eNB_rrc_inst[Mod_id].sizeof_SIB23); + return(eNB_rrc_inst[Mod_idP].sizeof_SIB23); } else return(0); @@ -159,17 +159,17 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, if( (Srb_id & RAB_OFFSET ) == CCCH){ - LOG_D(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_id,frame, Srb_id); + LOG_D(RRC,"[eNB %d] Frame %d CCCH request (Srb_id %d)\n",Mod_idP,frameP, Srb_id); - if(eNB_rrc_inst[Mod_id].Srb0.Active==0) { - LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_id); + if(eNB_rrc_inst[Mod_idP].Srb0.Active==0) { + LOG_E(RRC,"[eNB %d] CCCH Not active\n",Mod_idP); return -1; } - Srb_info=&eNB_rrc_inst[Mod_id].Srb0; + Srb_info=&eNB_rrc_inst[Mod_idP].Srb0; // check if data is there for MAC if(Srb_info->Tx_buffer.payload_size>0){//Fill buffer - LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_id,Srb_info,Srb_info->Tx_buffer.payload_size,Buffer,Srb_info->Tx_buffer.Payload); + LOG_D(RRC,"[eNB %d] CCCH (%p) has %d bytes (dest: %p, src %p)\n",Mod_idP,Srb_info,Srb_info->Tx_buffer.payload_size,buffer_pP,Srb_info->Tx_buffer.Payload); #if defined(ENABLE_ITTI) { @@ -183,17 +183,17 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_CCCH_DATA_REQ); - RRC_MAC_CCCH_DATA_REQ (message_p).frame = frame; + RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP; RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size; memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu)); memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, Srb_info->Tx_buffer.Payload, ccch_size); RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_id, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); } #endif - memcpy(Buffer,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); + memcpy(buffer_pP,Srb_info->Tx_buffer.Payload,Srb_info->Tx_buffer.payload_size); Sdu_size = Srb_info->Tx_buffer.payload_size; Srb_info->Tx_buffer.payload_size=0; } @@ -214,7 +214,7 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, #if defined(ENABLE_ITTI) { MessageDef *message_p; - int mcch_size = eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; + int mcch_size = eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]; int sdu_size = sizeof(RRC_MAC_MCCH_DATA_REQ (message_p).sdu); if (mcch_size > sdu_size) { @@ -223,29 +223,29 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } message_p = itti_alloc_new_message (TASK_RRC_ENB, RRC_MAC_MCCH_DATA_REQ); - RRC_MAC_MCCH_DATA_REQ (message_p).frame = frame; + RRC_MAC_MCCH_DATA_REQ (message_p).frame = frameP; RRC_MAC_MCCH_DATA_REQ (message_p).sdu_size = mcch_size; memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu)); - memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_id].MCCH_MESSAGE[mbsfn_sync_area], mcch_size); + memcpy (RRC_MAC_MCCH_DATA_REQ (message_p).sdu, eNB_rrc_inst[Mod_idP].MCCH_MESSAGE[mbsfn_sync_area], mcch_size); RRC_MAC_MCCH_DATA_REQ (message_p).enb_index = eNB_index; RRC_MAC_MCCH_DATA_REQ (message_p).mbsfn_sync_area = mbsfn_sync_area; - itti_send_msg_to_task (TASK_MAC_ENB, Mod_id, message_p); + itti_send_msg_to_task (TASK_MAC_ENB, Mod_idP, message_p); } #endif - memcpy(&Buffer[0], - eNB_rrc_inst[Mod_id].MCCH_MESSAGE[mbsfn_sync_area], - eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + memcpy(&buffer_pP[0], + eNB_rrc_inst[Mod_idP].MCCH_MESSAGE[mbsfn_sync_area], + eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); #ifdef DEBUG_RRC - LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_id,frame); - for (i=0;i<eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area];i++) - LOG_T(RRC,"%x.",Buffer[i]); + LOG_D(RRC,"[eNB %d] Frame %d : MCCH request => MCCH_MESSAGE \n",Mod_id,frameP); + for (i=0;i<eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area];i++) + LOG_T(RRC,"%x.",buffer_pP[i]); LOG_T(RRC,"\n"); #endif - return (eNB_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); + return (eNB_rrc_inst[Mod_idP].sizeof_MCCH_MESSAGE[mbsfn_sync_area]); // } //else //return(0); @@ -255,10 +255,10 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, else{ //This is an UE #ifdef DEBUG_RRC - LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_id,frame,Srb_id); - LOG_D(RRC,"[UE %d] Frame %d Buffer status %d,\n",Mod_id,frame, UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size); + LOG_D(RRC,"[UE %d] Frame %d Filling CCCH SRB_ID %d\n",Mod_idP,frameP,Srb_id); + LOG_D(RRC,"[UE %d] Frame %d buffer_pP status %d,\n",Mod_idP,frameP, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); #endif - if( (UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size > 0) ) { + if( (UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size > 0) ) { #if defined(ENABLE_ITTI) { @@ -272,21 +272,21 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } message_p = itti_alloc_new_message (TASK_RRC_UE, RRC_MAC_CCCH_DATA_REQ); - RRC_MAC_CCCH_DATA_REQ (message_p).frame = frame; + RRC_MAC_CCCH_DATA_REQ (message_p).frame = frameP; RRC_MAC_CCCH_DATA_REQ (message_p).sdu_size = ccch_size; memset (RRC_MAC_BCCH_DATA_REQ (message_p).sdu, 0, sizeof(RRC_MAC_BCCH_DATA_REQ (message_p).sdu)); - memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload, ccch_size); + memcpy (RRC_MAC_CCCH_DATA_REQ (message_p).sdu, UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload, ccch_size); RRC_MAC_CCCH_DATA_REQ (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_MAC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_MAC_UE, Mod_idP + NB_eNB_INST, message_p); } #endif - memcpy(&Buffer[0],&UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size); - u8 Ret_size=UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size; + memcpy(&buffer_pP[0],&UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.Payload[0],UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size); + u8 Ret_size=UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size; // UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0; - UE_rrc_inst[Mod_id].Info[eNB_index].T300_active = 1; - UE_rrc_inst[Mod_id].Info[eNB_index].T300_cnt = 0; + UE_rrc_inst[Mod_idP].Info[eNB_index].T300_active = 1; + UE_rrc_inst[Mod_idP].Info[eNB_index].T300_cnt = 0; // msg("[RRC][UE %d] Sending rach\n",Mod_id); return(Ret_size); } @@ -298,18 +298,18 @@ s8 mac_rrc_lite_data_req(u8 Mod_id, u32 frame, u16 Srb_id, u8 Nb_tb, u8 *Buffer, } //-------------------------------------------------------------------------------------------// -s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size,u8 eNB_flag,u8 eNB_index,u8 mbsfn_sync_area){ +s8 mac_rrc_lite_data_ind(module_id_t Mod_idP, frame_t frameP, u16 Srb_id, u8 *Sdu, u16 sdu_size,eNB_flag_t eNB_flagP,u8 eNB_index,u8 mbsfn_sync_area){ //-------------------------------------------------------------------------------------------// SRB_INFO *Srb_info; /* int si_window; */ - if(eNB_flag == 0){ + if(eNB_flagP == 0){ if(Srb_id == BCCH){ - LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",Mod_id,Srb_id,eNB_index); + LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",Mod_idP,Srb_id,eNB_index); #if defined(ENABLE_ITTI) { @@ -323,7 +323,7 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size } message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_BCCH_DATA_IND); - RRC_MAC_BCCH_DATA_IND (message_p).frame = frame; + RRC_MAC_BCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_BCCH_DATA_IND (message_p).sdu_size = sdu_size; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); memcpy (RRC_MAC_BCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); @@ -331,14 +331,14 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size RRC_MAC_BCCH_DATA_IND (message_p).rsrq = 30 /* TODO change phy to report rspq */; RRC_MAC_BCCH_DATA_IND (message_p).rsrp = 45 /* TODO change phy to report rspp */; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else - decode_BCCH_DLSCH_Message(Mod_id,frame,eNB_index,Sdu,sdu_size, 0, 0); + decode_BCCH_DLSCH_Message(Mod_idP,frameP,eNB_index,Sdu,sdu_size, 0, 0); /* - if ((frame %2) == 0) { + if ((frameP %2) == 0) { if (UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 0) { - LOG_D(RRC,"[UE %d] Frame %d : Received SIB1 from eNB %d (%d bytes)\n",Mod_id,frame,eNB_index,sdu_size); + LOG_D(RRC,"[UE %d] Frame %d : Received SIB1 from eNB %d (%d bytes)\n",Mod_id,frameP,eNB_index,sdu_size); if (UE_rrc_inst[Mod_id].SIB1[eNB_index]) memcpy(UE_rrc_inst[Mod_id].SIB1[eNB_index],&Sdu[0],sdu_size); else { @@ -353,11 +353,11 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size else { if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 0)) { - si_window = (frame%UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod)/frame%UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize; - LOG_D(RRC,"[UE %d] Frame %d : Received SI (%d bytes), in window %d (SIperiod %d, SIwindowsize %d)\n",Mod_id,frame,sdu_size,si_window,UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod,UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize); + si_window = (frameP%UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod)/frameP%UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize; + LOG_D(RRC,"[UE %d] Frame %d : Received SI (%d bytes), in window %d (SIperiod %d, SIwindowsize %d)\n",Mod_id,frameP,sdu_size,si_window,UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod,UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize); memcpy(UE_rrc_inst[Mod_id].SI[eNB_index],&Sdu[0],sdu_size); - if (decode_SI(Mod_id,frame,eNB_index,si_window)==0) { - LOG_D(RRC,"[UE %d] Frame %d :Decoded SI successfully\n",Mod_id,frame); + if (decode_SI(Mod_id,frameP,eNB_index,si_window)==0) { + LOG_D(RRC,"[UE %d] Frame %d :Decoded SI successfully\n",Mod_id,frameP); UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; } } @@ -380,7 +380,7 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size if((Srb_id & RAB_OFFSET) == CCCH){ if (sdu_size>0) { - LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_id,Srb_id & RAB_OFFSET,eNB_index); + LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_idP,Srb_id & RAB_OFFSET,eNB_index); #if defined(ENABLE_ITTI) { @@ -394,20 +394,20 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size } message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_IND); - RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; + RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); RRC_MAC_CCCH_DATA_IND (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else - Srb_info = &UE_rrc_inst[Mod_id].Srb0[eNB_index]; + Srb_info = &UE_rrc_inst[Mod_idP].Srb0[eNB_index]; memcpy(Srb_info->Rx_buffer.Payload,Sdu,sdu_size); Srb_info->Rx_buffer.payload_size = sdu_size; - rrc_ue_decode_ccch(Mod_id, frame, Srb_info, eNB_index); + rrc_ue_decode_ccch(Mod_idP, frameP, Srb_info, eNB_index); #endif } } @@ -415,7 +415,7 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size #ifdef Rel10 if ((Srb_id & RAB_OFFSET) == MCCH) { LOG_T(RRC,"[UE %d] Frame %d: Received SDU on MBSFN sync area %d for MCCH on SRB %d from eNB %d\n", - Mod_id,frame, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index); + Mod_id,frameP, mbsfn_sync_area, Srb_id & RAB_OFFSET,eNB_index); #if defined(ENABLE_ITTI) { @@ -429,17 +429,17 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size } message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_MCCH_DATA_IND); - RRC_MAC_MCCH_DATA_IND (message_p).frame = frame; + RRC_MAC_MCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_MCCH_DATA_IND (message_p).sdu_size = sdu_size; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); memcpy (RRC_MAC_MCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); RRC_MAC_MCCH_DATA_IND (message_p).enb_index = eNB_index; RRC_MAC_MCCH_DATA_IND (message_p).mbsfn_sync_area = mbsfn_sync_area; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else - decode_MCCH_Message(Mod_id, frame, eNB_index, Sdu, sdu_size, mbsfn_sync_area); + decode_MCCH_Message(Mod_id, frameP, eNB_index, Sdu, sdu_size, mbsfn_sync_area); #endif } #endif // Rel10 @@ -447,8 +447,8 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size } else{ // This is an eNB - Srb_info = &eNB_rrc_inst[Mod_id].Srb0; - LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",Mod_id,Srb_info->Srb_id); + Srb_info = &eNB_rrc_inst[Mod_idP].Srb0; + LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",Mod_idP,Srb_info->Srb_id); #if defined(ENABLE_ITTI) { @@ -462,19 +462,19 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size } message_p = itti_alloc_new_message (TASK_MAC_ENB, RRC_MAC_CCCH_DATA_IND); - RRC_MAC_CCCH_DATA_IND (message_p).frame = frame; + RRC_MAC_CCCH_DATA_IND (message_p).frame = frameP; RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = sdu_size; memset (RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, sizeof(RRC_MAC_CCCH_DATA_IND (message_p).sdu)); memcpy (RRC_MAC_CCCH_DATA_IND (message_p).sdu, Sdu, sdu_size); - itti_send_msg_to_task (TASK_RRC_ENB, Mod_id, message_p); + itti_send_msg_to_task (TASK_RRC_ENB, Mod_idP, message_p); } #else // msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id); if (sdu_size > 0) { memcpy(Srb_info->Rx_buffer.Payload,Sdu,sdu_size); Srb_info->Rx_buffer.payload_size = sdu_size; - rrc_eNB_decode_ccch(Mod_id,frame,Srb_info); + rrc_eNB_decode_ccch(Mod_idP,frameP,Srb_info); } #endif } @@ -485,13 +485,13 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, u8 *Sdu, u16 sdu_size //-------------------------------------------------------------------------------------------// // this function is Not USED anymore -void mac_lite_sync_ind(u8 Mod_id,u8 Status){ +void mac_lite_sync_ind(module_id_t Mod_idP,u8 Status){ //-------------------------------------------------------------------------------------------// } //-------------------------------------------------------------------------------------------// -u8 rrc_lite_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int rb_id, u32 muiP, u32 confirmP, - unsigned int sdu_size, u8* Buffer, u8 mode) { +u8 rrc_lite_data_req(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t rb_idP, mui_t muiP, u32 confirmP, + sdu_size_t sdu_size, u8* buffer_pP, u8 mode) { //-------------------------------------------------------------------------------------------// #if defined(ENABLE_ITTI) { @@ -500,10 +500,10 @@ u8 rrc_lite_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int r u8 *message_buffer; message_buffer = itti_malloc (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, sdu_size); - memcpy (message_buffer, Buffer, sdu_size); + memcpy (message_buffer, buffer_pP, sdu_size); message_p = itti_alloc_new_message (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, RRC_DCCH_DATA_REQ); - RRC_DCCH_DATA_REQ (message_p).frame = frame; + RRC_DCCH_DATA_REQ (message_p).frame = frameP; RRC_DCCH_DATA_REQ (message_p).enb_flag = eNB_flag; RRC_DCCH_DATA_REQ (message_p).rb_id = rb_id; RRC_DCCH_DATA_REQ (message_p).muip = muiP; @@ -511,32 +511,32 @@ u8 rrc_lite_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int r RRC_DCCH_DATA_REQ (message_p).sdu_size = sdu_size; RRC_DCCH_DATA_REQ (message_p).sdu_p = message_buffer; RRC_DCCH_DATA_REQ (message_p).mode = mode; - RRC_DCCH_DATA_REQ (message_p).eNB_index = eNB_id; - RRC_DCCH_DATA_REQ (message_p).ue_index = UE_id; + RRC_DCCH_DATA_REQ (message_p).eNB_index = enb_mod_idP; + RRC_DCCH_DATA_REQ (message_p).ue_index = ue_mod_idP; - itti_send_msg_to_task (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, eNB_flag ? eNB_id : NB_eNB_INST + UE_id, message_p); + itti_send_msg_to_task (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, eNB_flag ? enb_mod_idP : NB_eNB_INST + ue_mod_idP, message_p); return TRUE; // TODO should be changed to a CNF message later, currently RRC lite does not used the returned value anyway. } #else - return pdcp_data_req (eNB_id, UE_id, frame, eNB_flag, rb_id, muiP, confirmP, sdu_size, Buffer, mode); + return pdcp_data_req (enb_mod_idP, ue_mod_idP, frameP, eNB_flagP, rb_idP, muiP, confirmP, sdu_size, buffer_pP, mode); #endif } //-------------------------------------------------------------------------------------------// -void rrc_lite_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag,u32 Srb_id, u32 sdu_size,u8 *Buffer){ +void rrc_lite_data_ind(module_id_t enb_mod_idP, module_id_t ue_mod_idP, frame_t frameP, eNB_flag_t eNB_flagP,rb_id_t Srb_id, sdu_size_t sdu_sizeP,u8 *buffer_pP){ //-------------------------------------------------------------------------------------------// u8 DCCH_index = Srb_id; u8_t Mod_id; - if (eNB_flag == 0) { - Mod_id = UE_id + NB_eNB_INST; + if (eNB_flagP == 0) { + Mod_id = ue_mod_idP + NB_eNB_INST; LOG_N(RRC, "[UE %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from eNB %d\n", - UE_id, frame, DCCH_index,Srb_id-1,sdu_size, eNB_id); + ue_mod_idP, frameP, DCCH_index,Srb_id-1,sdu_sizeP, enb_mod_idP); } else { - Mod_id = eNB_id; + Mod_id = enb_mod_idP; LOG_N(RRC, "[eNB %d] Frame %d: received a DCCH %d message on SRB %d with Size %d from UE %d\n", - eNB_id, frame, DCCH_index,Srb_id-1,sdu_size, UE_id); + enb_mod_idP, frameP, DCCH_index,Srb_id-1,sdu_sizeP, ue_mod_idP); } #if defined(ENABLE_ITTI) @@ -546,86 +546,86 @@ void rrc_lite_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag,u32 Srb_i u8 *message_buffer; message_buffer = itti_malloc (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, sdu_size); - memcpy (message_buffer, Buffer, sdu_size); + memcpy (message_buffer, buffer_pP, sdu_sizeP); - message_p = itti_alloc_new_message (eNB_flag ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); - RRC_DCCH_DATA_IND (message_p).frame = frame; + message_p = itti_alloc_new_message (eNB_flagP ? TASK_PDCP_ENB : TASK_PDCP_UE, RRC_DCCH_DATA_IND); + RRC_DCCH_DATA_IND (message_p).frame = frameP; RRC_DCCH_DATA_IND (message_p).dcch_index = DCCH_index; - RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_size; - RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; - RRC_DCCH_DATA_IND (message_p).ue_index = UE_id; - RRC_DCCH_DATA_IND (message_p).eNB_index = eNB_id; + RRC_DCCH_DATA_IND (message_p).sdu_size = sdu_sizeP; + RRC_DCCH_DATA_IND (message_p).sdu_p = message_buffer; + RRC_DCCH_DATA_IND (message_p).ue_index = ue_mod_idP; + RRC_DCCH_DATA_IND (message_p).eNB_index = enb_mod_idP; itti_send_msg_to_task (eNB_flag ? TASK_RRC_ENB : TASK_RRC_UE, Mod_id, message_p); } #else - if (eNB_flag ==1) { - rrc_eNB_decode_dcch(eNB_id,frame,DCCH_index,UE_id,Buffer,sdu_size); + if (eNB_flagP ==1) { + rrc_eNB_decode_dcch(enb_mod_idP,frameP,DCCH_index,ue_mod_idP,buffer_pP,sdu_sizeP); } else { - rrc_ue_decode_dcch(UE_id,frame,DCCH_index,Buffer,eNB_id); + rrc_ue_decode_dcch(ue_mod_idP,frameP,DCCH_index,buffer_pP,enb_mod_idP); } #endif } //-------------------------------------------------------------------------------------------// -void rrc_lite_in_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index) { +void rrc_lite_in_sync_ind(module_id_t Mod_idP, frame_t frameP, u16 eNB_index) { //-------------------------------------------------------------------------------------------// #if defined(ENABLE_ITTI) { MessageDef *message_p; message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_IN_SYNC_IND); - RRC_MAC_IN_SYNC_IND (message_p).frame = frame; + RRC_MAC_IN_SYNC_IND (message_p).frame = frameP; RRC_MAC_IN_SYNC_IND (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else - UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt=0; - if (UE_rrc_inst[Mod_id].Info[eNB_index].T310_active==1) - UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt++; + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt=0; + if (UE_rrc_inst[Mod_idP].Info[eNB_index].T310_active==1) + UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt++; #endif } //-------------------------------------------------------------------------------------------// -void rrc_lite_out_of_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index){ +void rrc_lite_out_of_sync_ind(module_id_t Mod_idP, frame_t frameP, u16 eNB_index){ //-------------------------------------------------------------------------------------------// // rlc_info_t rlc_infoP; // rlc_infoP.rlc_mode=RLC_UM; LOG_I(RRC,"[UE %d] Frame %d: OUT OF SYNC FROM eNB %d (T310 %d, N310 %d, N311 %d)\n ", - Mod_id,frame,eNB_index, - UE_rrc_inst[Mod_id].Info[eNB_index].T310_cnt, - UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt, - UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt); + Mod_idP,frameP,eNB_index, + UE_rrc_inst[Mod_idP].Info[eNB_index].T310_cnt, + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt, + UE_rrc_inst[Mod_idP].Info[eNB_index].N311_cnt); #if defined(ENABLE_ITTI) { MessageDef *message_p; message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_OUT_OF_SYNC_IND); - RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frame; + RRC_MAC_OUT_OF_SYNC_IND (message_p).frame = frameP; RRC_MAC_OUT_OF_SYNC_IND (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else - UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt++; + UE_rrc_inst[Mod_idP].Info[eNB_index].N310_cnt++; #endif } //-------------------------------------------------------------------------------------------// -int mac_get_rrc_lite_status(u8 Mod_id,u8 eNB_flag,u8 index){ +int mac_get_rrc_lite_status(module_id_t Mod_idP,eNB_flag_t eNB_flag,u8 index){ //-------------------------------------------------------------------------------------------// if(eNB_flag == 1) - return(eNB_rrc_inst[Mod_id].Info.UE[index].Status); + return(eNB_rrc_inst[Mod_idP].Info.UE[index].Status); else - return(UE_rrc_inst[Mod_id].Info[index].State); + return(UE_rrc_inst[Mod_idP].Info[index].State); } //-------------------------------------------------------------------------------------------// -int mac_ue_ccch_success_ind(u8 Mod_id, u8 eNB_index) { +int mac_ue_ccch_success_ind(module_id_t Mod_idP, u8 eNB_index) { //-------------------------------------------------------------------------------------------// #if defined(ENABLE_ITTI) { @@ -634,11 +634,11 @@ int mac_ue_ccch_success_ind(u8 Mod_id, u8 eNB_index) { message_p = itti_alloc_new_message (TASK_MAC_UE, RRC_MAC_CCCH_DATA_CNF); RRC_MAC_CCCH_DATA_CNF (message_p).enb_index = eNB_index; - itti_send_msg_to_task (TASK_RRC_UE, Mod_id + NB_eNB_INST, message_p); + itti_send_msg_to_task (TASK_RRC_UE, Mod_idP + NB_eNB_INST, message_p); } #else // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds) - UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size=0; + UE_rrc_inst[Mod_idP].Srb0[eNB_index].Tx_buffer.payload_size=0; #endif return 0; } diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h index f396f950e844bd2786499d5c9dcc2ecfe5a6d81e..0dfa986167cea04f1ad84ab918356002cf3a864f 100644 --- a/openair2/RRC/LITE/defs.h +++ b/openair2/RRC/LITE/defs.h @@ -234,8 +234,8 @@ union{ typedef struct HANDOVER_INFO_s { u8 ho_prepare; u8 ho_complete; - u8 modid_s; //Mod_id of serving cell - u8 modid_t; //Mod_id of target cell + u8 modid_s; //module_idP of serving cell + u8 modid_t; //module_idP of target cell u8 ueid_s; //UE index in serving cell u8 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 */ @@ -444,147 +444,147 @@ typedef struct UE_RRC_INST_s { int rrc_init_global_param(void); int L3_xface_init(void); void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active,u8 HO_enabled); -char openair_rrc_lite_eNB_init(u8 Mod_id); -char openair_rrc_lite_ue_init(u8 Mod_id,u8 CH_IDX); +char openair_rrc_lite_eNB_init(module_id_t module_idP); +char openair_rrc_lite_ue_init(module_id_t module_idP,u8 CH_IDX); void rrc_config_buffer(SRB_INFO *srb_info, u8 Lchan_type, u8 Role); -void openair_rrc_on(u8 Mod_id,u8 eNB_flag); +void openair_rrc_on(module_id_t module_idP, eNB_flag_t eNB_flagP); void rrc_top_cleanup(void); /** \brief Function to update timers every subframe. For UE it updates T300,T304 and T310. -@param Mod_id Instance of UE/eNB +@param module_idP Instance of UE/eNB @param frame Frame index @param eNB_flag Flag to indicate if this instance is and eNB or UE @param index Index of corresponding eNB (for UE) */ -RRC_status_t rrc_rx_tx(u8 Mod_id,u32 frame, u8 eNB_flag,u8 index); +RRC_status_t rrc_rx_tx(module_id_t module_idP,frame_t frameP, eNB_flag_t eNB_flagP,u8 index); // UE RRC Procedures /** \brief Decodes DL-CCCH message and invokes appropriate routine to handle the message - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param Srb_info Pointer to SRB_INFO structure (SRB0) \param eNB_index Index of corresponding eNB/CH*/ -int rrc_ue_decode_ccch(u8 Mod_id, u32 frame, SRB_INFO *Srb_info,u8 eNB_index); +int rrc_ue_decode_ccch(module_id_t module_idP, frame_t frameP, SRB_INFO *Srb_info,u8 eNB_index); /** \brief Decodes a DL-DCCH message and invokes appropriate routine to handle the message - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param Srb_id Index of Srb (1,2) - \param Buffer Pointer to received SDU + \param buffer_pP Pointer to received SDU \param eNB_index Index of corresponding CH/eNB*/ -void rrc_ue_decode_dcch(u8 Mod_id, u32 frame, u8 Srb_id, u8* Buffer,u8 eNB_index); +void rrc_ue_decode_dcch(module_id_t module_idP, frame_t frameP, u8 Srb_id, u8* buffer_pP,u8 eNB_index); /** \brief Generate/Encodes RRCConnnectionRequest message at UE - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param Srb_id Index of Srb (1,2) \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionRequest(u8 Mod_id, u32 frame, u8 eNB_index); +void rrc_ue_generate_RRCConnectionRequest(module_id_t module_idP, frame_t frameP, u8 eNB_index); /** \brief Generates/Encodes RRCConnnectionSetupComplete message at UE - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionSetupComplete(u8 Mod_id,u32 frame,u8 eNB_index, uint8_t Transaction_id); +void rrc_ue_generate_RRCConnectionSetupComplete(module_id_t module_idP,frame_t frameP,u8 eNB_index, uint8_t Transaction_id); /** \brief process the received rrcConnectionReconfiguration message at UE - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param *rrcConnectionReconfiguration pointer to the sturcture \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_process_rrcConnectionReconfiguration(u8 Mod_id, u32 frame,RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,u8 eNB_index); +void rrc_ue_process_rrcConnectionReconfiguration(module_id_t module_idP, frame_t frameP,RRCConnectionReconfiguration_t *rrcConnectionReconfiguration,u8 eNB_index); /** \brief Generates/Encodes RRCConnectionReconfigurationComplete message at UE - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param eNB_index Index of corresponding eNB/CH*/ -void rrc_ue_generate_RRCConnectionReconfigurationComplete(u8 Mod_id, u32 frame, u8 eNB_index, uint8_t Transaction_id); +void rrc_ue_generate_RRCConnectionReconfigurationComplete(module_id_t module_idP, frame_t frameP, u8 eNB_index, uint8_t Transaction_id); /** \brief Establish SRB1 based on configuration in SRB_ToAddMod structure. Configures RLC/PDCP accordingly - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param eNB_index Index of corresponding eNB/CH \param SRB_config Pointer to SRB_ToAddMod IE from configuration @returns 0 on success*/ -s32 rrc_ue_establish_srb1(u8 Mod_id,u32 frame,u8 eNB_index,struct SRB_ToAddMod *SRB_config); +s32 rrc_ue_establish_srb1(module_id_t module_idP,frame_t frameP,u8 eNB_index,struct SRB_ToAddMod *SRB_config); /** \brief Establish SRB2 based on configuration in SRB_ToAddMod structure. Configures RLC/PDCP accordingly - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param frame Frame index \param eNB_index Index of corresponding eNB/CH \param SRB_config Pointer to SRB_ToAddMod IE from configuration @returns 0 on success*/ -s32 rrc_ue_establish_srb2(u8 Mod_id,u32 frame, u8 eNB_index,struct SRB_ToAddMod *SRB_config); +s32 rrc_ue_establish_srb2(module_id_t module_idP,frame_t frameP, u8 eNB_index,struct SRB_ToAddMod *SRB_config); /** \brief Establish a DRB according to DRB_ToAddMod structure - \param Mod_id Instance ID of UE + \param module_idP Instance ID of UE \param eNB_index Index of corresponding CH/eNB \param DRB_config Pointer to DRB_ToAddMod IE from configuration @returns 0 on success */ -s32 rrc_ue_establish_drb(u8 Mod_id,u32 frame,u8 eNB_index,struct DRB_ToAddMod *DRB_config); +s32 rrc_ue_establish_drb(module_id_t module_idP,frame_t frameP,u8 eNB_index,struct DRB_ToAddMod *DRB_config); /** \brief Process MobilityControlInfo Message to proceed with handover and configure PHY/MAC - \param Mod_id Instance of UE on which to act + \param module_idP Instance of UE on which to act \param frame frame time interval \param eNB_index Index of corresponding CH/eNB \param mobilityControlInfo Pointer to mobilityControlInfo */ -void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struct MobilityControlInfo *mobilityControlInfo); +void rrc_ue_process_mobilityControlInfo(module_id_t enb_module_idP, module_id_t ue_module_idP, frame_t frameP, struct MobilityControlInfo *mobilityControlInfo); /** \brief Process a measConfig Message and configure PHY/MAC - \param Mod_id Instance of UE on which to act + \param module_idP Instance of UE on which to act \param frame frame time interval \param eNB_index Index of corresponding CH/eNB \param measConfig Pointer to MeasConfig IE from configuration*/ -void rrc_ue_process_measConfig(u8 Mod_id,u32 frame, u8 eNB_index,MeasConfig_t *measConfig); +void rrc_ue_process_measConfig(module_id_t module_idP,frame_t frameP, u8 eNB_index,MeasConfig_t *measConfig); /** \brief Process a RadioResourceConfigDedicated Message and configure PHY/MAC - \param Mod_id Instance of UE on which to act + \param module_idP Instance of UE on which to act \param eNB_index Index of corresponding CH/eNB \param radioResourceConfigDedicated Pointer to RadioResourceConfigDedicated IE from configuration*/ -void rrc_ue_process_radioResourceConfigDedicated(u8 Mod_id,u32 frame, u8 eNB_index, +void rrc_ue_process_radioResourceConfigDedicated(module_id_t module_idP,frame_t frameP, u8 eNB_index, RadioResourceConfigDedicated_t *radioResourceConfigDedicated); // eNB/CH RRC Procedures /**\brief Function to get the next transaction identifier. - \param Mod_id Instance ID for CH/eNB + \param module_idP Instance ID for CH/eNB \return a transaction identifier*/ -uint8_t rrc_eNB_get_next_transaction_identifier(uint8_t Mod_id); +uint8_t rrc_eNB_get_next_transaction_identifier(module_id_t module_idP); /**\brief Entry routine to decode a UL-CCCH-Message. Invokes PER decoder and parses message. - \param Mod_id Instance ID for CH/eNB + \param module_idP Instance ID for CH/eNB \param frame Frame index \param Srb_info Pointer to SRB0 information structure (buffer, etc.)*/ -int rrc_eNB_decode_ccch(u8 Mod_id, u32 frame, SRB_INFO *Srb_info); +int rrc_eNB_decode_ccch(module_id_t module_idP, frame_t frameP, SRB_INFO *Srb_info); /**\brief Entry routine to decode a UL-DCCH-Message. Invokes PER decoder and parses message. - \param Mod_id Instance ID for CH/eNB + \param module_idP Instance ID for CH/eNB \param frame Frame index \param UE_index Index of UE sending the message \param Rx_sdu Pointer Received Message \param sdu_size Size of incoming SDU*/ -int rrc_eNB_decode_dcch(u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, u8 *Rx_sdu, u8 sdu_size); +int rrc_eNB_decode_dcch(module_id_t module_idP, frame_t frameP, u8 Srb_id, u8 UE_index, u8 *Rx_sdu, u8 sdu_size); /**\brief Generate the RRCConnectionSetup based on information coming from RRM - \param Mod_id Instance ID for eNB/CH + \param module_idP Instance ID for eNB/CH \param frame Frame index \param UE_index Index of UE receiving the message*/ -void rrc_eNB_generate_RRCConnectionSetup(u8 Mod_id,u32 frame, u16 UE_index); +void rrc_eNB_generate_RRCConnectionSetup(module_id_t module_idP,frame_t frameP, u16 UE_index); /**\brief Process the RRCConnectionSetupComplete based on information coming from UE - \param Mod_id Instance ID for eNB/CH + \param module_idP Instance ID for eNB/CH \param frame Frame index \param UE_index Index of UE transmitting the message \param rrcConnectionSetupComplete Pointer to RRCConnectionSetupComplete message*/ -void rrc_eNB_process_RRCConnectionSetupComplete(u8 Mod_id, u32 frame, u8 UE_index, +void rrc_eNB_process_RRCConnectionSetupComplete(module_id_t module_idP, frame_t frameP, u8 UE_index, RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete); /**\brief Process the RRCConnectionReconfigurationComplete based on information coming from UE - \param Mod_id Instance ID for eNB/CH + \param module_idP Instance ID for eNB/CH \param UE_index Index of UE transmitting the messages \param rrcConnectionReconfigurationComplete Pointer to RRCConnectionReconfigurationComplete message*/ -void rrc_eNB_process_RRCConnectionReconfigurationComplete(u8 Mod_id,u32 frame,u8 UE_index,RRCConnectionReconfigurationComplete_r8_IEs_t *rrcConnectionReconfigurationComplete); +void rrc_eNB_process_RRCConnectionReconfigurationComplete(module_id_t module_idP,frame_t frameP,u8 UE_index,RRCConnectionReconfigurationComplete_r8_IEs_t *rrcConnectionReconfigurationComplete); #if defined(ENABLE_ITTI) /**\brief RRC eNB task. @@ -597,61 +597,69 @@ void *rrc_ue_task(void *args_p); #endif /**\brief Generate/decode the handover RRCConnectionReconfiguration at eNB - \param Mod_id Instance ID for eNB/CH + \param module_idP Instance ID for eNB/CH \param frame Frame index \param UE_index Index of UE transmitting the messages*/ -void rrc_eNB_generate_RRCConnectionReconfiguration_handover(u8 Mod_id, u32 frame, u16 UE_index, u8 *nas_pdu, u32 nas_length); +void rrc_eNB_generate_RRCConnectionReconfiguration_handover(module_id_t module_idP, frame_t frameP, u16 UE_index, u8 *nas_pdu, u32 nas_length); //L2_interface.c -s8 mac_rrc_lite_data_req( u8 Mod_id, u32 frame, unsigned short Srb_id, u8 Nb_tb, u8 *Buffer,u8 eNB_flag, u8 eNB_index, u8 mbsfn_sync_area); +s8 mac_rrc_lite_data_req( module_id_t module_idP, frame_t frameP, unsigned short Srb_id, u8 Nb_tb, u8 *buffer_pP,eNB_flag_t eNB_flagP, u8 eNB_index, u8 mbsfn_sync_area); -s8 mac_rrc_lite_data_ind( u8 Mod_id, u32 frame, unsigned short Srb_id, u8 *Sdu, unsigned short Sdu_len,u8 eNB_flag,u8 eNB_index, u8 mbsfn_sync_area); +s8 mac_rrc_lite_data_ind( module_id_t module_idP, frame_t frameP, unsigned short Srb_id, u8 *Sdu, unsigned short Sdu_len,eNB_flag_t eNB_flagP,u8 eNB_index, u8 mbsfn_sync_area); -void mac_sync_ind( u8 Mod_id, u8 status); +void mac_sync_ind( module_id_t Mod_instP, u8 status); -u8 rrc_lite_data_req(u8 eNB_id, u8 UE_id, u32 frame, u8 eNB_flag, unsigned int rb_id, u32 muiP, u32 confirmP, - unsigned int sdu_size, u8* Buffer, u8 mode); +u8 rrc_lite_data_req(module_id_t enb_mod_idP, + module_id_t ue_mod_idP, + frame_t frameP, + eNB_flag_t eNB_flagP, + rb_id_t rb_idP, + mui_t muiP, + u32 confirmP, + sdu_size_t sdu_sizeP, + u8 *Buffer_pP, + u8 modeP); -void rrc_lite_data_ind(u8_t eNB_id, u8_t UE_id, u32 frame, u8 eNB_flag, u32 Rb_id, u32 sdu_size,u8 *Buffer); +void rrc_lite_data_ind(module_id_t eNB_id, module_id_t UE_id, frame_t frameP, eNB_flag_t eNB_flagP, rb_id_t Rb_id, sdu_size_t sdu_size,u8 *buffer_pP); -void rrc_lite_in_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index); +void rrc_lite_in_sync_ind(module_id_t module_idP, frame_t frameP, u16 eNB_index); -void rrc_lite_out_of_sync_ind(u8 Mod_id, u32 frame, unsigned short eNB_index); +void rrc_lite_out_of_sync_ind(module_id_t module_idP, frame_t frameP, unsigned short eNB_index); -int decode_MCCH_Message(u8 Mod_id, u32 frame, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area); +int decode_MCCH_Message(module_id_t module_idP, frame_t frameP, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area); -void decode_MBSFNAreaConfiguration(u8 Mod_id, u8 eNB_index, u32 frame,u8 mbsfn_sync_area); +void decode_MBSFNAreaConfiguration(module_id_t module_idP, u8 eNB_index, frame_t frameP,u8 mbsfn_sync_area); -int decode_BCCH_DLSCH_Message(u8 Mod_id,u32 frame,u8 eNB_index,u8 *Sdu,u8 Sdu_len, u8 rsrq, u8 rsrp); +int decode_BCCH_DLSCH_Message(module_id_t module_idP,frame_t frameP,u8 eNB_index,u8 *Sdu,u8 Sdu_len, u8 rsrq, u8 rsrp); -int decode_SIB1(u8 Mod_id,u8 eNB_index, u8 rsrq, u8 rsrp); +int decode_SIB1(module_id_t module_idP,u8 eNB_index, u8 rsrq, u8 rsrp); -int decode_SI(u8 Mod_id,u32 frame,u8 eNB_index,u8 si_window); +int decode_SI(module_id_t module_idP,frame_t frameP,u8 eNB_index,u8 si_window); -void ue_meas_filtering(u8 Mod_id,u32 frame,u8 eNB_index); +void ue_meas_filtering(module_id_t module_idP,frame_t frameP,u8 eNB_index); -void ue_measurement_report_triggering(u8 Mod_id, u32 frame,u8 eNB_index); +void ue_measurement_report_triggering(module_id_t module_idP, frame_t frameP,u8 eNB_index); -int mac_get_rrc_lite_status(u8 Mod_id,u8 eNB_flag,u8 index); +int mac_get_rrc_lite_status(module_id_t module_idP,eNB_flag_t eNB_flagP,u8 index); -void rrc_eNB_generate_UECapabilityEnquiry(u8 Mod_id, u32 frame, u16 UE_index); +void rrc_eNB_generate_UECapabilityEnquiry(module_id_t module_idP, frame_t frameP, u16 UE_index); -void rrc_eNB_generate_SecurityModeCommand(u8 Mod_id, u32 frame, u16 UE_index); +void rrc_eNB_generate_SecurityModeCommand(module_id_t module_idP, frame_t frameP, u16 UE_index); -void rrc_eNB_process_MeasurementReport(u8 Mod_id,u32 frame, u16 UE_index,MeasResults_t *measResults2) ; +void rrc_eNB_process_MeasurementReport(u8 module_idP,frame_t frameP, u16 UE_index,MeasResults_t *measResults2) ; -void rrc_eNB_generate_HandoverPreparationInformation (u8 Mod_id, u32 frame, u8 UE_index, PhysCellId_t targetPhyId) ; +void rrc_eNB_generate_HandoverPreparationInformation (u8 module_idP, frame_t frameP, u8 UE_index, PhysCellId_t targetPhyId) ; -void check_handovers(u8 Mod_id, u32 frame); +void check_handovers(u8 module_idP, frame_t frameP); -u8 check_trigger_meas_event(u8 Mod_id,u32 frame, u8 eNB_index, u8 ue_cnx_index, u8 meas_index, +u8 check_trigger_meas_event(u8 module_idP,frame_t frameP, u8 eNB_index, u8 ue_cnx_index, u8 meas_index, Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt); -//void rrc_ue_process_ueCapabilityEnquiry(uint8_t Mod_id,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index); -//void rrc_ue_process_securityModeCommand(uint8_t Mod_id,uint32_t frame,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index); +//void rrc_ue_process_ueCapabilityEnquiry(uint8_t module_idP,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index); +//void rrc_ue_process_securityModeCommand(uint8_t module_idP,uint32_t frame,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index); -void rrc_eNB_free_UE_index (u8 Mod_id, u8 UE_id); +void rrc_eNB_free_UE_index (module_id_t enb_mod_idP, module_id_t ue_mod_idP); long binary_search_int(int elements[], long numElem, int value); diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c index 1890b9dcb2ac7cfda2c72db1a50825217fd6f893..3288723eb7e3e3aec258b822ff77e88b260c04e5 100644 --- a/openair2/RRC/LITE/rrc_UE.c +++ b/openair2/RRC/LITE/rrc_UE.c @@ -24,16 +24,16 @@ Forums : http://forums.eurecom.fsr/openairinterface Address : Eurecom, 2229, route des crêtes, 06560 Valbonne Sophia Antipolis, France -*******************************************************************************/ + *******************************************************************************/ /*! \file rrc_UE.c -* \brief rrc procedures for UE -* \author Raymond Knopp and Navid Nikaein -* \date 2011 -* \version 1.0 -* \company Eurecom -* \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr -*/ + * \brief rrc procedures for UE + * \author Raymond Knopp and Navid Nikaein + * \date 2011 + * \version 1.0 + * \company Eurecom + * \email: raymond.knopp@eurecom.fr and navid.nikaein@eurecom.fr + */ #define RRC_UE #define RRC_UE_C @@ -104,80 +104,80 @@ extern inline unsigned int taus(void); extern s8 dB_fixed2(u32 x,u32 y); /*------------------------------------------------------------------------------*/ -static Rrc_State_t rrc_get_state (u8 Mod_id) { +static Rrc_State_t rrc_get_state (module_id_t Mod_id) { return UE_rrc_inst[Mod_id].RrcState; } -static Rrc_Sub_State_t rrc_get_sub_state (u8 Mod_id) { +static Rrc_Sub_State_t rrc_get_sub_state (module_id_t Mod_id) { return UE_rrc_inst[Mod_id].RrcSubState; } -static int rrc_set_state (u8 Mod_id, Rrc_State_t state) { +static int rrc_set_state (module_id_t Mod_id, Rrc_State_t state) { AssertFatal ((RRC_STATE_FIRST <= state) && (state <= RRC_STATE_LAST), - "Invalid state %d!\n", state); + "Invalid state %d!\n", state); if (UE_rrc_inst[Mod_id].RrcState != state) { - UE_rrc_inst[Mod_id].RrcState = state; + UE_rrc_inst[Mod_id].RrcState = state; #if defined(ENABLE_ITTI) - { - MessageDef *msg_p; + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND); - RRC_STATE_IND(msg_p).state = UE_rrc_inst[Mod_id].RrcState; - RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[Mod_id].RrcSubState; + msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND); + RRC_STATE_IND(msg_p).state = UE_rrc_inst[Mod_id].RrcState; + RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[Mod_id].RrcSubState; - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } #endif - return (1); + return (1); } return (0); } -static int rrc_set_sub_state (u8 Mod_id, Rrc_Sub_State_t subState) { +static int rrc_set_sub_state (module_id_t Mod_id, Rrc_Sub_State_t subState) { #if (defined(ENABLE_ITTI) && (defined(ENABLE_USE_MME) || defined(ENABLE_RAL))) switch (UE_rrc_inst[Mod_id].RrcState) { - case RRC_STATE_INACTIVE: - AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); - break; - - case RRC_STATE_IDLE: - AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); - break; - - case RRC_STATE_CONNECTED: - AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST), - "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); - break; + case RRC_STATE_INACTIVE: + AssertFatal ((RRC_SUB_STATE_INACTIVE_FIRST <= subState) && (subState <= RRC_SUB_STATE_INACTIVE_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); + break; + + case RRC_STATE_IDLE: + AssertFatal ((RRC_SUB_STATE_IDLE_FIRST <= subState) && (subState <= RRC_SUB_STATE_IDLE_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); + break; + + case RRC_STATE_CONNECTED: + AssertFatal ((RRC_SUB_STATE_CONNECTED_FIRST <= subState) && (subState <= RRC_SUB_STATE_CONNECTED_LAST), + "Invalid sub state %d for state %d!\n", subState, UE_rrc_inst[Mod_id].RrcState); + break; } #endif if (UE_rrc_inst[Mod_id].RrcSubState != subState) { - UE_rrc_inst[Mod_id].RrcSubState = subState; + UE_rrc_inst[Mod_id].RrcSubState = subState; #if defined(ENABLE_ITTI) - { - MessageDef *msg_p; + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND); - RRC_STATE_IND(msg_p).state = UE_rrc_inst[Mod_id].RrcState; - RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[Mod_id].RrcSubState; + msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_STATE_IND); + RRC_STATE_IND(msg_p).state = UE_rrc_inst[Mod_id].RrcState; + RRC_STATE_IND(msg_p).sub_state = UE_rrc_inst[Mod_id].RrcSubState; - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } #endif - return (1); + return (1); } return (0); } /*------------------------------------------------------------------------------*/ -void init_SI_UE(u8 Mod_id,u8 eNB_index) { +void init_SI_UE(module_id_t Mod_id,u8 eNB_index) { int i; @@ -190,7 +190,7 @@ void init_SI_UE(u8 Mod_id,u8 eNB_index) { UE_rrc_inst[Mod_id].SI[eNB_index] = (u8 *)malloc16(64); for (i=0;i<NB_CNX_UE;i++) { - UE_rrc_inst[Mod_id].si[eNB_index][i] = (SystemInformation_t *)malloc16(sizeof(SystemInformation_t)); + UE_rrc_inst[Mod_id].si[eNB_index][i] = (SystemInformation_t *)malloc16(sizeof(SystemInformation_t)); } UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status = 0; @@ -198,7 +198,7 @@ void init_SI_UE(u8 Mod_id,u8 eNB_index) { } #ifdef Rel10 -void init_MCCH_UE(u8 Mod_id, u8 eNB_index) { +void init_MCCH_UE(module_id_t Mod_id, u8 eNB_index) { int i; UE_rrc_inst[Mod_id].sizeof_MCCH_MESSAGE[eNB_index] = 0; UE_rrc_inst[Mod_id].MCCH_MESSAGE[eNB_index] = (u8 *)malloc16(32); @@ -210,26 +210,26 @@ void init_MCCH_UE(u8 Mod_id, u8 eNB_index) { #endif static -void openair_rrc_lite_ue_init_security(u8 Mod_id) +void openair_rrc_lite_ue_init_security(module_id_t Mod_id) { #if defined(ENABLE_SECURITY) -// uint8_t *kRRCenc; -// uint8_t *kRRCint; - char ascii_buffer[65]; - uint8_t i; + // uint8_t *kRRCenc; + // uint8_t *kRRCint; + char ascii_buffer[65]; + uint8_t i; - memset(UE_rrc_inst[Mod_id].kenb, Mod_id, 32); + memset(UE_rrc_inst[Mod_id].kenb, Mod_id, 32); - for (i = 0; i < 32; i++) { - sprintf(&ascii_buffer[2 * i], "%02X", UE_rrc_inst[Mod_id].kenb[i]); - } + for (i = 0; i < 32; i++) { + sprintf(&ascii_buffer[2 * i], "%02X", UE_rrc_inst[Mod_id].kenb[i]); + } - LOG_T(RRC, "[OSA][UE %02d] kenb = %s\n", Mod_id, ascii_buffer); + LOG_T(RRC, "[OSA][UE %02d] kenb = %s\n", Mod_id, ascii_buffer); #endif } /*------------------------------------------------------------------------------*/ -char openair_rrc_lite_ue_init(u8 Mod_id, unsigned char eNB_index){ +char openair_rrc_lite_ue_init(module_id_t Mod_id, unsigned char eNB_index){ /*-----------------------------------------------------------------------------*/ rrc_set_state (Mod_id, RRC_STATE_INACTIVE); rrc_set_sub_state (Mod_id, RRC_SUB_STATE_INACTIVE); @@ -278,39 +278,39 @@ char openair_rrc_lite_ue_init(u8 Mod_id, unsigned char eNB_index){ } /*------------------------------------------------------------------------------*/ -void rrc_ue_generate_RRCConnectionRequest(u8 Mod_id, u32 frame, u8 eNB_index){ +void rrc_ue_generate_RRCConnectionRequest(module_id_t Mod_id, frame_t frameP, u8 eNB_index){ /*------------------------------------------------------------------------------*/ u8 i=0,rv[6]; - + if(UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size ==0){ - // Get RRCConnectionRequest, fill random for now - // Generate random byte stream for contention resolution + // Get RRCConnectionRequest, fill random for now + // Generate random byte stream for contention resolution for (i=0;i<6;i++) { #ifdef SMBV - // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed - rv[i]=i; + // if SMBV is configured the contention resolution needs to be fix for the connection procedure to succeed + rv[i]=i; #else - rv[i]=taus()&0xff; + rv[i]=taus()&0xff; #endif - LOG_T(RRC,"%x.",rv[i]); - } - LOG_T(RRC,"\n"); - UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size = do_RRCConnectionRequest(Mod_id, (u8 *)UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload,rv); + LOG_T(RRC,"%x.",rv[i]); + } + LOG_T(RRC,"\n"); + UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size = do_RRCConnectionRequest(Mod_id, (u8 *)UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload,rv); - LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n", - Mod_id, frame, UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index); + LOG_I(RRC,"[UE %d] : Frame %d, Logical Channel UL-CCCH (SRB0), Generating RRCConnectionRequest (bytes %d, eNB %d)\n", + Mod_id, frameP, UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size, eNB_index); - for (i=0;i<UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size;i++) { - LOG_T(RRC,"%x.",UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload[i]); - } - LOG_T(RRC,"\n"); - /* + for (i=0;i<UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.payload_size;i++) { + LOG_T(RRC,"%x.",UE_rrc_inst[Mod_id].Srb0[eNB_index].Tx_buffer.Payload[i]); + } + LOG_T(RRC,"\n"); + /* UE_rrc_inst[Mod_id].Srb0[Idx].Tx_buffer.Payload[i] = taus()&0xff; UE_rrc_inst[Mod_id].Srb0[Idx].Tx_buffer.payload_size =i; - */ + */ } } @@ -320,36 +320,36 @@ mui_t rrc_mui=0; /* NAS Attach request with IMSI */ static const char nas_attach_req_imsi[] = -{ - 0x07, 0x41, - /* EPS Mobile identity = IMSI */ - 0x71, 0x08, 0x29, 0x80, 0x43, 0x21, 0x43, 0x65, 0x87, - 0xF9, - /* End of EPS Mobile Identity */ - 0x02, 0xE0, 0xE0, 0x00, 0x20, 0x02, 0x03, - 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, - 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, - 0x01, 0x27, 0x11, -}; + { + 0x07, 0x41, + /* EPS Mobile identity = IMSI */ + 0x71, 0x08, 0x29, 0x80, 0x43, 0x21, 0x43, 0x65, 0x87, + 0xF9, + /* End of EPS Mobile Identity */ + 0x02, 0xE0, 0xE0, 0x00, 0x20, 0x02, 0x03, + 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, + 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, + 0x01, 0x27, 0x11, + }; /* NAS Attach request with GUTI */ static const char nas_attach_req_guti[] = -{ - 0x07, 0x41, - /* EPS Mobile identity = GUTI */ - 0x71, 0x0B, 0xF6, 0x12, 0xF2, 0x01, 0x80, 0x00, 0x01, 0xE0, 0x00, - 0xDA, 0x1F, - /* End of EPS Mobile Identity */ - 0x02, 0xE0, 0xE0, 0x00, 0x20, 0x02, 0x03, - 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, - 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, - 0x01, 0x27, 0x11, -}; + { + 0x07, 0x41, + /* EPS Mobile identity = GUTI */ + 0x71, 0x0B, 0xF6, 0x12, 0xF2, 0x01, 0x80, 0x00, 0x01, 0xE0, 0x00, + 0xDA, 0x1F, + /* End of EPS Mobile Identity */ + 0x02, 0xE0, 0xE0, 0x00, 0x20, 0x02, 0x03, + 0xD0, 0x11, 0x27, 0x1A, 0x80, 0x80, 0x21, 0x10, 0x01, 0x00, 0x00, + 0x10, 0x81, 0x06, 0x00, 0x00, 0x00, 0x00, 0x83, 0x06, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x0A, 0x00, 0x52, 0x12, 0xF2, + 0x01, 0x27, 0x11, + }; /*------------------------------------------------------------------------------*/ -void rrc_ue_generate_RRCConnectionSetupComplete(u8 Mod_id, u32 frame, u8 eNB_index, uint8_t Transaction_id){ +void rrc_ue_generate_RRCConnectionSetupComplete(module_id_t Mod_id, frame_t frameP, u8 eNB_index, uint8_t Transaction_id){ /*------------------------------------------------------------------------------*/ u8 buffer[100]; @@ -368,32 +368,32 @@ void rrc_ue_generate_RRCConnectionSetupComplete(u8 Mod_id, u32 frame, u8 eNB_ind size = do_RRCConnectionSetupComplete(Mod_id, buffer, Transaction_id, nas_msg_length, nas_msg); LOG_I(RRC,"[UE %d][RAPROC] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionSetupComplete (bytes%d, eNB %d)\n", - Mod_id,frame, size, eNB_index); + Mod_id,frameP, size, eNB_index); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id+NB_eNB_INST, size, eNB_index, rrc_mui, Mod_id+NB_eNB_INST, DCCH); + LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionSetupComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", + frameP, Mod_id+NB_eNB_INST, size, eNB_index, rrc_mui, Mod_id+NB_eNB_INST, DCCH); - // rrc_rlc_data_req(Mod_id+NB_eNB_INST,frame, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (eNB_index, Mod_id, frame, 0, DCCH, rrc_mui++, 0, size, buffer, 1); + // rrc_rlc_data_req(Mod_id+NB_eNB_INST,frameP, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); + pdcp_rrc_data_req (eNB_index, Mod_id, frameP, 0, DCCH, rrc_mui++, 0, size, buffer, 1); } -void rrc_ue_generate_RRCConnectionReconfigurationComplete(u8 Mod_id, u32 frame, u8 eNB_index, uint8_t Transaction_id) { +void rrc_ue_generate_RRCConnectionReconfigurationComplete(module_id_t Mod_id, frame_t frameP, u8 eNB_index, uint8_t Transaction_id) { u8 buffer[32], size; size = do_RRCConnectionReconfigurationComplete(Mod_id, buffer, Transaction_id); LOG_I(RRC,"[UE %d] Frame %d : Logical Channel UL-DCCH (SRB1), Generating RRCConnectionReconfigurationComplete (bytes %d, eNB_index %d)\n", - Mod_id,frame, size, eNB_index); + Mod_id,frameP, size, eNB_index); LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (RRCConnectionReconfigurationComplete to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id+NB_eNB_INST, size, eNB_index, rrc_mui, Mod_id+NB_eNB_INST, DCCH); + frameP, Mod_id+NB_eNB_INST, size, eNB_index, rrc_mui, Mod_id+NB_eNB_INST, DCCH); - //rrc_rlc_data_req(Mod_id+NB_eNB_INST,frame, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (eNB_index, Mod_id, frame, 0, DCCH, rrc_mui++, 0, size, buffer, 1); + //rrc_rlc_data_req(Mod_id+NB_eNB_INST,frameP, 0 ,DCCH,rrc_mui++,0,size,(char*)buffer); + pdcp_rrc_data_req (eNB_index, Mod_id, frameP, 0, DCCH, rrc_mui++, 0, size, buffer, 1); } /*------------------------------------------------------------------------------*/ -int rrc_ue_decode_ccch(u8 Mod_id, u32 frame, SRB_INFO *Srb_info, u8 eNB_index){ +int rrc_ue_decode_ccch(module_id_t Mod_id, frame_t frameP, SRB_INFO *Srb_info, u8 eNB_index){ /*------------------------------------------------------------------------------*/ //DL_CCCH_Message_t dlccchmsg; @@ -434,95 +434,95 @@ int rrc_ue_decode_ccch(u8 Mod_id, u32 frame, SRB_INFO *Srb_info, u8 eNB_index){ size_t message_string_size; if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_CCCH_Message, (void *)dl_ccch_msg)) > 0) - { - MessageDef *msg_p; + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_CCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_dl_ccch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_dl_ccch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); + } } # endif #endif if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%d bytes)\n",Mod_id,dec_rval.consumed); - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); - return -1; + LOG_E(RRC,"[UE %d] Frame %d : Failed to decode DL-CCCH-Message (%d bytes)\n",Mod_id,dec_rval.consumed); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); + return -1; } if (dl_ccch_msg->message.present == DL_CCCH_MessageType_PR_c1) { - if (UE_rrc_inst[Mod_id].Info[eNB_index].State == RRC_SI_RECEIVED) { + if (UE_rrc_inst[Mod_id].Info[eNB_index].State == RRC_SI_RECEIVED) { - switch (dl_ccch_msg->message.choice.c1.present) { + switch (dl_ccch_msg->message.choice.c1.present) { - case DL_CCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", Mod_id, frame); - rval = 0; - break; + case DL_CCCH_MessageType__c1_PR_NOTHING: + LOG_I(RRC, "[UE%d] Frame %d : Received PR_NOTHING on DL-CCCH-Message\n", Mod_id, frameP); + rval = 0; + break; - case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReestablishment ENB %d) --->][RRC_UE][MOD %02d][]\n", frame, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); + case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishment: + LOG_D(RRC, + "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReestablishment ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); - LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n", Mod_id, frame); - rval = 0; - break; + LOG_I(RRC, + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishment\n", Mod_id, frameP); + rval = 0; + break; - case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (RRCConnectionReestablishmentReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frame, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); - LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n", Mod_id, frame); - rval = 0; - break; + case DL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentReject: + LOG_D(RRC, + "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (RRCConnectionReestablishmentReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); + LOG_I(RRC, + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReestablishmentReject\n", Mod_id, frameP); + rval = 0; + break; - case DL_CCCH_MessageType__c1_PR_rrcConnectionReject: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frame, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); + case DL_CCCH_MessageType__c1_PR_rrcConnectionReject: + LOG_D(RRC, + "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReject ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); - LOG_I(RRC, - "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n", Mod_id, frame); - rval = 0; - break; + LOG_I(RRC, + "[UE%d] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionReject \n", Mod_id, frameP); + rval = 0; + break; - case DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: - LOG_D(RRC, - "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionSetup ENB %d) --->][RRC_UE][MOD %02d][]\n", frame, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); + case DL_CCCH_MessageType__c1_PR_rrcConnectionSetup: + LOG_D(RRC, + "[MSC_MSG][FRAME %05d][MAC_UE][MOD %02d][][--- MAC_DATA_IND (rrcConnectionSetup ENB %d) --->][RRC_UE][MOD %02d][]\n", frameP, Mod_id+NB_eNB_INST, eNB_index, Mod_id+NB_eNB_INST); - LOG_I(RRC, - "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup \n", Mod_id, frame); - // Get configuration + LOG_I(RRC, + "[UE%d][RAPROC] Frame %d : Logical Channel DL-CCCH (SRB0), Received RRCConnectionSetup \n", Mod_id, frameP); + // Get configuration - // Release T300 timer - UE_rrc_inst[Mod_id].Info[eNB_index].T300_active = 0; - rrc_ue_process_radioResourceConfigDedicated(Mod_id, frame, eNB_index, - &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated); + // Release T300 timer + UE_rrc_inst[Mod_id].Info[eNB_index].T300_active = 0; + rrc_ue_process_radioResourceConfigDedicated(Mod_id, frameP, eNB_index, + &dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.criticalExtensions.choice.c1.choice.rrcConnectionSetup_r8.radioResourceConfigDedicated); - rrc_set_state (Mod_id, RRC_STATE_CONNECTED); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_CONNECTED); - rrc_ue_generate_RRCConnectionSetupComplete(Mod_id, frame, eNB_index, dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier); + rrc_set_state (Mod_id, RRC_STATE_CONNECTED); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_CONNECTED); + rrc_ue_generate_RRCConnectionSetupComplete(Mod_id, frameP, eNB_index, dl_ccch_msg->message.choice.c1.choice.rrcConnectionSetup.rrc_TransactionIdentifier); - rval = 0; - break; + rval = 0; + break; - default: - LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n", Mod_id, frame); - rval = -1; - break; + default: + LOG_E(RRC, "[UE%d] Frame %d : Unknown message\n", Mod_id, frameP); + rval = -1; + break; + } } - } } vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_CCCH, VCD_FUNCTION_OUT); return rval; } -s32 rrc_ue_establish_srb1(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod *SRB_config) { +s32 rrc_ue_establish_srb1(module_id_t Mod_id, frame_t frameP,u8 eNB_index, struct SRB_ToAddMod *SRB_config) { // add descriptor from RRC PDU u8 lchan_id = DCCH; @@ -531,15 +531,15 @@ s32 rrc_ue_establish_srb1(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod UE_rrc_inst[Mod_id].Srb1[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Srb_id = 1; - // copy default configuration for now + // copy default configuration for now // memcpy(&UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); // memcpy(&UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); LOG_I(RRC,"[UE %d], CONFIG_SRB1 %d corresponding to eNB_index %d\n", Mod_id,lchan_id,eNB_index); - //rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, lchan_id,UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + //rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, lchan_id,UNDEF_SECURITY_MODE); + // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); // UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1; @@ -547,7 +547,7 @@ s32 rrc_ue_establish_srb1(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod return(0); } -s32 rrc_ue_establish_srb2(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod *SRB_config) { +s32 rrc_ue_establish_srb2(module_id_t Mod_id, frame_t frameP,u8 eNB_index, struct SRB_ToAddMod *SRB_config) { // add descriptor from RRC PDU u8 lchan_id = DCCH1; @@ -556,15 +556,15 @@ s32 rrc_ue_establish_srb2(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod UE_rrc_inst[Mod_id].Srb2[eNB_index].Status = RADIO_CONFIG_OK;//RADIO CFG UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id = 2; - // copy default configuration for now + // copy default configuration for now // memcpy(&UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Lchan_desc[0],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); // memcpy(&UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Lchan_desc[1],&DCCH_LCHAN_DESC,LCHAN_DESC_SIZE); LOG_I(RRC,"[UE %d], CONFIG_SRB2 %d corresponding to eNB_index %d\n",Mod_id,lchan_id,eNB_index); - //rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, lchan_id, UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + //rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, lchan_id, UNDEF_SECURITY_MODE); + // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD,lchan_id,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); // UE_rrc_inst[Mod_id].Srb1[eNB_index].Srb_info.Tx_buffer.payload_size=DEFAULT_MEAS_IND_SIZE+1; @@ -572,57 +572,57 @@ s32 rrc_ue_establish_srb2(u8 Mod_id,u32 frame,u8 eNB_index, struct SRB_ToAddMod return(0); } -s32 rrc_ue_establish_drb(u8 Mod_id,u32 frame,u8 eNB_index, - struct DRB_ToAddMod *DRB_config) { // add descriptor from RRC PDU +s32 rrc_ue_establish_drb(module_id_t Mod_id, frame_t frameP,u8 eNB_index, + struct DRB_ToAddMod *DRB_config) { // add descriptor from RRC PDU #ifdef NAS_NETLINK int oip_ifup=0,ip_addr_offset3=0,ip_addr_offset4=0; #endif LOG_I(RRC,"[UE %d] Frame %d: processing RRCConnectionReconfiguration: reconfiguring DRB %ld/LCID %d\n", - Mod_id, frame, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity); + Mod_id, frameP, DRB_config->drb_Identity, (int)*DRB_config->logicalChannelIdentity); /* - rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, + rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, UNDEF_SECURITY_MODE); - - rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD, + + rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD, (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity, RADIO_ACCESS_BEARER,Rlc_info_um); - */ + */ #ifdef NAS_NETLINK # ifdef OAI_EMU - ip_addr_offset3 = oai_emulation.info.nb_enb_local; - ip_addr_offset4 = NB_eNB_INST; + ip_addr_offset3 = oai_emulation.info.nb_enb_local; + ip_addr_offset4 = NB_eNB_INST; # else - ip_addr_offset3 = 0; - ip_addr_offset4 = 8; + ip_addr_offset3 = 0; + ip_addr_offset4 = 8; # endif # if !defined(OAI_NW_DRIVER_TYPE_ETHERNET) && !defined(EXMIMO) - LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oai%d, IP 10.0.%d.%d\n", Mod_id, ip_addr_offset3+Mod_id, - ip_addr_offset3+Mod_id+1,ip_addr_offset4+Mod_id+1); - oip_ifup=nas_config(ip_addr_offset3+Mod_id, // interface_id - ip_addr_offset3+Mod_id+1, // third_octet - ip_addr_offset4+Mod_id+1); // fourth_octet - if (oip_ifup == 0 ){ // interface is up --> send a config the DRB + LOG_I(OIP,"[UE %d] trying to bring up the OAI interface oai%d, IP 10.0.%d.%d\n", Mod_id, ip_addr_offset3+Mod_id, + ip_addr_offset3+Mod_id+1,ip_addr_offset4+Mod_id+1); + oip_ifup=nas_config(ip_addr_offset3+Mod_id, // interface_id + ip_addr_offset3+Mod_id+1, // third_octet + ip_addr_offset4+Mod_id+1); // fourth_octet + if (oip_ifup == 0 ){ // interface is up --> send a config the DRB # ifdef OAI_EMU oai_emulation.info.oai_ifup[Mod_id]=1; # endif LOG_I(OIP,"[UE %d] Config the oai%d to send/receive pkt on DRB %d to/from the protocol stack\n", - Mod_id, - ip_addr_offset3+Mod_id, - (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity); + Mod_id, + ip_addr_offset3+Mod_id, + (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity); rb_conf_ipv4(0,//add - Mod_id,//cx align with the UE index - ip_addr_offset3+Mod_id,//inst num_enb+ue_index - (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity,//rb - 0,//dscp - ipv4_address(ip_addr_offset3+Mod_id+1,ip_addr_offset4+Mod_id+1),//saddr - ipv4_address(ip_addr_offset3+Mod_id+1,eNB_index+1));//daddr + Mod_id,//cx align with the UE index + ip_addr_offset3+Mod_id,//inst num_enb+ue_index + (eNB_index * NB_RB_MAX) + *DRB_config->logicalChannelIdentity,//rb + 0,//dscp + ipv4_address(ip_addr_offset3+Mod_id+1,ip_addr_offset4+Mod_id+1),//saddr + ipv4_address(ip_addr_offset3+Mod_id+1,eNB_index+1));//daddr LOG_D(RRC,"[UE %d] State = Attached (eNB %d)\n",Mod_id,eNB_index); - } + } # else # ifdef OAI_EMU - oai_emulation.info.oai_ifup[Mod_id]=1; + oai_emulation.info.oai_ifup[Mod_id]=1; # endif # endif #endif @@ -631,7 +631,7 @@ s32 rrc_ue_establish_drb(u8 Mod_id,u32 frame,u8 eNB_index, } -void rrc_ue_process_measConfig(u8 Mod_id,u32 frame, u8 eNB_index,MeasConfig_t *measConfig){ +void rrc_ue_process_measConfig(module_id_t Mod_id, frame_t frameP, u8 eNB_index,MeasConfig_t *measConfig){ // This is the procedure described in 36.331 Section 5.5.2.1 int i; @@ -639,174 +639,174 @@ void rrc_ue_process_measConfig(u8 Mod_id,u32 frame, u8 eNB_index,MeasConfig_t * MeasObjectToAddMod_t *measObj; if (measConfig->measObjectToRemoveList != NULL) { - for (i=0;i<measConfig->measObjectToRemoveList->list.count;i++) { - ind = *measConfig->measObjectToRemoveList->list.array[i]; - free(UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]); - } + for (i=0;i<measConfig->measObjectToRemoveList->list.count;i++) { + ind = *measConfig->measObjectToRemoveList->list.array[i]; + free(UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]); + } } if (measConfig->measObjectToAddModList != NULL) { - LOG_D(RRC,"Measurement Object List is present\n"); - for (i=0;i<measConfig->measObjectToAddModList->list.count;i++) { - measObj = measConfig->measObjectToAddModList->list.array[i]; - ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; - - if (UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]) { - LOG_D(RRC,"Modifying measurement object %d\n",ind); - memcpy((char*)UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1], - (char*)measObj, - sizeof(MeasObjectToAddMod_t)); - } - else { - LOG_I(RRC,"Adding measurement object %d\n",ind); - if (measObj->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { - LOG_I(RRC,"EUTRA Measurement : carrierFreq %d, allowedMeasBandwidth %d,presenceAntennaPort1 %d, neighCellConfig %d\n", - measObj->measObject.choice.measObjectEUTRA.carrierFreq, - measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, - measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, - measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); - UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]=measObj; - } + LOG_D(RRC,"Measurement Object List is present\n"); + for (i=0;i<measConfig->measObjectToAddModList->list.count;i++) { + measObj = measConfig->measObjectToAddModList->list.array[i]; + ind = measConfig->measObjectToAddModList->list.array[i]->measObjectId; + + if (UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]) { + LOG_D(RRC,"Modifying measurement object %d\n",ind); + memcpy((char*)UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1], + (char*)measObj, + sizeof(MeasObjectToAddMod_t)); + } + else { + LOG_I(RRC,"Adding measurement object %d\n",ind); + if (measObj->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { + LOG_I(RRC,"EUTRA Measurement : carrierFreq %d, allowedMeasBandwidth %d,presenceAntennaPort1 %d, neighCellConfig %d\n", + measObj->measObject.choice.measObjectEUTRA.carrierFreq, + measObj->measObject.choice.measObjectEUTRA.allowedMeasBandwidth, + measObj->measObject.choice.measObjectEUTRA.presenceAntennaPort1, + measObj->measObject.choice.measObjectEUTRA.neighCellConfig.buf[0]); + UE_rrc_inst[Mod_id].MeasObj[eNB_index][ind-1]=measObj; + } + } } - } - rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - (struct PhysicalConfigDedicated *)NULL, - UE_rrc_inst[Mod_id].MeasObj[eNB_index], - (MAC_MainConfig_t *)NULL, - 0, - (struct LogicalChannelConfig *)NULL, - (MeasGapConfig_t *)NULL, - (TDD_Config_t *)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + rrc_mac_config_req(Mod_id,0,0,eNB_index, + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, + UE_rrc_inst[Mod_id].MeasObj[eNB_index], + (MAC_MainConfig_t *)NULL, + 0, + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL #ifdef Rel10 - , - 0, - (MBSFN_AreaInfoList_r9_t *)NULL, - (PMCH_InfoList_r9_t *)NULL + , + 0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL #endif #ifdef CBA - , - 0, - 0 + , + 0, + 0 #endif - ); + ); } if (measConfig->reportConfigToRemoveList != NULL) { - for (i=0;i<measConfig->reportConfigToRemoveList->list.count;i++) { - ind = *measConfig->reportConfigToRemoveList->list.array[i]; - free(UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1]); - } + for (i=0;i<measConfig->reportConfigToRemoveList->list.count;i++) { + ind = *measConfig->reportConfigToRemoveList->list.array[i]; + free(UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1]); + } } if (measConfig->reportConfigToAddModList != NULL) { - LOG_I(RRC,"Report Configuration List is present\n"); - for (i=0;i<measConfig->reportConfigToAddModList->list.count;i++) { - ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId; - if (UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1]) { - LOG_I(RRC,"Modifying Report Configuration %d\n",ind-1); - memcpy((char*)UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1], - (char*)measConfig->reportConfigToAddModList->list.array[i], - sizeof(ReportConfigToAddMod_t)); - } - else { - LOG_D(RRC,"Adding Report Configuration %d %p \n",ind-1,measConfig->reportConfigToAddModList->list.array[i]); - UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; + LOG_I(RRC,"Report Configuration List is present\n"); + for (i=0;i<measConfig->reportConfigToAddModList->list.count;i++) { + ind = measConfig->reportConfigToAddModList->list.array[i]->reportConfigId; + if (UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1]) { + LOG_I(RRC,"Modifying Report Configuration %d\n",ind-1); + memcpy((char*)UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1], + (char*)measConfig->reportConfigToAddModList->list.array[i], + sizeof(ReportConfigToAddMod_t)); + } + else { + LOG_D(RRC,"Adding Report Configuration %d %p \n",ind-1,measConfig->reportConfigToAddModList->list.array[i]); + UE_rrc_inst[Mod_id].ReportConfig[eNB_index][ind-1] = measConfig->reportConfigToAddModList->list.array[i]; + } } - } } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]) { - LOG_D(RRC,"Modifying Quantity Configuration \n"); - memcpy((char*)UE_rrc_inst[Mod_id].QuantityConfig[eNB_index], - (char*)measConfig->quantityConfig, - sizeof(QuantityConfig_t)); - } - else { - LOG_D(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[Mod_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; - } + if (UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]) { + LOG_D(RRC,"Modifying Quantity Configuration \n"); + memcpy((char*)UE_rrc_inst[Mod_id].QuantityConfig[eNB_index], + (char*)measConfig->quantityConfig, + sizeof(QuantityConfig_t)); + } + else { + LOG_D(RRC,"Adding Quantity configuration\n"); + UE_rrc_inst[Mod_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; + } } if (measConfig->measIdToRemoveList != NULL) { - for (i=0;i<measConfig->measIdToRemoveList->list.count;i++) { - ind = *measConfig->measIdToRemoveList->list.array[i]; - free(UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1]); - } + for (i=0;i<measConfig->measIdToRemoveList->list.count;i++) { + ind = *measConfig->measIdToRemoveList->list.array[i]; + free(UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1]); + } } if (measConfig->measIdToAddModList != NULL) { - for (i=0;i<measConfig->measIdToAddModList->list.count;i++) { - ind = measConfig->measIdToAddModList->list.array[i]->measId; - if (UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1]) { - LOG_D(RRC,"Modifying Measurement ID %d\n",ind-1); - memcpy((char*)UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1], - (char*)measConfig->measIdToAddModList->list.array[i], - sizeof(MeasIdToAddMod_t)); - } - else { - LOG_D(RRC,"Adding Measurement ID %d %p\n",ind-1,measConfig->measIdToAddModList->list.array[i]); - UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; + for (i=0;i<measConfig->measIdToAddModList->list.count;i++) { + ind = measConfig->measIdToAddModList->list.array[i]->measId; + if (UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1]) { + LOG_D(RRC,"Modifying Measurement ID %d\n",ind-1); + memcpy((char*)UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1], + (char*)measConfig->measIdToAddModList->list.array[i], + sizeof(MeasIdToAddMod_t)); + } + else { + LOG_D(RRC,"Adding Measurement ID %d %p\n",ind-1,measConfig->measIdToAddModList->list.array[i]); + UE_rrc_inst[Mod_id].MeasId[eNB_index][ind-1] = measConfig->measIdToAddModList->list.array[i]; + } } - } } if (measConfig->measGapConfig !=NULL) { - if (UE_rrc_inst[Mod_id].measGapConfig[eNB_index]) { - memcpy((char*)UE_rrc_inst[Mod_id].measGapConfig[eNB_index], - (char*)measConfig->measGapConfig, - sizeof(MeasGapConfig_t)); - } - else { - UE_rrc_inst[Mod_id].measGapConfig[eNB_index] = measConfig->measGapConfig; - } + if (UE_rrc_inst[Mod_id].measGapConfig[eNB_index]) { + memcpy((char*)UE_rrc_inst[Mod_id].measGapConfig[eNB_index], + (char*)measConfig->measGapConfig, + sizeof(MeasGapConfig_t)); + } + else { + UE_rrc_inst[Mod_id].measGapConfig[eNB_index] = measConfig->measGapConfig; + } } if (measConfig->quantityConfig != NULL) { - if (UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]) { - LOG_I(RRC,"Modifying Quantity Configuration \n"); - memcpy((char*)UE_rrc_inst[Mod_id].QuantityConfig[eNB_index], - (char*)measConfig->quantityConfig, - sizeof(QuantityConfig_t)); - } - else { - LOG_I(RRC,"Adding Quantity configuration\n"); - UE_rrc_inst[Mod_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; - } - - UE_rrc_inst[Mod_id].filter_coeff_rsrp = 1./pow(2,(*UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); - UE_rrc_inst[Mod_id].filter_coeff_rsrq = 1./pow(2,(*UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); - - LOG_I(RRC,"[UE %d] set rsrp-coeff for eNB %d: %d rsrq-coeff: %d rsrp_factor: %f rsrq_factor: %f \n", - Mod_id, eNB_index, // UE_rrc_inst[Mod_id].Info[eNB_index].UE_index, - *UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, - *UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, - UE_rrc_inst[Mod_id].filter_coeff_rsrp, UE_rrc_inst[Mod_id].filter_coeff_rsrp, - UE_rrc_inst[Mod_id].filter_coeff_rsrp, UE_rrc_inst[Mod_id].filter_coeff_rsrq); + if (UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]) { + LOG_I(RRC,"Modifying Quantity Configuration \n"); + memcpy((char*)UE_rrc_inst[Mod_id].QuantityConfig[eNB_index], + (char*)measConfig->quantityConfig, + sizeof(QuantityConfig_t)); + } + else { + LOG_I(RRC,"Adding Quantity configuration\n"); + UE_rrc_inst[Mod_id].QuantityConfig[eNB_index] = measConfig->quantityConfig; + } + + UE_rrc_inst[Mod_id].filter_coeff_rsrp = 1./pow(2,(*UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP)/4); + UE_rrc_inst[Mod_id].filter_coeff_rsrq = 1./pow(2,(*UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ)/4); + + LOG_I(RRC,"[UE %d] set rsrp-coeff for eNB %d: %d rsrq-coeff: %d rsrp_factor: %f rsrq_factor: %f \n", + Mod_id, eNB_index, // UE_rrc_inst[Mod_id].Info[eNB_index].UE_index, + *UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRP, + *UE_rrc_inst[Mod_id].QuantityConfig[eNB_index]->quantityConfigEUTRA->filterCoefficientRSRQ, + UE_rrc_inst[Mod_id].filter_coeff_rsrp, UE_rrc_inst[Mod_id].filter_coeff_rsrp, + UE_rrc_inst[Mod_id].filter_coeff_rsrp, UE_rrc_inst[Mod_id].filter_coeff_rsrq); } if (measConfig->s_Measure != NULL) { - UE_rrc_inst[Mod_id].s_measure = *measConfig->s_Measure; + UE_rrc_inst[Mod_id].s_measure = *measConfig->s_Measure; } - + if (measConfig->speedStatePars != NULL) { - if (UE_rrc_inst[Mod_id].speedStatePars) - memcpy((char*)UE_rrc_inst[Mod_id].speedStatePars,(char*)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars)); - else - UE_rrc_inst[Mod_id].speedStatePars = measConfig->speedStatePars; - LOG_I(RRC,"[UE %d] Configuring mobility optimization params for UE %d \n", - Mod_id,UE_rrc_inst[Mod_id].Info[0].UE_index); + if (UE_rrc_inst[Mod_id].speedStatePars) + memcpy((char*)UE_rrc_inst[Mod_id].speedStatePars,(char*)measConfig->speedStatePars,sizeof(struct MeasConfig__speedStatePars)); + else + UE_rrc_inst[Mod_id].speedStatePars = measConfig->speedStatePars; + LOG_I(RRC,"[UE %d] Configuring mobility optimization params for UE %d \n", + Mod_id,UE_rrc_inst[Mod_id].Info[0].UE_index); } } void -rrc_ue_process_radioResourceConfigDedicated(u8 Mod_id,u32 frame, u8 eNB_index, - RadioResourceConfigDedicated_t *radioResourceConfigDedicated) { +rrc_ue_process_radioResourceConfigDedicated(module_id_t Mod_id, frame_t frameP, u8 eNB_index, + RadioResourceConfigDedicated_t *radioResourceConfigDedicated) { long SRB_id,DRB_id; int i,cnt; @@ -818,287 +818,287 @@ rrc_ue_process_radioResourceConfigDedicated(u8 Mod_id,u32 frame, u8 eNB_index, // Save physicalConfigDedicated if present if (radioResourceConfigDedicated->physicalConfigDedicated) { - if (UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index]) { - memcpy((char*)UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated, - sizeof(struct PhysicalConfigDedicated)); + if (UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index]) { + memcpy((char*)UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index],(char*)radioResourceConfigDedicated->physicalConfigDedicated, + sizeof(struct PhysicalConfigDedicated)); - } - else { - UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; - } + } + else { + UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index] = radioResourceConfigDedicated->physicalConfigDedicated; + } } // Apply macMainConfig if present if (radioResourceConfigDedicated->mac_MainConfig) { - if (radioResourceConfigDedicated->mac_MainConfig->present == RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue) { - if (UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index]) { - memcpy((char*)UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index],(char*)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue, - sizeof(MAC_MainConfig_t)); + if (radioResourceConfigDedicated->mac_MainConfig->present == RadioResourceConfigDedicated__mac_MainConfig_PR_explicitValue) { + if (UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index]) { + memcpy((char*)UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index],(char*)&radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue, + sizeof(MAC_MainConfig_t)); + } + else + UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index] = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; } - else - UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index] = &radioResourceConfigDedicated->mac_MainConfig->choice.explicitValue; - } } // Apply spsConfig if present if (radioResourceConfigDedicated->sps_Config) { - if (UE_rrc_inst[Mod_id].sps_Config[eNB_index]) { - memcpy(UE_rrc_inst[Mod_id].sps_Config[eNB_index],radioResourceConfigDedicated->sps_Config, - sizeof(struct SPS_Config)); - } - else { - UE_rrc_inst[Mod_id].sps_Config[eNB_index] = radioResourceConfigDedicated->sps_Config; - } + if (UE_rrc_inst[Mod_id].sps_Config[eNB_index]) { + memcpy(UE_rrc_inst[Mod_id].sps_Config[eNB_index],radioResourceConfigDedicated->sps_Config, + sizeof(struct SPS_Config)); + } + else { + UE_rrc_inst[Mod_id].sps_Config[eNB_index] = radioResourceConfigDedicated->sps_Config; + } } #ifdef CBA if (radioResourceConfigDedicated->cba_RNTI_vlola) { - cba_RNTI = (uint16_t) (((radioResourceConfigDedicated->cba_RNTI_vlola->buf[1]&0xff) << 8) | - (radioResourceConfigDedicated->cba_RNTI_vlola->buf[0]&0xff)); - for (i=0 ; i< NUM_MAX_CBA_GROUP; i++) { - if (UE_rrc_inst[Mod_id].cba_rnti[i] == cba_RNTI ) { - cba_found=1; - break; - } else if (UE_rrc_inst[Mod_id].cba_rnti[i] == 0 ) - break; - } - if (cba_found==0) { - UE_rrc_inst[Mod_id].num_active_cba_groups++; - UE_rrc_inst[Mod_id].cba_rnti[i]=cba_RNTI; - LOG_D(RRC, "[UE %d] Frame %d: radioResourceConfigDedicated reveived CBA_RNTI = %x for group %d from eNB %d \n", - Mod_id,frame, UE_rrc_inst[Mod_id].cba_rnti[i], i, eNB_index); - } + cba_RNTI = (uint16_t) (((radioResourceConfigDedicated->cba_RNTI_vlola->buf[1]&0xff) << 8) | + (radioResourceConfigDedicated->cba_RNTI_vlola->buf[0]&0xff)); + for (i=0 ; i< NUM_MAX_CBA_GROUP; i++) { + if (UE_rrc_inst[Mod_id].cba_rnti[i] == cba_RNTI ) { + cba_found=1; + break; + } else if (UE_rrc_inst[Mod_id].cba_rnti[i] == 0 ) + break; + } + if (cba_found==0) { + UE_rrc_inst[Mod_id].num_active_cba_groups++; + UE_rrc_inst[Mod_id].cba_rnti[i]=cba_RNTI; + LOG_D(RRC, "[UE %d] Frame %d: radioResourceConfigDedicated reveived CBA_RNTI = %x for group %d from eNB %d \n", + Mod_id,frameP, UE_rrc_inst[Mod_id].cba_rnti[i], i, eNB_index); + } } #endif // Establish SRBs if present // loop through SRBToAddModList if (radioResourceConfigDedicated->srb_ToAddModList) { - uint8_t *kRRCenc = NULL; - uint8_t *kRRCint = NULL; + uint8_t *kRRCenc = NULL; + uint8_t *kRRCint = NULL; #if defined(ENABLE_SECURITY) - derive_key_rrc_enc(UE_rrc_inst[Mod_id].ciphering_algorithm, - UE_rrc_inst[Mod_id].kenb, &kRRCenc); - derive_key_rrc_int(UE_rrc_inst[Mod_id].integrity_algorithm, - UE_rrc_inst[Mod_id].kenb, &kRRCint); + derive_key_rrc_enc(UE_rrc_inst[Mod_id].ciphering_algorithm, + UE_rrc_inst[Mod_id].kenb, &kRRCenc); + derive_key_rrc_int(UE_rrc_inst[Mod_id].integrity_algorithm, + UE_rrc_inst[Mod_id].kenb, &kRRCint); #endif // Refresh SRBs - rrc_pdcp_config_asn1_req(eNB_index,Mod_id,frame,0, - radioResourceConfigDedicated->srb_ToAddModList, - (DRB_ToAddModList_t*)NULL, - (DRB_ToReleaseList_t*)NULL, - UE_rrc_inst[Mod_id].ciphering_algorithm | - (UE_rrc_inst[Mod_id].integrity_algorithm << 4), - kRRCenc, - kRRCint, - NULL + rrc_pdcp_config_asn1_req(eNB_index,Mod_id,frameP,0, + radioResourceConfigDedicated->srb_ToAddModList, + (DRB_ToAddModList_t*)NULL, + (DRB_ToReleaseList_t*)NULL, + UE_rrc_inst[Mod_id].ciphering_algorithm | + (UE_rrc_inst[Mod_id].integrity_algorithm << 4), + kRRCenc, + kRRCint, + NULL #ifdef Rel10 - ,(PMCH_InfoList_r9_t *)NULL +,(PMCH_InfoList_r9_t *)NULL #endif - ); + ); - // Refresh SRBs - rrc_rlc_config_asn1_req(NB_eNB_INST+Mod_id,frame,0,eNB_index, - radioResourceConfigDedicated->srb_ToAddModList, - (DRB_ToAddModList_t*)NULL, - (DRB_ToReleaseList_t*)NULL + // Refresh SRBs + rrc_rlc_config_asn1_req(eNB_index,Mod_id,frameP,0, + radioResourceConfigDedicated->srb_ToAddModList, + (DRB_ToAddModList_t*)NULL, + (DRB_ToReleaseList_t*)NULL #ifdef Rel10 - ,(PMCH_InfoList_r9_t *)NULL + ,(PMCH_InfoList_r9_t *)NULL #endif - ); + ); - for (cnt=0;cnt<radioResourceConfigDedicated->srb_ToAddModList->list.count;cnt++) { + for (cnt=0;cnt<radioResourceConfigDedicated->srb_ToAddModList->list.count;cnt++) { - SRB_id = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]->srb_Identity; - LOG_D(RRC,"[UE %d]: Frame %d SRB config cnt %d (SRB%ld)\n",Mod_id,frame,cnt,SRB_id); - if (SRB_id == 1) { - if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]) { - memcpy(UE_rrc_inst[Mod_id].SRB1_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], - sizeof(struct SRB_ToAddMod)); - } - else { - UE_rrc_inst[Mod_id].SRB1_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; + SRB_id = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]->srb_Identity; + LOG_D(RRC,"[UE %d]: Frame %d SRB config cnt %d (SRB%ld)\n",Mod_id,frameP,cnt,SRB_id); + if (SRB_id == 1) { + if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]) { + memcpy(UE_rrc_inst[Mod_id].SRB1_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], + sizeof(struct SRB_ToAddMod)); + } + else { + UE_rrc_inst[Mod_id].SRB1_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; - rrc_ue_establish_srb1(Mod_id,frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig) { - if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { - SRB1_logicalChannelConfig = &UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue; - } - else { - SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; - } - } - else { - SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; - } + rrc_ue_establish_srb1(Mod_id,frameP,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); + if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig) { + if (UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { + SRB1_logicalChannelConfig = &UE_rrc_inst[Mod_id].SRB1_config[eNB_index]->logicalChannelConfig->choice.explicitValue; + } + else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } + } + else { + SRB1_logicalChannelConfig = &SRB1_logicalChannelConfig_defaultValue; + } - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], - (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], - 1, - SRB1_logicalChannelConfig, - (MeasGapConfig_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, Mod_id, eNB_index, Mod_id); + rrc_mac_config_req(Mod_id,0,0,eNB_index, + (RadioResourceConfigCommonSIB_t *)NULL, + UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], + (MeasObjectToAddMod_t **)NULL, + UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], + 1, + SRB1_logicalChannelConfig, + (MeasGapConfig_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL #ifdef Rel10 - , - 0, - (MBSFN_AreaInfoList_r9_t *)NULL, - (PMCH_InfoList_r9_t *)NULL + , + 0, + (MBSFN_AreaInfoList_r9_t *)NULL, + (PMCH_InfoList_r9_t *)NULL #endif #ifdef CBA - , - 0, - 0 + , + 0, + 0 #endif - ); - } - } - else { - if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]) { - memcpy(UE_rrc_inst[Mod_id].SRB2_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], - sizeof(struct SRB_ToAddMod)); - } - else { - - UE_rrc_inst[Mod_id].SRB2_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; - - rrc_ue_establish_srb2(Mod_id,frame,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); - if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig) { - if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue){ - LOG_I(RRC,"Applying Explicit SRB2 logicalChannelConfig\n"); - SRB2_logicalChannelConfig = &UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig->choice.explicitValue; - } - else { - LOG_I(RRC,"Applying default SRB2 logicalChannelConfig\n"); - SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; - } + ); + } } else { - SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; - } + if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]) { + memcpy(UE_rrc_inst[Mod_id].SRB2_config[eNB_index],radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt], + sizeof(struct SRB_ToAddMod)); + } + else { - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], - (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], - 2, - SRB2_logicalChannelConfig, - UE_rrc_inst[Mod_id].measGapConfig[eNB_index], - (TDD_Config_t *)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + UE_rrc_inst[Mod_id].SRB2_config[eNB_index] = radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]; + + rrc_ue_establish_srb2(Mod_id,frameP,eNB_index,radioResourceConfigDedicated->srb_ToAddModList->list.array[cnt]); + if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig) { + if (UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue){ + LOG_I(RRC,"Applying Explicit SRB2 logicalChannelConfig\n"); + SRB2_logicalChannelConfig = &UE_rrc_inst[Mod_id].SRB2_config[eNB_index]->logicalChannelConfig->choice.explicitValue; + } + else { + LOG_I(RRC,"Applying default SRB2 logicalChannelConfig\n"); + SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; + } + } + else { + SRB2_logicalChannelConfig = &SRB2_logicalChannelConfig_defaultValue; + } + + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, Mod_id, eNB_index, Mod_id); + rrc_mac_config_req(Mod_id,0,0,eNB_index, + (RadioResourceConfigCommonSIB_t *)NULL, + UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], + (MeasObjectToAddMod_t **)NULL, + UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], + 2, + SRB2_logicalChannelConfig, + UE_rrc_inst[Mod_id].measGapConfig[eNB_index], + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL #ifdef Rel10 - , - 0, - (MBSFN_AreaInfoList_r9_t *)NULL, - (PMCH_InfoList_r9_t *)NULL +, +0, +(MBSFN_AreaInfoList_r9_t *)NULL, +(PMCH_InfoList_r9_t *)NULL #endif #ifdef CBA - , - 0, - 0 +, +0, +0 #endif - ); - } + ); + } + } } - } } // Establish DRBs if present if (radioResourceConfigDedicated->drb_ToAddModList) { - uint8_t *kUPenc = NULL; + uint8_t *kUPenc = NULL; #if defined(ENABLE_SECURITY) - derive_key_up_enc(UE_rrc_inst[Mod_id].integrity_algorithm, - UE_rrc_inst[Mod_id].kenb, &kUPenc); -#endif - - // Refresh DRBs - rrc_pdcp_config_asn1_req(eNB_index, Mod_id,frame,0, - (SRB_ToAddModList_t*)NULL, - radioResourceConfigDedicated->drb_ToAddModList, - (DRB_ToReleaseList_t*)NULL, - UE_rrc_inst[Mod_id].ciphering_algorithm | - (UE_rrc_inst[Mod_id].integrity_algorithm << 4), - NULL, - NULL, - kUPenc + derive_key_up_enc(UE_rrc_inst[Mod_id].integrity_algorithm, + UE_rrc_inst[Mod_id].kenb, &kUPenc); +#endif + + // Refresh DRBs + rrc_pdcp_config_asn1_req(eNB_index, Mod_id,frameP,0, + (SRB_ToAddModList_t*)NULL, + radioResourceConfigDedicated->drb_ToAddModList, + (DRB_ToReleaseList_t*)NULL, + UE_rrc_inst[Mod_id].ciphering_algorithm | + (UE_rrc_inst[Mod_id].integrity_algorithm << 4), + NULL, + NULL, + kUPenc #ifdef Rel10 - ,(PMCH_InfoList_r9_t *)NULL +,(PMCH_InfoList_r9_t *)NULL #endif - ); + ); - // Refresh DRBs - rrc_rlc_config_asn1_req(NB_eNB_INST+Mod_id,frame,0,eNB_index, - (SRB_ToAddModList_t*)NULL, - radioResourceConfigDedicated->drb_ToAddModList, - (DRB_ToReleaseList_t*)NULL + // Refresh DRBs + rrc_rlc_config_asn1_req(eNB_index,Mod_id,frameP,0, + (SRB_ToAddModList_t*)NULL, + radioResourceConfigDedicated->drb_ToAddModList, + (DRB_ToReleaseList_t*)NULL #ifdef Rel10 - ,(PMCH_InfoList_r9_t *)NULL -#endif - ); - for (i=0;i<radioResourceConfigDedicated->drb_ToAddModList->list.count;i++) { - DRB_id = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity-1; - if (UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]) { - memcpy(UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id],radioResourceConfigDedicated->drb_ToAddModList->list.array[i], - sizeof(struct DRB_ToAddMod)); - } - else { - UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id] = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]; - - rrc_ue_establish_drb(Mod_id,frame,eNB_index,radioResourceConfigDedicated->drb_ToAddModList->list.array[i]); - // MAC/PHY Configuration - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB %d eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, eNB_index, Mod_id); - rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], - (MeasObjectToAddMod_t **)NULL, - UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], - *UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity, - UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig, - UE_rrc_inst[Mod_id].measGapConfig[eNB_index], - (TDD_Config_t*)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + ,(PMCH_InfoList_r9_t *)NULL +#endif + ); + for (i=0;i<radioResourceConfigDedicated->drb_ToAddModList->list.count;i++) { + DRB_id = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity-1; + if (UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]) { + memcpy(UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id],radioResourceConfigDedicated->drb_ToAddModList->list.array[i], + sizeof(struct DRB_ToAddMod)); + } + else { + UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id] = radioResourceConfigDedicated->drb_ToAddModList->list.array[i]; + + rrc_ue_establish_drb(Mod_id,frameP,eNB_index,radioResourceConfigDedicated->drb_ToAddModList->list.array[i]); + // MAC/PHY Configuration + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (DRB %d eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, Mod_id, radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity, eNB_index, Mod_id); + rrc_mac_config_req(Mod_id,0,0,eNB_index, + (RadioResourceConfigCommonSIB_t *)NULL, + UE_rrc_inst[Mod_id].physicalConfigDedicated[eNB_index], + (MeasObjectToAddMod_t **)NULL, + UE_rrc_inst[Mod_id].mac_MainConfig[eNB_index], + *UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]->logicalChannelIdentity, + UE_rrc_inst[Mod_id].DRB_config[eNB_index][DRB_id]->logicalChannelConfig, + UE_rrc_inst[Mod_id].measGapConfig[eNB_index], + (TDD_Config_t*)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL #ifdef Rel10 - , - 0, - (MBSFN_AreaInfoList_r9_t *)NULL, - (PMCH_InfoList_r9_t *)NULL +, +0, +(MBSFN_AreaInfoList_r9_t *)NULL, +(PMCH_InfoList_r9_t *)NULL #endif #ifdef CBA - , - UE_rrc_inst[Mod_id].num_active_cba_groups, // - UE_rrc_inst[Mod_id].cba_rnti[0] +, +UE_rrc_inst[Mod_id].num_active_cba_groups, // +UE_rrc_inst[Mod_id].cba_rnti[0] #endif - ); + ); + } } - } } UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_CONNECTED; @@ -1107,7 +1107,7 @@ rrc_ue_process_radioResourceConfigDedicated(u8 Mod_id,u32 frame, u8 eNB_index, } -void rrc_ue_process_securityModeCommand(uint8_t Mod_id,uint32_t frame,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index) { +void rrc_ue_process_securityModeCommand(uint8_t Mod_id, frame_t frameP,SecurityModeCommand_t *securityModeCommand,uint8_t eNB_index) { asn_enc_rval_t enc_rval; @@ -1115,9 +1115,9 @@ void rrc_ue_process_securityModeCommand(uint8_t Mod_id,uint32_t frame,SecurityMo // SecurityModeCommand_t SecurityModeCommand; uint8_t buffer[200]; int i, securityMode; - + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing securityModeCommand (eNB %d)\n", - Mod_id,frame,eNB_index); + Mod_id,frameP,eNB_index); switch (securityModeCommand->criticalExtensions.choice.c1.choice.securityModeCommand_r8.securityConfigSMC.securityAlgorithmConfig.cipheringAlgorithm){ case SecurityAlgorithmConfig__cipheringAlgorithm_eea0: @@ -1165,60 +1165,60 @@ void rrc_ue_process_securityModeCommand(uint8_t Mod_id,uint32_t frame,SecurityMo ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeComplete; else ul_dcch_msg.message.choice.c1.present = UL_DCCH_MessageType__c1_PR_securityModeFailure; - + if (securityModeCommand->criticalExtensions.present == SecurityModeCommand__criticalExtensions_PR_c1) { - if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { - - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; - ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; - - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", - Mod_id,frame,eNB_index); - - enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, - (void*)&ul_dcch_msg, - buffer, - 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %d)!\n", - enc_rval.failed_type->name, enc_rval.encoded); + if (securityModeCommand->criticalExtensions.choice.c1.present == SecurityModeCommand__criticalExtensions__c1_PR_securityModeCommand_r8) { + + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.rrc_TransactionIdentifier = securityModeCommand->rrc_TransactionIdentifier; + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.present = SecurityModeCommand__criticalExtensions_PR_c1; + ul_dcch_msg.message.choice.c1.choice.securityModeComplete.criticalExtensions.choice.securityModeComplete_r8.nonCriticalExtension =NULL; + + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), encoding securityModeComplete (eNB %d)\n", + Mod_id,frameP,eNB_index); + + enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, + (void*)&ul_dcch_msg, + buffer, + 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %d)!\n", + enc_rval.failed_type->name, enc_rval.encoded); #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); + xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); #endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) - { - char message_string[20000]; - size_t message_string_size; + { + char message_string[20000]; + size_t message_string_size; - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) - { - MessageDef *msg_p; + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); - } - } + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } + } # endif #endif #ifdef USER_MODE - LOG_D(RRC, "securityModeComplete Encoded %d bits (%d bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); + LOG_D(RRC, "securityModeComplete Encoded %d bits (%d bytes)\n", enc_rval.encoded, (enc_rval.encoded+7)/8); #endif - for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) - LOG_T(RRC, "%02x.", buffer[i]); - LOG_T(RRC, "\n"); - pdcp_rrc_data_req (eNB_index, Mod_id, frame, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); - } + for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) + LOG_T(RRC, "%02x.", buffer[i]); + LOG_T(RRC, "\n"); + pdcp_rrc_data_req (eNB_index, Mod_id, frameP, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); + } } - + } -void rrc_ue_process_ueCapabilityEnquiry(uint8_t Mod_id,uint32_t frame,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index) { +void rrc_ue_process_ueCapabilityEnquiry(uint8_t Mod_id, frame_t frameP,UECapabilityEnquiry_t *UECapabilityEnquiry,uint8_t eNB_index) { asn_enc_rval_t enc_rval; @@ -1231,7 +1231,7 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t Mod_id,uint32_t frame,UECapabili int i; LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing UECapabilityEnquiry (eNB %d)\n", - Mod_id,frame,eNB_index); + Mod_id,frameP,eNB_index); memset((void *)&ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); @@ -1247,155 +1247,155 @@ void rrc_ue_process_ueCapabilityEnquiry(uint8_t Mod_id,uint32_t frame,UECapabili UE_rrc_inst[Mod_id].UECapability_size); // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.buf = UE_rrc_inst[Mod_id].UECapability; // ue_CapabilityRAT_Container.ueCapabilityRAT_Container.size = UE_rrc_inst[Mod_id].UECapability_size; - + if (UECapabilityEnquiry->criticalExtensions.present == UECapabilityEnquiry__criticalExtensions_PR_c1) { - if (UECapabilityEnquiry->criticalExtensions.choice.c1.present == UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) { - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; - ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count=0; + if (UECapabilityEnquiry->criticalExtensions.choice.c1.present == UECapabilityEnquiry__criticalExtensions__c1_PR_ueCapabilityEnquiry_r8) { + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.present = UECapabilityInformation__criticalExtensions_PR_c1; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.present = UECapabilityInformation__criticalExtensions__c1_PR_ueCapabilityInformation_r8; + ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list.count=0; - for (i=0;i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count;i++) { + for (i=0;i<UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.count;i++) { - if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] - == RAT_Type_eutra) { - ASN_SEQUENCE_ADD( - &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, - &ue_CapabilityRAT_Container); + if (*UECapabilityEnquiry->criticalExtensions.choice.c1.choice.ueCapabilityEnquiry_r8.ue_CapabilityRequest.list.array[i] + == RAT_Type_eutra) { + ASN_SEQUENCE_ADD( + &ul_dcch_msg.message.choice.c1.choice.ueCapabilityInformation.criticalExtensions.choice.c1.choice.ueCapabilityInformation_r8.ue_CapabilityRAT_ContainerList.list, + &ue_CapabilityRAT_Container); - enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, 100); - AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %d)!\n", - enc_rval.failed_type->name, enc_rval.encoded); + enc_rval = uper_encode_to_buffer(&asn_DEF_UL_DCCH_Message, (void*) &ul_dcch_msg, buffer, 100); + AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %d)!\n", + enc_rval.failed_type->name, enc_rval.encoded); #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); + xer_fprint(stdout, &asn_DEF_UL_DCCH_Message, (void*)&ul_dcch_msg); #endif #if defined(ENABLE_ITTI) # if !defined(DISABLE_XER_SPRINT) - { - char message_string[20000]; - size_t message_string_size; + { + char message_string[20000]; + size_t message_string_size; - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) - { - MessageDef *msg_p; + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_UL_DCCH_Message, (void *) &ul_dcch_msg)) > 0) + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_UL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_ul_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_ul_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); - } - } + itti_send_msg_to_task(TASK_UNKNOWN, NB_eNB_INST + Mod_id, msg_p); + } + } # endif #endif #ifdef USER_MODE - LOG_D(RRC,"UECapabilityInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); + LOG_D(RRC,"UECapabilityInformation Encoded %d bits (%d bytes)\n",enc_rval.encoded,(enc_rval.encoded+7)/8); #endif - for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) - LOG_T(RRC, "%02x.", buffer[i]); - LOG_T(RRC, "\n"); - pdcp_rrc_data_req (eNB_index, Mod_id, frame, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); - } + for (i = 0; i < (enc_rval.encoded + 7) / 8; i++) + LOG_T(RRC, "%02x.", buffer[i]); + LOG_T(RRC, "\n"); + pdcp_rrc_data_req (eNB_index, Mod_id, frameP, 0, DCCH, rrc_mui++, 0, (enc_rval.encoded + 7) / 8, buffer, 1); + } + } } - } } } -void rrc_ue_process_rrcConnectionReconfiguration(u8 Mod_id, u32 frame, - RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, - u8 eNB_index) { +void rrc_ue_process_rrcConnectionReconfiguration(module_id_t Mod_id, frame_t frameP, + RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, + u8 eNB_index) { - LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n", - Mod_id,frame,eNB_index); - if (rrcConnectionReconfiguration->criticalExtensions.present == RRCConnectionReconfiguration__criticalExtensions_PR_c1) { - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == - RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { - RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 = &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; + LOG_I(RRC,"[UE %d] Frame %d: Receiving from SRB1 (DL-DCCH), Processing RRCConnectionReconfiguration (eNB %d)\n", + Mod_id,frameP,eNB_index); + if (rrcConnectionReconfiguration->criticalExtensions.present == RRCConnectionReconfiguration__criticalExtensions_PR_c1) { + if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == + RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { + RRCConnectionReconfiguration_r8_IEs_t *rrcConnectionReconfiguration_r8 = &rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8; - if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { - LOG_I(RRC,"Mobility Control Information is present\n"); - rrc_ue_process_mobilityControlInfo(Mod_id, eNB_index, frame, rrcConnectionReconfiguration_r8->mobilityControlInfo); - } - if (rrcConnectionReconfiguration_r8->measConfig != NULL) { - LOG_I(RRC,"Measurement Configuration is present\n"); - rrc_ue_process_measConfig(Mod_id,frame, eNB_index, - rrcConnectionReconfiguration_r8->measConfig); - } - if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { - LOG_I(RRC,"Radio Resource Configuration is present\n"); - rrc_ue_process_radioResourceConfigDedicated(Mod_id,frame,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); - } + if (rrcConnectionReconfiguration_r8->mobilityControlInfo) { + LOG_I(RRC,"Mobility Control Information is present\n"); + rrc_ue_process_mobilityControlInfo(Mod_id, eNB_index, frameP, rrcConnectionReconfiguration_r8->mobilityControlInfo); + } + if (rrcConnectionReconfiguration_r8->measConfig != NULL) { + LOG_I(RRC,"Measurement Configuration is present\n"); + rrc_ue_process_measConfig(Mod_id,frameP, eNB_index, + rrcConnectionReconfiguration_r8->measConfig); + } + if (rrcConnectionReconfiguration_r8->radioResourceConfigDedicated) { + LOG_I(RRC,"Radio Resource Configuration is present\n"); + rrc_ue_process_radioResourceConfigDedicated(Mod_id,frameP,eNB_index, rrcConnectionReconfiguration_r8->radioResourceConfigDedicated); + } #if defined(ENABLE_ITTI) - /* Check if there is dedicated NAS information to forward to NAS */ - if (rrcConnectionReconfiguration_r8->dedicatedInfoNASList != NULL) { - int list_count; - uint32_t pdu_length; - uint8_t *pdu_buffer; - MessageDef *msg_p; + /* Check if there is dedicated NAS information to forward to NAS */ + if (rrcConnectionReconfiguration_r8->dedicatedInfoNASList != NULL) { + int list_count; + uint32_t pdu_length; + uint8_t *pdu_buffer; + MessageDef *msg_p; - for (list_count = 0; list_count < rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.count; list_count++) { - pdu_length = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->size; - pdu_buffer = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->buf; + for (list_count = 0; list_count < rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.count; list_count++) { + pdu_length = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->size; + pdu_buffer = rrcConnectionReconfiguration_r8->dedicatedInfoNASList->list.array[list_count]->buf; - msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_ESTABLI_CNF); - NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS; - NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length; - NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer; + msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_ESTABLI_CNF); + NAS_CONN_ESTABLI_CNF(msg_p).errCode = AS_SUCCESS; + NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.length = pdu_length; + NAS_CONN_ESTABLI_CNF(msg_p).nasMsg.data = pdu_buffer; - itti_send_msg_to_task(TASK_NAS_UE, Mod_id, msg_p); - } + itti_send_msg_to_task(TASK_NAS_UE, Mod_id, msg_p); + } - free (rrcConnectionReconfiguration_r8->dedicatedInfoNASList); - } + free (rrcConnectionReconfiguration_r8->dedicatedInfoNASList); + } #ifdef ENABLE_RAL - { - MessageDef *message_ral_p = NULL; - rrc_ral_connection_reestablishment_ind_t connection_reestablishment_ind; - int i; - - message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_REESTABLISHMENT_IND); - memset(&connection_reestablishment_ind, 0, sizeof(rrc_ral_connection_reestablishment_ind_t)); - // TO DO ral_si_ind.plmn_id = 0; - connection_reestablishment_ind.ue_id = Mod_id; - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { - connection_reestablishment_ind.num_drb = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; - - for (i=0;(i<rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { - // why minus 1 in RRC code for drb_identity ? - connection_reestablishment_ind.drb_id[i] = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; - } - } else { - connection_reestablishment_ind.num_drb = 0; - } - if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { - connection_reestablishment_ind.num_srb = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; - } else { - connection_reestablishment_ind.num_srb = 0; + { + MessageDef *message_ral_p = NULL; + rrc_ral_connection_reestablishment_ind_t connection_reestablishment_ind; + int i; + + message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_REESTABLISHMENT_IND); + memset(&connection_reestablishment_ind, 0, sizeof(rrc_ral_connection_reestablishment_ind_t)); + // TO DO ral_si_ind.plmn_id = 0; + connection_reestablishment_ind.ue_id = Mod_id; + if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { + connection_reestablishment_ind.num_drb = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; + + for (i=0;(i<rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { + // why minus 1 in RRC code for drb_identity ? + connection_reestablishment_ind.drb_id[i] = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; } - memcpy (&message_ral_p->ittiMsg, (void *) &connection_reestablishment_ind, sizeof(rrc_ral_connection_reestablishment_ind_t)); - //#warning "Mod_id ? for instance ? => YES" - LOG_I(RRC, "Sending RRC_RAL_CONNECTION_REESTABLISHMENT_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); + } else { + connection_reestablishment_ind.num_drb = 0; } + if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { + connection_reestablishment_ind.num_srb = rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; + } else { + connection_reestablishment_ind.num_srb = 0; + } + memcpy (&message_ral_p->ittiMsg, (void *) &connection_reestablishment_ind, sizeof(rrc_ral_connection_reestablishment_ind_t)); + //#warning "Mod_id ? for instance ? => YES" + LOG_I(RRC, "Sending RRC_RAL_CONNECTION_REESTABLISHMENT_IND to mRAL\n"); + itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); + } #endif #endif - } // c1 present - } // critical extensions present + } // c1 present + } // critical extensions present } /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover) */ -void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struct MobilityControlInfo *mobilityControlInfo) +void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, frame_t frameP, struct MobilityControlInfo *mobilityControlInfo) { - u8 Mod_id = NB_eNB_INST + UE_id; + module_id_t Mod_id = UE_id; /* DRB_ToReleaseList_t* drb2release_list; DRB_Identity_t *lcid; - */ + */ LOG_N(RRC,"Note: This function needs some updates\n"); if(UE_rrc_inst[UE_id].Info[eNB_index].T310_active == 1) UE_rrc_inst[UE_id].Info[eNB_index].T310_active = 0; @@ -1409,20 +1409,20 @@ void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struc { ASN_SEQUENCE_ADD (&(drb2release_list)->list,lcid); } - */ + */ //Removing SRB1 and SRB2 and DRB0 LOG_N(RRC,"[UE %d] : Update needed for rrc_pdcp_config_req (deprecated) and rrc_rlc_config_req commands(deprecated)\n", UE_id); - rrc_pdcp_config_req (eNB_index, UE_id, frame, 0, ACTION_REMOVE, DCCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(Mod_id,frame,0,ACTION_REMOVE,Mod_id+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + rrc_pdcp_config_req (eNB_index, UE_id, frameP, 0, ACTION_REMOVE, DCCH,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(eNB_index, Mod_id,frameP,0,ACTION_REMOVE,Mod_id+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - rrc_pdcp_config_req (eNB_index, UE_id, frame, 0, ACTION_REMOVE, DCCH1,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(Mod_id,frame,0,ACTION_REMOVE,Mod_id+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + rrc_pdcp_config_req (eNB_index, UE_id, frameP, 0, ACTION_REMOVE, DCCH1,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(eNB_index, Mod_id,frameP,0,ACTION_REMOVE,Mod_id+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - rrc_pdcp_config_req (eNB_index, UE_id, frame, 0, ACTION_REMOVE, DTCH,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(Mod_id,frame,0,ACTION_REMOVE,Mod_id+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); + rrc_pdcp_config_req (eNB_index, UE_id, frameP, 0, ACTION_REMOVE, DTCH,UNDEF_SECURITY_MODE); + rrc_rlc_config_req(eNB_index, Mod_id,frameP,0,ACTION_REMOVE,Mod_id+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); /* - rrc_pdcp_config_asn1_req(NB_eNB_INST+Mod_id,frame, 0,eNB_index, + rrc_pdcp_config_asn1_req(NB_eNB_INST+Mod_id,frameP, 0,eNB_index, NULL, // SRB_ToAddModList NULL, // DRB_ToAddModList drb2release_list, @@ -1434,8 +1434,8 @@ void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struc ,NULL #endif ); - - rrc_rlc_config_asn1_req(NB_eNB_INST+Mod_id, frame,0,eNB_index, + + rrc_rlc_config_asn1_req(NB_eNB_INST+Mod_id, frameP,0,eNB_index, NULL,// SRB_ToAddModList NULL,// DRB_ToAddModList drb2release_list // DRB_ToReleaseList @@ -1444,7 +1444,7 @@ void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struc #endif ); */ - + //A little cleanup at RRC... //Copying current queue config to free RRC index @@ -1452,22 +1452,22 @@ void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struc memcpy((void *)UE_rrc_inst[Mod_id].SRB1_config[~(7<<eNB_index)],(void *)UE_rrc_inst[Mod_id].SRB1_config[7<<eNB_index],sizeof(SRB_ToAddMod_t)); memcpy((void *)UE_rrc_inst[Mod_id].SRB2_config[~(7<<eNB_index)],(void *)UE_rrc_inst[Mod_id].SRB2_config[7<<eNB_index],sizeof(SRB_ToAddMod_t)); memcpy((void *)UE_rrc_inst[Mod_id].DRB_config[~(7<<eNB_index)][0],(void *)UE_rrc_inst[Mod_id].DRB_config[7<<eNB_index][0],sizeof(DRB_ToAddMod_t)); - */ + */ /* LOG_N(RRC,"Not sure if Freeing the current queue config works properly: Fix me\n"); free((void *)&UE_rrc_inst[Mod_id].SRB1_config[eNB_index]); free((void *)&UE_rrc_inst[Mod_id].SRB2_config[eNB_index]); free((void *)&UE_rrc_inst[Mod_id].DRB_config[eNB_index][0]); - + UE_rrc_inst[Mod_id].SRB1_config[eNB_index] = NULL; UE_rrc_inst[Mod_id].SRB2_config[eNB_index] = NULL; UE_rrc_inst[Mod_id].DRB_config[eNB_index][0] = NULL; - */ + */ //Synchronisation to DL of target cell LOG_D(RRC,"HO: Reset PDCP and RLC for configured RBs.. \n[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SRB2 eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - - // Reset MAC and configure PHY + frameP, Mod_id, eNB_index, Mod_id); + + // Reset MAC and configure PHY rrc_mac_config_req(Mod_id,0,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, (struct PhysicalConfigDedicated *)NULL, @@ -1493,28 +1493,28 @@ void rrc_ue_process_mobilityControlInfo(u8 eNB_index, u8 UE_id, u32 frame, struc ,0, 0 #endif - ); - + ); + // Re-establish PDCP for all RBs that are established - // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, Mod_id+DCCH); - // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, Mod_id+DCCH1); - // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frame, 0, ACTION_ADD, Mod_id+DTCH); - - + // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, Mod_id+DCCH); + // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, Mod_id+DCCH1); + // rrc_pdcp_config_req (Mod_id+NB_eNB_INST, frameP, 0, ACTION_ADD, Mod_id+DTCH); + + // Re-establish RLC for all RBs that are established - // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD,Mod_id+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD,Mod_id+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frame,0,ACTION_ADD,Mod_id+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); - + // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD,Mod_id+DCCH,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD,Mod_id+DCCH1,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_rlc_config_req(Mod_id+NB_eNB_INST,frameP,0,ACTION_ADD,Mod_id+DTCH,RADIO_ACCESS_BEARER,Rlc_info_um); + UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_SI_RECEIVED; } -void rrc_detach_from_eNB(u8 Mod_id,u8 eNB_index) { - //UE_rrc_inst[Mod_id].DRB_config[eNB_index] +void rrc_detach_from_eNB(module_id_t Mod_id,u8 eNB_index) { + //UE_rrc_inst[Mod_id].DRB_config[eNB_index] } /*------------------------------------------------------------------------------------------*/ -void rrc_ue_decode_dcch(u8 Mod_id,u32 frame,u8 Srb_id, u8 *Buffer,u8 eNB_index){ +void rrc_ue_decode_dcch(module_id_t Mod_id, frame_t frameP,u8 Srb_id, u8 *Buffer,u8 eNB_index){ /*------------------------------------------------------------------------------------------*/ //DL_DCCH_Message_t dldcchmsg; @@ -1527,9 +1527,9 @@ void rrc_ue_decode_dcch(u8 Mod_id,u32 frame,u8 Srb_id, u8 *Buffer,u8 eNB_index) #endif if (Srb_id != 1) { - LOG_E(RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%d), should not have ...\n", - Mod_id, frame, Srb_id); - return; + LOG_E(RRC,"[UE %d] Frame %d: Received message on DL-DCCH (SRB%d), should not have ...\n", + Mod_id, frameP, Srb_id); + return; } //memset(dl_dcch_msg,0,sizeof(DL_DCCH_Message_t)); @@ -1540,7 +1540,7 @@ void rrc_ue_decode_dcch(u8 Mod_id,u32 frame,u8 Srb_id, u8 *Buffer,u8 eNB_index) for (i=0;i<30;i++) LOG_T(RRC,"%x.",Buffer[i]); LOG_T(RRC, "\n"); - */ + */ uper_decode(NULL, &asn_DEF_DL_DCCH_Message, (void**)&dl_dcch_msg, @@ -1565,229 +1565,229 @@ void rrc_ue_decode_dcch(u8 Mod_id,u32 frame,u8 Srb_id, u8 *Buffer,u8 eNB_index) size_t message_string_size; if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_DL_DCCH_Message, (void *)dl_dcch_msg)) > 0) - { - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); + { + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_DCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_dl_dcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_dl_dcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); + } } # endif #endif if (dl_dcch_msg->message.present == DL_DCCH_MessageType_PR_c1) { - if (UE_rrc_inst[Mod_id].Info[eNB_index].State >= RRC_CONNECTED) { + if (UE_rrc_inst[Mod_id].Info[eNB_index].State >= RRC_CONNECTED) { - switch (dl_dcch_msg->message.choice.c1.present) { + switch (dl_dcch_msg->message.choice.c1.present) { - case DL_DCCH_MessageType__c1_PR_NOTHING: - LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n", Mod_id, frame); - return; + case DL_DCCH_MessageType__c1_PR_NOTHING: + LOG_I(RRC, "[UE %d] Frame %d : Received PR_NOTHING on DL-DCCH-Message\n", Mod_id, frameP); + return; - case DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000: - break; + case DL_DCCH_MessageType__c1_PR_csfbParametersResponseCDMA2000: + break; - case DL_DCCH_MessageType__c1_PR_dlInformationTransfer: { + case DL_DCCH_MessageType__c1_PR_dlInformationTransfer: { #if defined(ENABLE_ITTI) - DLInformationTransfer_t *dlInformationTransfer = &dl_dcch_msg->message.choice.c1.choice.dlInformationTransfer; - - if ((dlInformationTransfer->criticalExtensions.present == DLInformationTransfer__criticalExtensions_PR_c1) - && (dlInformationTransfer->criticalExtensions.choice.c1.present - == DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8) - && (dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.present - == DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) { - /* This message hold a dedicated info NAS payload, forward it to NAS */ - struct DLInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType = - &dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType; - uint32_t pdu_length; - uint8_t *pdu_buffer; - MessageDef *msg_p; - - pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size; - pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf; - - msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND); - NAS_DOWNLINK_DATA_IND(msg_p).UEid = Mod_id; // TODO set the UEid to something else ? - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length; - NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer; + DLInformationTransfer_t *dlInformationTransfer = &dl_dcch_msg->message.choice.c1.choice.dlInformationTransfer; + + if ((dlInformationTransfer->criticalExtensions.present == DLInformationTransfer__criticalExtensions_PR_c1) + && (dlInformationTransfer->criticalExtensions.choice.c1.present + == DLInformationTransfer__criticalExtensions__c1_PR_dlInformationTransfer_r8) + && (dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType.present + == DLInformationTransfer_r8_IEs__dedicatedInfoType_PR_dedicatedInfoNAS)) { + /* This message hold a dedicated info NAS payload, forward it to NAS */ + struct DLInformationTransfer_r8_IEs__dedicatedInfoType *dedicatedInfoType = + &dlInformationTransfer->criticalExtensions.choice.c1.choice.dlInformationTransfer_r8.dedicatedInfoType; + uint32_t pdu_length; + uint8_t *pdu_buffer; + MessageDef *msg_p; - itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); - } + pdu_length = dedicatedInfoType->choice.dedicatedInfoNAS.size; + pdu_buffer = dedicatedInfoType->choice.dedicatedInfoNAS.buf; + + msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_DOWNLINK_DATA_IND); + NAS_DOWNLINK_DATA_IND(msg_p).UEid = Mod_id; // TODO set the UEid to something else ? + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.length = pdu_length; + NAS_DOWNLINK_DATA_IND(msg_p).nasMsg.data = pdu_buffer; + + itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); + } #endif - break; - } + break; + } - case DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest: - break; + case DL_DCCH_MessageType__c1_PR_handoverFromEUTRAPreparationRequest: + break; - case DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand: - break; + case DL_DCCH_MessageType__c1_PR_mobilityFromEUTRACommand: + break; - case DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration: - // first check if mobilityControlInfo is present - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo - != NULL) { - /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover)*/ - if (UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId - != dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId) { - LOG_W(RRC, - "[UE %d] Frame %d: Handover target (%d) is different from RSRP measured target (%d)..\n", Mod_id, frame, dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId, UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId); - return; + case DL_DCCH_MessageType__c1_PR_rrcConnectionReconfiguration: + // first check if mobilityControlInfo is present + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo + != NULL) { + /* 36.331, 5.3.5.4 Reception of an RRCConnectionReconfiguration including the mobilityControlInfo by the UE (handover)*/ + if (UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId + != dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId) { + LOG_W(RRC, + "[UE %d] Frame %d: Handover target (%d) is different from RSRP measured target (%d)..\n", Mod_id, frameP, dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.mobilityControlInfo->targetPhysCellId, UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId); + return; + } + else + if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId)) + == 0xFF) { + LOG_W(RRC, + "[UE %d] Frame %d: Mod_id of the target eNB not found, check the network topology\n", Mod_id, frameP); + return; + } + else { + LOG_I(RRC, + "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n", Mod_id, frameP); + UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required + } } - else - if ((target_eNB_index = get_adjacent_cell_mod_id(UE_rrc_inst[Mod_id].HandoverInfoUe.targetCellId)) - == 0xFF) { - LOG_W(RRC, - "[UE %d] Frame %d: Mod_id of the target eNB not found, check the network topology\n", Mod_id, frame); - return; - } - else { - LOG_I(RRC, - "[UE% d] Frame %d: Received rrcConnectionReconfiguration with mobilityControlInfo \n", Mod_id, frame); - UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; // Ready to send more MeasReports if required - } - } - rrc_ue_process_rrcConnectionReconfiguration(Mod_id, frame, - &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration, eNB_index); - if (target_eNB_index != 0xFF) { - rrc_ue_generate_RRCConnectionReconfigurationComplete(Mod_id, frame, target_eNB_index, - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); - UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_HO_EXECUTION; - UE_rrc_inst[Mod_id].Info[target_eNB_index].State = RRC_RECONFIGURED; - LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", Mod_id, target_eNB_index); + rrc_ue_process_rrcConnectionReconfiguration(Mod_id, frameP, + &dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration, eNB_index); + if (target_eNB_index != 0xFF) { + rrc_ue_generate_RRCConnectionReconfigurationComplete(Mod_id, frameP, target_eNB_index, + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); + UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_HO_EXECUTION; + UE_rrc_inst[Mod_id].Info[target_eNB_index].State = RRC_RECONFIGURED; + LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED during HO (eNB %d)\n", Mod_id, target_eNB_index); #if defined(ENABLE_ITTI) #ifdef ENABLE_RAL - { - MessageDef *message_ral_p = NULL; - rrc_ral_connection_reconfiguration_ho_ind_t connection_reconfiguration_ho_ind; - int i; - - message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND); - memset(&connection_reconfiguration_ho_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); - connection_reconfiguration_ho_ind.ue_id = Mod_id; - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { - connection_reconfiguration_ho_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; - - for (i=0;(i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { - // why minus 1 in RRC code for drb_identity ? - connection_reconfiguration_ho_ind.drb_id[i] = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; - } - } else { - connection_reconfiguration_ho_ind.num_drb = 0; - } - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { - connection_reconfiguration_ho_ind.num_srb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; - } else { - connection_reconfiguration_ho_ind.num_srb = 0; + { + MessageDef *message_ral_p = NULL; + rrc_ral_connection_reconfiguration_ho_ind_t connection_reconfiguration_ho_ind; + int i; + + message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND); + memset(&connection_reconfiguration_ho_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); + connection_reconfiguration_ho_ind.ue_id = Mod_id; + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { + connection_reconfiguration_ho_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; + + for (i=0;(i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { + // why minus 1 in RRC code for drb_identity ? + connection_reconfiguration_ho_ind.drb_id[i] = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; + } + } else { + connection_reconfiguration_ho_ind.num_drb = 0; + } + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { + connection_reconfiguration_ho_ind.num_srb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; + } else { + connection_reconfiguration_ho_ind.num_srb = 0; + } + memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ho_ind, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); + //#warning "Mod_id ? for instance ? => YES" + LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n"); + itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); } - memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ho_ind, sizeof(rrc_ral_connection_reconfiguration_ho_ind_t)); - //#warning "Mod_id ? for instance ? => YES" - LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_HO_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); - } #endif #endif - } - else { - rrc_ue_generate_RRCConnectionReconfigurationComplete(Mod_id, frame, eNB_index, - dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); - UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_RECONFIGURED; - LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", Mod_id, eNB_index); + } + else { + rrc_ue_generate_RRCConnectionReconfigurationComplete(Mod_id, frameP, eNB_index, + dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.rrc_TransactionIdentifier); + UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_RECONFIGURED; + LOG_I(RRC, "[UE %d] State = RRC_RECONFIGURED (eNB %d)\n", Mod_id, eNB_index); #if defined(ENABLE_ITTI) #ifdef ENABLE_RAL - { - MessageDef *message_ral_p = NULL; - rrc_ral_connection_reconfiguration_ind_t connection_reconfiguration_ind; - int i; - - message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_IND); - memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t)); - connection_reconfiguration_ind.ue_id = Mod_id; - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { - connection_reconfiguration_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; - - for (i=0;(i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { - // why minus 1 in RRC code for drb_identity ? - connection_reconfiguration_ind.drb_id[i] = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; - } - } else { - connection_reconfiguration_ind.num_drb = 0; - } - if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { - connection_reconfiguration_ind.num_srb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; - } else { - connection_reconfiguration_ind.num_srb = 0; + { + MessageDef *message_ral_p = NULL; + rrc_ral_connection_reconfiguration_ind_t connection_reconfiguration_ind; + int i; + + message_ral_p = itti_alloc_new_message (TASK_RRC_UE, RRC_RAL_CONNECTION_RECONFIGURATION_IND); + memset(&connection_reconfiguration_ind, 0, sizeof(rrc_ral_connection_reconfiguration_ind_t)); + connection_reconfiguration_ind.ue_id = Mod_id; + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList != NULL) { + connection_reconfiguration_ind.num_drb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count; + + for (i=0;(i<dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.count) && (i < maxDRB);i++) { + // why minus 1 in RRC code for drb_identity ? + connection_reconfiguration_ind.drb_id[i] = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->drb_ToAddModList->list.array[i]->drb_Identity; + } + } else { + connection_reconfiguration_ind.num_drb = 0; + } + if (dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList != NULL) { + connection_reconfiguration_ind.num_srb = dl_dcch_msg->message.choice.c1.choice.rrcConnectionReconfiguration.criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated->srb_ToAddModList->list.count; + } else { + connection_reconfiguration_ind.num_srb = 0; + } + memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t)); + //#warning "Mod_id ? for instance ? => YES" + LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n"); + itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); } - memcpy (&message_ral_p->ittiMsg, (void *) &connection_reconfiguration_ind, sizeof(rrc_ral_connection_reconfiguration_ind_t)); - //#warning "Mod_id ? for instance ? => YES" - LOG_I(RRC, "Sending RRC_RAL_CONNECTION_RECONFIGURATION_IND to mRAL\n"); - itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); - } #endif #endif - } - break; + } + break; - case DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: + case DL_DCCH_MessageType__c1_PR_rrcConnectionRelease: #if defined(ENABLE_ITTI) - msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND); - if ((dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.present - == RRCConnectionRelease__criticalExtensions_PR_c1) - && (dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.present - == RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8)) { - NAS_CONN_RELEASE_IND(msg_p).cause = - dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause; - } + msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CONN_RELEASE_IND); + if ((dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.present + == RRCConnectionRelease__criticalExtensions_PR_c1) + && (dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.present + == RRCConnectionRelease__criticalExtensions__c1_PR_rrcConnectionRelease_r8)) { + NAS_CONN_RELEASE_IND(msg_p).cause = + dl_dcch_msg->message.choice.c1.choice.rrcConnectionRelease.criticalExtensions.choice.c1.choice.rrcConnectionRelease_r8.releaseCause; + } - itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); #if defined(ENABLE_RAL) - msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND); - RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = Mod_id; - itti_send_msg_to_task(TASK_RAL_UE, Mod_id + NB_eNB_INST, msg_p); + msg_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_CONNECTION_RELEASE_IND); + RRC_RAL_CONNECTION_RELEASE_IND(msg_p).ue_id = Mod_id; + itti_send_msg_to_task(TASK_RAL_UE, Mod_id + NB_eNB_INST, msg_p); #endif #endif - break; + break; - case DL_DCCH_MessageType__c1_PR_securityModeCommand: - LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n", Mod_id, eNB_index); - rrc_ue_process_securityModeCommand(Mod_id, frame, &dl_dcch_msg->message.choice.c1.choice.securityModeCommand, - eNB_index); - break; + case DL_DCCH_MessageType__c1_PR_securityModeCommand: + LOG_I(RRC, "[UE %d] Received securityModeCommand (eNB %d)\n", Mod_id, eNB_index); + rrc_ue_process_securityModeCommand(Mod_id, frameP, &dl_dcch_msg->message.choice.c1.choice.securityModeCommand, + eNB_index); + break; - case DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: - LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n", Mod_id, eNB_index); - rrc_ue_process_ueCapabilityEnquiry(Mod_id, frame, &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, - eNB_index); - break; + case DL_DCCH_MessageType__c1_PR_ueCapabilityEnquiry: + LOG_I(RRC, "[UE %d] Received Capability Enquiry (eNB %d)\n", Mod_id, eNB_index); + rrc_ue_process_ueCapabilityEnquiry(Mod_id, frameP, &dl_dcch_msg->message.choice.c1.choice.ueCapabilityEnquiry, + eNB_index); + break; - case DL_DCCH_MessageType__c1_PR_counterCheck: - break; + case DL_DCCH_MessageType__c1_PR_counterCheck: + break; #ifdef Rel10 - case DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9: - break; - case DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10: - break; - case DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10: - break; + case DL_DCCH_MessageType__c1_PR_ueInformationRequest_r9: + break; + case DL_DCCH_MessageType__c1_PR_loggedMeasurementConfiguration_r10: + break; + case DL_DCCH_MessageType__c1_PR_rnReconfiguration_r10: + break; #endif - case DL_DCCH_MessageType__c1_PR_spare1: - case DL_DCCH_MessageType__c1_PR_spare2: - case DL_DCCH_MessageType__c1_PR_spare3: - case DL_DCCH_MessageType__c1_PR_spare4: - break; + case DL_DCCH_MessageType__c1_PR_spare1: + case DL_DCCH_MessageType__c1_PR_spare2: + case DL_DCCH_MessageType__c1_PR_spare3: + case DL_DCCH_MessageType__c1_PR_spare4: + break; - default: - break; + default: + break; + } } - } } #ifndef NO_RRM - send_msg(&S_rrc,msg_rrc_end_scan_req(Mod_id,eNB_index)); + send_msg(&S_rrc,msg_rrc_end_scan_req(Mod_id,eNB_index)); #endif } @@ -1798,7 +1798,7 @@ const char SIBType[16][6] ={"SIB3\0","SIB4\0","SIB5\0","SIB6\0","SIB7\0","SIB8\0 const char SIBPeriod[7][7]= {"80ms\0","160ms\0","320ms\0","640ms\0","1280ms\0","2560ms\0","5120ms\0"}; int siPeriod_int[7] = {80,160,320,640,1280,2560,5120}; -int decode_BCCH_DLSCH_Message(u8 Mod_id,u32 frame,u8 eNB_index,u8 *Sdu,u8 Sdu_len, u8 rsrq, u8 rsrp) { +int decode_BCCH_DLSCH_Message(module_id_t Mod_id, frame_t frameP,u8 eNB_index,u8 *Sdu,u8 Sdu_len, u8 rsrq, u8 rsrp) { //BCCH_DL_SCH_Message_t bcch_message; BCCH_DL_SCH_Message_t *bcch_message=NULL;//_ptr=&bcch_message; @@ -1813,115 +1813,115 @@ int decode_BCCH_DLSCH_Message(u8 Mod_id,u32 frame,u8 eNB_index,u8 *Sdu,u8 Sdu_le if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 1)) { - // Avoid decoding to prevent memory bloating - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); - return 0; + // Avoid decoding to prevent memory bloating + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); + return 0; } else { - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_RECEIVING_SIB); - //memset(&bcch_message,0,sizeof(BCCH_DL_SCH_Message_t)); - // LOG_D(RRC,"[UE %d] Decoding DL_BCCH_DLSCH_Message\n",Mod_id) - /* + //memset(&bcch_message,0,sizeof(BCCH_DL_SCH_Message_t)); + // LOG_D(RRC,"[UE %d] Decoding DL_BCCH_DLSCH_Message\n",Mod_id) + /* for (i=0;i<Sdu_len;i++) printf("%x.",Sdu[i]); printf("\n");*/ - dec_rval = uper_decode_complete(NULL, - &asn_DEF_BCCH_DL_SCH_Message, - (void **)&bcch_message, - (const void *)Sdu, - Sdu_len);//,0,0); - - if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Failed to decode BCCH_DLSCH_MESSAGE (%d bits)\n",Mod_id,dec_rval.consumed); - //free the memory - SEQUENCE_free(&asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message, 1); - vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); - return -1; - } - // xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)&bcch_message); + dec_rval = uper_decode_complete(NULL, + &asn_DEF_BCCH_DL_SCH_Message, + (void **)&bcch_message, + (const void *)Sdu, + Sdu_len);//,0,0); + + if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { + LOG_E(RRC,"[UE %d] Failed to decode BCCH_DLSCH_MESSAGE (%d bits)\n",Mod_id,dec_rval.consumed); + //free the memory + SEQUENCE_free(&asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message, 1); + vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); + return -1; + } + // xer_fprint(stdout, &asn_DEF_BCCH_DL_SCH_Message, (void*)&bcch_message); #if defined(ENABLE_ITTI) # if defined(DISABLE_ITTI_XER_PRINT) - { - MessageDef *msg_p; + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_BCCH_MESSAGE); - memcpy (&msg_p->ittiMsg, (void *) bcch_message, sizeof(RrcDlBcchMessage)); + msg_p = itti_alloc_new_message (TASK_RRC_UE, RRC_DL_BCCH_MESSAGE); + memcpy (&msg_p->ittiMsg, (void *) bcch_message, sizeof(RrcDlBcchMessage)); - itti_send_msg_to_task (TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task (TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); + } # else - { - char message_string[15000]; - size_t message_string_size; - - if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) { - MessageDef *msg_p; + char message_string[15000]; + size_t message_string_size; + + if ((message_string_size = xer_sprint(message_string, sizeof(message_string), &asn_DEF_BCCH_DL_SCH_Message, (void *)bcch_message)) > 0) + { + MessageDef *msg_p; - msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText)); - msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size; - memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size); + msg_p = itti_alloc_new_message_sized (TASK_RRC_UE, RRC_DL_BCCH, message_string_size + sizeof (IttiMsgText)); + msg_p->ittiMsg.rrc_dl_bcch.size = message_string_size; + memcpy(&msg_p->ittiMsg.rrc_dl_bcch.text, message_string, message_string_size); - itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); + itti_send_msg_to_task(TASK_UNKNOWN, Mod_id + NB_eNB_INST, msg_p); + } } - } # endif #endif - if (bcch_message->message.present == BCCH_DL_SCH_MessageType_PR_c1) { - switch (bcch_message->message.choice.c1.present) { - case BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: - if ((frame %2) == 0) { - if (UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 0) { - memcpy((void*)*sib1, - (void*)&bcch_message->message.choice.c1.choice.systemInformationBlockType1, - sizeof(SystemInformationBlockType1_t)); - LOG_D(RRC,"[UE %d] Decoding First SIB1\n",Mod_id); - decode_SIB1(Mod_id, eNB_index, rsrq, rsrp); - //mac_xface->macphy_exit("after decode_SIB1"); + if (bcch_message->message.present == BCCH_DL_SCH_MessageType_PR_c1) { + switch (bcch_message->message.choice.c1.present) { + case BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1: + if ((frameP %2) == 0) { + if (UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 0) { + memcpy((void*)*sib1, + (void*)&bcch_message->message.choice.c1.choice.systemInformationBlockType1, + sizeof(SystemInformationBlockType1_t)); + LOG_D(RRC,"[UE %d] Decoding First SIB1\n",Mod_id); + decode_SIB1(Mod_id, eNB_index, rsrq, rsrp); + //mac_xface->macphy_exit("after decode_SIB1"); + } } - } - break; + break; - case BCCH_DL_SCH_MessageType__c1_PR_systemInformation: - if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 0)) { - // if ((frame %8) == 1) { // check only in odd frames for SI - si_window = (frame%(UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod/10))/(UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize/10); - memcpy((void*)si[si_window], - (void*)&bcch_message->message.choice.c1.choice.systemInformation, - sizeof(SystemInformation_t)); - LOG_D(RRC,"[UE %d] Decoding SI for frame %d, si_window %d\n",Mod_id,frame,si_window); - decode_SI(Mod_id,frame,eNB_index,si_window); - //mac_xface->macphy_exit("after decode_SI"); - - // } - } - break; + case BCCH_DL_SCH_MessageType__c1_PR_systemInformation: + if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && + (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 0)) { + // if ((frameP %8) == 1) { // check only in odd frames for SI + si_window = (frameP%(UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod/10))/(UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize/10); + memcpy((void*)si[si_window], + (void*)&bcch_message->message.choice.c1.choice.systemInformation, + sizeof(SystemInformation_t)); + LOG_D(RRC,"[UE %d] Decoding SI for frameP %d, si_window %d\n",Mod_id,frameP,si_window); + decode_SI(Mod_id,frameP,eNB_index,si_window); + //mac_xface->macphy_exit("after decode_SI"); + + // } + } + break; - case BCCH_DL_SCH_MessageType__c1_PR_NOTHING: - default: - break; + case BCCH_DL_SCH_MessageType__c1_PR_NOTHING: + default: + break; + } } - } } if ((rrc_get_sub_state(Mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) # if defined(ENABLE_USE_MME) -&& (UE_rrc_inst[Mod_id].initialNasMsg.data != NULL) + && (UE_rrc_inst[Mod_id].initialNasMsg.data != NULL) #endif ) { - rrc_ue_generate_RRCConnectionRequest(Mod_id, frame, 0); - LOG_I(RRC, "not sending connection request\n"); + rrc_ue_generate_RRCConnectionRequest(Mod_id, frameP, 0); + LOG_I(RRC, "not sending connection request\n"); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); } /* if ((UE_rrc_inst[Mod_id].Info[eNB_index].SIB1Status == 1) && - (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 1) && (frame >= Mod_id * 20 + 10)) + (UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus == 1) && (frameP >= Mod_id * 20 + 10)) SEQUENCE_free(&asn_DEF_BCCH_DL_SCH_Message, (void*)bcch_message, 0);*/ vcd_signal_dumper_dump_function_by_name(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_DECODE_BCCH, VCD_FUNCTION_OUT); @@ -1929,7 +1929,7 @@ int decode_BCCH_DLSCH_Message(u8 Mod_id,u32 frame,u8 eNB_index,u8 *Sdu,u8 Sdu_le } -int decode_SIB1(u8 Mod_id,u8 eNB_index, u8 rsrq, u8 rsrp) { +int decode_SIB1(module_id_t Mod_id,u8 eNB_index, u8 rsrq, u8 rsrp) { SystemInformationBlockType1_t **sib1=&UE_rrc_inst[Mod_id].sib1[eNB_index]; int i; @@ -1949,29 +1949,29 @@ int decode_SIB1(u8 Mod_id,u8 eNB_index, u8 rsrq, u8 rsrp) { LOG_D(RRC,"freqBandIndicator : %d\n",(int)(*sib1)->freqBandIndicator); LOG_D(RRC,"siWindowLength : %s\n",siWindowLength[(*sib1)->si_WindowLength]); if ((*sib1)->schedulingInfoList.list.count>0) { - for (i=0;i<(*sib1)->schedulingInfoList.list.count;i++) { - LOG_D(RRC,"siSchedulingInfoPeriod[%d] : %s\n",i,SIBPeriod[(int)(*sib1)->schedulingInfoList.list.array[i]->si_Periodicity]); - if ((*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count>0) - LOG_D(RRC,"siSchedulingInfoSIBType[%d] : %s\n",i,SIBType[(int)(*(*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.array[0])]); - else { - LOG_W(RRC,"mapping list %d is null\n",i); + for (i=0;i<(*sib1)->schedulingInfoList.list.count;i++) { + LOG_D(RRC,"siSchedulingInfoPeriod[%d] : %s\n",i,SIBPeriod[(int)(*sib1)->schedulingInfoList.list.array[i]->si_Periodicity]); + if ((*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.count>0) + LOG_D(RRC,"siSchedulingInfoSIBType[%d] : %s\n",i,SIBType[(int)(*(*sib1)->schedulingInfoList.list.array[i]->sib_MappingInfo.list.array[0])]); + else { + LOG_W(RRC,"mapping list %d is null\n",i); + } } - } } else { - LOG_E(RRC,"siSchedulingInfoPeriod[0] : PROBLEM!!!\n"); - return -1; + LOG_E(RRC,"siSchedulingInfoPeriod[0] : PROBLEM!!!\n"); + return -1; } if ((*sib1)->tdd_Config) { - LOG_D(RRC,"TDD subframe assignment : %d\n",(int)(*sib1)->tdd_Config->subframeAssignment); - LOG_D(RRC,"S-Subframe Config : %d\n",(int)(*sib1)->tdd_Config->specialSubframePatterns); + LOG_D(RRC,"TDD subframe assignment : %d\n",(int)(*sib1)->tdd_Config->subframeAssignment); + LOG_D(RRC,"S-Subframe Config : %d\n",(int)(*sib1)->tdd_Config->specialSubframePatterns); } UE_rrc_inst[Mod_id].Info[eNB_index].SIperiod = siPeriod_int[(*sib1)->schedulingInfoList.list.array[0]->si_Periodicity]; UE_rrc_inst[Mod_id].Info[eNB_index].SIwindowsize = siWindowLength_int[(*sib1)->si_WindowLength]; LOG_D(RRC, "[MSC_MSG][FRAME unknown][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB1 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - Mod_id, eNB_index, Mod_id); + Mod_id, eNB_index, Mod_id); rrc_mac_config_req(Mod_id,0,0,eNB_index, (RadioResourceConfigCommonSIB_t *)NULL, @@ -2009,55 +2009,55 @@ int decode_SIB1(u8 Mod_id,u8 eNB_index, u8 rsrq, u8 rsrp) { int cell_valid = 0; if ((*sib1)->cellAccessRelatedInfo.cellBarred == SystemInformationBlockType1__cellAccessRelatedInfo__cellBarred_notBarred) { - /* Cell is not barred */ - int plmn; - int plmn_number; - - plmn_number = (*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list.count; - - /* Compare requested PLMN and PLMNs from SIB1*/ - for (plmn = 0; plmn < plmn_number; plmn++) { - PLMN_Identity_t *plmn_Identity; - - plmn_Identity = &(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list.array[plmn]->plmn_Identity; - if (((plmn_Identity->mcc == NULL) - || - ((UE_rrc_inst[Mod_id].plmnID.MCCdigit1 == *(plmn_Identity->mcc->list.array[0])) && - (UE_rrc_inst[Mod_id].plmnID.MCCdigit2 == *(plmn_Identity->mcc->list.array[1])) && - (UE_rrc_inst[Mod_id].plmnID.MCCdigit3 == *(plmn_Identity->mcc->list.array[2])))) - && - (UE_rrc_inst[Mod_id].plmnID.MNCdigit1 == *(plmn_Identity->mnc.list.array[0])) && - (UE_rrc_inst[Mod_id].plmnID.MNCdigit2 == *(plmn_Identity->mnc.list.array[1])) && - (((UE_rrc_inst[Mod_id].plmnID.MNCdigit3 == 0xf) && (plmn_Identity->mnc.list.count == 2)) - || - (UE_rrc_inst[Mod_id].plmnID.MNCdigit3 == *(plmn_Identity->mnc.list.array[2])))) { - /* PLMN match, send a confirmation to NAS */ - MessageDef *msg_p; - - msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CELL_SELECTION_CNF); - NAS_CELL_SELECTION_CNF (msg_p).errCode = AS_SUCCESS; - NAS_CELL_SELECTION_CNF (msg_p).cellID = BIT_STRING_to_uint32(&(*sib1)->cellAccessRelatedInfo.cellIdentity); - NAS_CELL_SELECTION_CNF (msg_p).tac = BIT_STRING_to_uint16(&(*sib1)->cellAccessRelatedInfo.trackingAreaCode); - NAS_CELL_SELECTION_CNF (msg_p).rat = 0xFF; - NAS_CELL_SELECTION_CNF (msg_p).rsrq = rsrq; - NAS_CELL_SELECTION_CNF (msg_p).rsrp = rsrp; - - itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); - cell_valid = 1; - break; + /* Cell is not barred */ + int plmn; + int plmn_number; + + plmn_number = (*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list.count; + + /* Compare requested PLMN and PLMNs from SIB1*/ + for (plmn = 0; plmn < plmn_number; plmn++) { + PLMN_Identity_t *plmn_Identity; + + plmn_Identity = &(*sib1)->cellAccessRelatedInfo.plmn_IdentityList.list.array[plmn]->plmn_Identity; + if (((plmn_Identity->mcc == NULL) + || + ((UE_rrc_inst[Mod_id].plmnID.MCCdigit1 == *(plmn_Identity->mcc->list.array[0])) && + (UE_rrc_inst[Mod_id].plmnID.MCCdigit2 == *(plmn_Identity->mcc->list.array[1])) && + (UE_rrc_inst[Mod_id].plmnID.MCCdigit3 == *(plmn_Identity->mcc->list.array[2])))) + && + (UE_rrc_inst[Mod_id].plmnID.MNCdigit1 == *(plmn_Identity->mnc.list.array[0])) && + (UE_rrc_inst[Mod_id].plmnID.MNCdigit2 == *(plmn_Identity->mnc.list.array[1])) && + (((UE_rrc_inst[Mod_id].plmnID.MNCdigit3 == 0xf) && (plmn_Identity->mnc.list.count == 2)) + || + (UE_rrc_inst[Mod_id].plmnID.MNCdigit3 == *(plmn_Identity->mnc.list.array[2])))) { + /* PLMN match, send a confirmation to NAS */ + MessageDef *msg_p; + + msg_p = itti_alloc_new_message(TASK_RRC_UE, NAS_CELL_SELECTION_CNF); + NAS_CELL_SELECTION_CNF (msg_p).errCode = AS_SUCCESS; + NAS_CELL_SELECTION_CNF (msg_p).cellID = BIT_STRING_to_uint32(&(*sib1)->cellAccessRelatedInfo.cellIdentity); + NAS_CELL_SELECTION_CNF (msg_p).tac = BIT_STRING_to_uint16(&(*sib1)->cellAccessRelatedInfo.trackingAreaCode); + NAS_CELL_SELECTION_CNF (msg_p).rat = 0xFF; + NAS_CELL_SELECTION_CNF (msg_p).rsrq = rsrq; + NAS_CELL_SELECTION_CNF (msg_p).rsrp = rsrp; + + itti_send_msg_to_task(TASK_NAS_UE, Mod_id + NB_eNB_INST, msg_p); + cell_valid = 1; + break; + } } - } } if (cell_valid == 0) - { - /* Cell can not be used, ask PHY to try the next one */ - MessageDef *msg_p; + { + /* Cell can not be used, ask PHY to try the next one */ + MessageDef *msg_p; - msg_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_NEXT_CELL_REQ); + msg_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_NEXT_CELL_REQ); - itti_send_msg_to_task(TASK_PHY_UE, Mod_id + NB_eNB_INST, msg_p); - } + itti_send_msg_to_task(TASK_PHY_UE, Mod_id + NB_eNB_INST, msg_p); + } } #endif @@ -2165,7 +2165,7 @@ void dump_sib13(SystemInformationBlockType13_r9_t *sib13) { #endif //const char SIBPeriod[7][7]= {"80ms\0","160ms\0","320ms\0","640ms\0","1280ms\0","2560ms\0","5120ms\0"}; -int decode_SI(u8 Mod_id,u32 frame,u8 eNB_index,u8 si_window) { +int decode_SI(module_id_t Mod_id, frame_t frameP,u8 eNB_index,u8 si_window) { SystemInformation_t **si=&UE_rrc_inst[Mod_id].si[eNB_index][si_window]; int i; @@ -2175,66 +2175,66 @@ int decode_SI(u8 Mod_id,u32 frame,u8 eNB_index,u8 si_window) { // Dump contents if ((*si)->criticalExtensions.present==SystemInformation__criticalExtensions_PR_systemInformation_r8) { - LOG_D(RRC,"(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n", - (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count); + LOG_D(RRC,"(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count %d\n", + (*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count); } else { - LOG_D(RRC,"[UE] Unknown criticalExtension version (not Rel8)\n"); - return -1; + LOG_D(RRC,"[UE] Unknown criticalExtension version (not Rel8)\n"); + return -1; } for (i=0;i<(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.count;i++) { - LOG_D(RRC,"SI count %d\n",i); - typeandinfo=(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i]; - - switch(typeandinfo->present) { - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2: - UE_rrc_inst[Mod_id].sib2[eNB_index] = &typeandinfo->choice.sib2; - LOG_D(RRC,"[UE %d] Frame %d Found SIB2 from eNB %d\n",Mod_id,frame,eNB_index); - dump_sib2(UE_rrc_inst[Mod_id].sib2[eNB_index]); - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB2 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - rrc_mac_config_req(Mod_id,0,0,eNB_index, - &UE_rrc_inst[Mod_id].sib2[eNB_index]->radioResourceConfigCommon, - (struct PhysicalConfigDedicated *)NULL, - (MeasObjectToAddMod_t **)NULL, - (MAC_MainConfig_t *)NULL, - 0, - (struct LogicalChannelConfig *)NULL, - (MeasGapConfig_t *)NULL, - (TDD_Config_t *)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq, - UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.ul_Bandwidth, - &UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission, - UE_rrc_inst[Mod_id].sib2[eNB_index]->mbsfn_SubframeConfigList + LOG_D(RRC,"SI count %d\n",i); + typeandinfo=(*si)->criticalExtensions.choice.systemInformation_r8.sib_TypeAndInfo.list.array[i]; + + switch(typeandinfo->present) { + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib2: + UE_rrc_inst[Mod_id].sib2[eNB_index] = &typeandinfo->choice.sib2; + LOG_D(RRC,"[UE %d] Frame %d Found SIB2 from eNB %d\n",Mod_id,frameP,eNB_index); + dump_sib2(UE_rrc_inst[Mod_id].sib2[eNB_index]); + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB2 params eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, Mod_id, eNB_index, Mod_id); + rrc_mac_config_req(Mod_id,0,0,eNB_index, + &UE_rrc_inst[Mod_id].sib2[eNB_index]->radioResourceConfigCommon, + (struct PhysicalConfigDedicated *)NULL, + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 0, + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.ul_CarrierFreq, + UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.ul_Bandwidth, + &UE_rrc_inst[Mod_id].sib2[eNB_index]->freqInfo.additionalSpectrumEmission, + UE_rrc_inst[Mod_id].sib2[eNB_index]->mbsfn_SubframeConfigList #ifdef Rel10 - ,0, - (MBSFN_AreaInfoList_r9_t *)NULL, - (PMCH_InfoList_r9_t *)NULL +,0, +(MBSFN_AreaInfoList_r9_t *)NULL, +(PMCH_InfoList_r9_t *)NULL #endif #ifdef CBA - ,0, - 0 +,0, +0 #endif - ); - UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; - // After SI is received, prepare RRCConnectionRequest + ); + UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; + // After SI is received, prepare RRCConnectionRequest #ifdef Rel10 - if (UE_rrc_inst[Mod_id].MBMS_flag < 3) // see -Q option + if (UE_rrc_inst[Mod_id].MBMS_flag < 3) // see -Q option #endif #if !(defined(ENABLE_ITTI) && defined(ENABLE_USE_MME)) - rrc_ue_generate_RRCConnectionRequest(Mod_id,frame,eNB_index); - LOG_I(RRC, "not sending connection request\n"); + rrc_ue_generate_RRCConnectionRequest(Mod_id,frameP,eNB_index); + LOG_I(RRC, "not sending connection request\n"); #endif - if (UE_rrc_inst[Mod_id].Info[eNB_index].State == RRC_IDLE) { - LOG_I(RRC,"[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n",Mod_id); - UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_SI_RECEIVED; + if (UE_rrc_inst[Mod_id].Info[eNB_index].State == RRC_IDLE) { + LOG_I(RRC,"[UE %d] Received SIB1/SIB2/SIB3 Switching to RRC_SI_RECEIVED\n",Mod_id); + UE_rrc_inst[Mod_id].Info[eNB_index].State = RRC_SI_RECEIVED; #ifdef ENABLE_RAL - { + { MessageDef *message_ral_p = NULL; rrc_ral_system_information_ind_t ral_si_ind; @@ -2257,92 +2257,92 @@ int decode_SI(u8 Mod_id,u32 frame,u8 eNB_index,u8 si_window) { memcpy (&message_ral_p->ittiMsg, (void *) &ral_si_ind, sizeof(rrc_ral_system_information_ind_t)); #warning "Mod_id ? for instance ?" itti_send_msg_to_task (TASK_RAL_UE, Mod_id + NB_eNB_INST, message_ral_p); - } + } #endif - } - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3: - UE_rrc_inst[Mod_id].sib3[eNB_index] = &typeandinfo->choice.sib3; - LOG_I(RRC,"[UE %d] Frame %d Found SIB3 from eNB %d\n",Mod_id,frame,eNB_index); - dump_sib3(UE_rrc_inst[Mod_id].sib3[eNB_index]); - UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; - - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4: - UE_rrc_inst[Mod_id].sib4[eNB_index] = &typeandinfo->choice.sib4; - LOG_I(RRC,"[UE %d] Frame %d Found SIB4 from eNB %d\n",Mod_id,frame,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5: - UE_rrc_inst[Mod_id].sib5[eNB_index] = &typeandinfo->choice.sib5; - LOG_I(RRC,"[UE %d] Found SIB5 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6: - UE_rrc_inst[Mod_id].sib6[eNB_index] = &typeandinfo->choice.sib6; - LOG_I(RRC,"[UE %d] Found SIB6 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7: - UE_rrc_inst[Mod_id].sib7[eNB_index] = &typeandinfo->choice.sib7; - LOG_I(RRC,"[UE %d] Found SIB7 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8: - UE_rrc_inst[Mod_id].sib8[eNB_index] = &typeandinfo->choice.sib8; - LOG_I(RRC,"[UE %d] Found SIB8 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9: - UE_rrc_inst[Mod_id].sib9[eNB_index] = &typeandinfo->choice.sib9; - LOG_I(RRC,"[UE %d] Found SIB9 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10: - UE_rrc_inst[Mod_id].sib10[eNB_index] = &typeandinfo->choice.sib10; - LOG_I(RRC,"[UE %d] Found SIB10 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11: - UE_rrc_inst[Mod_id].sib11[eNB_index] = &typeandinfo->choice.sib11; - LOG_I(RRC,"[UE %d] Found SIB11 from eNB %d\n",Mod_id,eNB_index); - break; + } + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib3: + UE_rrc_inst[Mod_id].sib3[eNB_index] = &typeandinfo->choice.sib3; + LOG_I(RRC,"[UE %d] Frame %d Found SIB3 from eNB %d\n",Mod_id,frameP,eNB_index); + dump_sib3(UE_rrc_inst[Mod_id].sib3[eNB_index]); + UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; + + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SIB_COMPLETE); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib4: + UE_rrc_inst[Mod_id].sib4[eNB_index] = &typeandinfo->choice.sib4; + LOG_I(RRC,"[UE %d] Frame %d Found SIB4 from eNB %d\n",Mod_id,frameP,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib5: + UE_rrc_inst[Mod_id].sib5[eNB_index] = &typeandinfo->choice.sib5; + LOG_I(RRC,"[UE %d] Found SIB5 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib6: + UE_rrc_inst[Mod_id].sib6[eNB_index] = &typeandinfo->choice.sib6; + LOG_I(RRC,"[UE %d] Found SIB6 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib7: + UE_rrc_inst[Mod_id].sib7[eNB_index] = &typeandinfo->choice.sib7; + LOG_I(RRC,"[UE %d] Found SIB7 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib8: + UE_rrc_inst[Mod_id].sib8[eNB_index] = &typeandinfo->choice.sib8; + LOG_I(RRC,"[UE %d] Found SIB8 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib9: + UE_rrc_inst[Mod_id].sib9[eNB_index] = &typeandinfo->choice.sib9; + LOG_I(RRC,"[UE %d] Found SIB9 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib10: + UE_rrc_inst[Mod_id].sib10[eNB_index] = &typeandinfo->choice.sib10; + LOG_I(RRC,"[UE %d] Found SIB10 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib11: + UE_rrc_inst[Mod_id].sib11[eNB_index] = &typeandinfo->choice.sib11; + LOG_I(RRC,"[UE %d] Found SIB11 from eNB %d\n",Mod_id,eNB_index); + break; #ifdef Rel10 - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920: - UE_rrc_inst[Mod_id].sib12[eNB_index] = &typeandinfo->choice.sib12_v920; - LOG_I(RRC,"[RRC][UE %d] Found SIB12 from eNB %d\n",Mod_id,eNB_index); - break; - case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920: - UE_rrc_inst[Mod_id].sib13[eNB_index] = &typeandinfo->choice.sib13_v920; - LOG_I(RRC,"[RRC][UE %d] Found SIB13 from eNB %d\n",Mod_id,eNB_index); - dump_sib13(UE_rrc_inst[Mod_id].sib13[eNB_index]); - // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer - LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB13 params eNB %d) --->][MAC_UE][MOD %02d][]\n", - frame, Mod_id, eNB_index, Mod_id); - rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - (struct PhysicalConfigDedicated *)NULL, - (MeasObjectToAddMod_t **)NULL, - (MAC_MainConfig_t *)NULL, - 0, - (struct LogicalChannelConfig *)NULL, - (MeasGapConfig_t *)NULL, - (TDD_Config_t *)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - (MBSFN_SubframeConfigList_t *)NULL - ,0, - &UE_rrc_inst[Mod_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9, - (PMCH_InfoList_r9_t *)NULL + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib12_v920: + UE_rrc_inst[Mod_id].sib12[eNB_index] = &typeandinfo->choice.sib12_v920; + LOG_I(RRC,"[RRC][UE %d] Found SIB12 from eNB %d\n",Mod_id,eNB_index); + break; + case SystemInformation_r8_IEs_sib_TypeAndInfo_Member_PR_sib13_v920: + UE_rrc_inst[Mod_id].sib13[eNB_index] = &typeandinfo->choice.sib13_v920; + LOG_I(RRC,"[RRC][UE %d] Found SIB13 from eNB %d\n",Mod_id,eNB_index); + dump_sib13(UE_rrc_inst[Mod_id].sib13[eNB_index]); + // adding here function to store necessary parameters for using in decode_MCCH_Message + maybe transfer to PHY layer + LOG_D(RRC, "[MSC_MSG][FRAME %05d][RRC_UE][MOD %02d][][--- MAC_CONFIG_REQ (SIB13 params eNB %d) --->][MAC_UE][MOD %02d][]\n", + frameP, Mod_id, eNB_index, Mod_id); + rrc_mac_config_req(Mod_id,0,0,eNB_index, + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 0, + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (MBSFN_SubframeConfigList_t *)NULL + ,0, + &UE_rrc_inst[Mod_id].sib13[eNB_index]->mbsfn_AreaInfoList_r9, + (PMCH_InfoList_r9_t *)NULL #ifdef CBA - ,0, - 0 +,0, +0 #endif - ); - UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; - break; + ); + UE_rrc_inst[Mod_id].Info[eNB_index].SIStatus = 1; + break; #endif - default: - break; - } + default: + break; + } } @@ -2351,348 +2351,349 @@ int decode_SI(u8 Mod_id,u32 frame,u8 eNB_index,u8 si_window) { } // layer 3 filtering of RSRP (EUTRA) measurements: 36.331, Sec. 5.5.3.2 -void ue_meas_filtering(u8 Mod_id,u32 frame,u8 eNB_index){ - float a = UE_rrc_inst[Mod_id].filter_coeff_rsrp; // 'a' in 36.331 Sec. 5.5.3.2 +void ue_meas_filtering(module_id_t Mod_id, frame_t frameP,u8 eNB_index){ + float a = UE_rrc_inst[Mod_id].filter_coeff_rsrp; // 'a' in 36.331 Sec. 5.5.3.2 float a1 = UE_rrc_inst[Mod_id].filter_coeff_rsrq; //float rsrp_db, rsrq_db; - u8 eNB_offset; + u8 eNB_offset; if(UE_rrc_inst[Mod_id].QuantityConfig[0] != NULL) { // Only consider 1 serving cell (index: 0) - if (UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { - if(UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP != NULL) { - for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { - //filter_factor = 1/power(2,*UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP/4); - // LOG_N(RRC,"[UE %d] Frame %d : check proper operation in abstraction mode rsrp (%d), rx gain (%d) N_RB_DL (%d)\n", - // Mod_id,frame,mac_xface->get_RSRP(Mod_id,eNB_offset),mac_xface->get_rx_total_gain_dB(Mod_id),mac_xface->lte_frame_parms->N_RB_DL); - UE_rrc_inst[Mod_id].rsrp_db[eNB_offset] = (dB_fixed_times10(mac_xface->get_RSRP(Mod_id,eNB_offset))/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12); - UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset] = (1.0-a)*UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset] + a*UE_rrc_inst[Mod_id].rsrp_db[eNB_offset]; - //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); - - LOG_D(RRC,"[UE %d] Frame %d: Meas RSRP: eNB_offset: %d rsrp_coef: %3.2f filter_coef: %d before L3 filtering: rsrp: %3.1f after L3 filtering: rsrp: %3.1f \n ", - Mod_id, frame, eNB_offset,a, - *UE_rrc_inst->QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP, - UE_rrc_inst[Mod_id].rsrp_db[eNB_offset], - UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); - } + if (UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { + if(UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP != NULL) { + for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { + //filter_factor = 1/power(2,*UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP/4); + // LOG_N(RRC,"[UE %d] Frame %d : check proper operation in abstraction mode rsrp (%d), rx gain (%d) N_RB_DL (%d)\n", + // Mod_id,frameP,mac_xface->get_RSRP(Mod_id,eNB_offset),mac_xface->get_rx_total_gain_dB(Mod_id),mac_xface->lte_frame_parms->N_RB_DL); + UE_rrc_inst[Mod_id].rsrp_db[eNB_offset] = (dB_fixed_times10(mac_xface->get_RSRP(Mod_id,eNB_offset))/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12); + UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset] = (1.0-a)*UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset] + a*UE_rrc_inst[Mod_id].rsrp_db[eNB_offset]; + //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); + + LOG_D(RRC,"[UE %d] Frame %d: Meas RSRP: eNB_offset: %d rsrp_coef: %3.2f filter_coef: %d before L3 filtering: rsrp: %3.1f after L3 filtering: rsrp: %3.1f \n ", + Mod_id, frameP, eNB_offset,a, + *UE_rrc_inst->QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRP, + UE_rrc_inst[Mod_id].rsrp_db[eNB_offset], + UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); + } + } } - } - else { - for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { - UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]= mac_xface->get_RSRP(Mod_id,eNB_offset); - // phy_vars_ue->PHY_measurements.rsrp_filtered[eNB_offset]=UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]; - //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); + else { + for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { + UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]= mac_xface->get_RSRP(Mod_id,eNB_offset); + // phy_vars_ue->PHY_measurements.rsrp_filtered[eNB_offset]=UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]; + //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); + } } - } - if (UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { - if(UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ != NULL) { - for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { - // LOG_N(RRC,"[UE %d] Frame %d : check if this operation workes properly in abstraction mode\n",Mod_id,frame); - UE_rrc_inst[Mod_id].rsrq_db[eNB_offset] = (10*log10(mac_xface->get_RSRQ(Mod_id,eNB_offset)))-20; - UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset]=(1-a1)*UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset] + a1 *UE_rrc_inst[Mod_id].rsrq_db[eNB_offset]; - //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); - /* + if (UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA != NULL) { + if(UE_rrc_inst[Mod_id].QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ != NULL) { + for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { + // LOG_N(RRC,"[UE %d] Frame %d : check if this operation workes properly in abstraction mode\n",Mod_id,frameP); + UE_rrc_inst[Mod_id].rsrq_db[eNB_offset] = (10*log10(mac_xface->get_RSRQ(Mod_id,eNB_offset)))-20; + UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset]=(1-a1)*UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset] + a1 *UE_rrc_inst[Mod_id].rsrq_db[eNB_offset]; + //mac_xface->set_RSRP_filtered(Mod_id,eNB_offset,UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]); + /* LOG_D(RRC,"[UE %d] meas RSRQ: eNB_offset: %d rsrq_coef: %3.2f filter_coef: %d before L3 filtering: rsrq: %3.1f after L3 filtering: rsrq: %3.1f \n ", Mod_id, eNB_offset, a1, - *UE_rrc_inst->QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ, + *UE_rrc_inst->QuantityConfig[0]->quantityConfigEUTRA->filterCoefficientRSRQ, mac_xface->get_RSRQ(Mod_id,eNB_offset), UE_rrc_inst[Mod_id].rsrq_db[eNB_offset], UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset]); - */ - } + */ + } + } } - } - else{ - for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { - UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset]= mac_xface->get_RSRQ(Mod_id,eNB_offset); + else{ + for (eNB_offset = 0;eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id);eNB_offset++) { + UE_rrc_inst[Mod_id].rsrq_db_filtered[eNB_offset]= mac_xface->get_RSRQ(Mod_id,eNB_offset); + } } - } } } //Below routine implements Measurement Reporting procedure from 36.331 Section 5.5.5 -void rrc_ue_generate_MeasurementReport(u8 eNB_id, u8 UE_id, u32 frame) { +void rrc_ue_generate_MeasurementReport(u8 eNB_id, u8 UE_id, frame_t frameP) { - u8 buffer[32], size; - u8 i; - u8 target_eNB_offset; - MeasId_t measId; + u8 buffer[32], size; + u8 i; + u8 target_eNB_offset; + MeasId_t measId; PhysCellId_t cellId, targetCellId; - long rsrq_s,rsrp_t,rsrq_t; - long rsrp_s, nElem, nElem1; - float rsrp_filtered, rsrq_filtered; + long rsrq_s,rsrp_t,rsrq_t; + long rsrp_s, nElem, nElem1; + float rsrp_filtered, rsrq_filtered; + static u32 pframe=0; + int result; + nElem = 100; nElem1 = 33; - static u32 pframe=0; - int result; target_eNB_offset = UE_rrc_inst[UE_id].Info[0].handoverTarget; // eNB_offset of target eNB: used to obtain the mod_id of target eNB for (i=0;i<MAX_MEAS_ID;i++) { - if (UE_rrc_inst[UE_id].measReportList[0][i] != NULL) { - measId = UE_rrc_inst[UE_id].measReportList[0][i]->measId; - - // Note: Values in the meas report have to be the mapped values...to implement binary search for LUT - rsrp_filtered = UE_rrc_inst[UE_id].rsrp_db_filtered[eNB_id];//nid_cell]; - rsrp_s = binary_search_float(RSRP_meas_mapping,nElem, rsrp_filtered); //mapped RSRP of serving cell - - rsrq_filtered = UE_rrc_inst[UE_id].rsrq_db_filtered[eNB_id];//nid_cell]; //RSRQ of serving cell - rsrq_s = binary_search_float(RSRQ_meas_mapping,nElem1,rsrp_filtered);//mapped RSRQ of serving cell - - LOG_D(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %d rsrq_s: %d tmp: %f tmp1: %f \n", - UE_id, frame, eNB_id, rsrp_s,rsrq_s,rsrp_filtered,rsrq_filtered); - - rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[UE_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell - rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[UE_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell - - // if (measFlag == 1) { - cellId = get_adjacent_cell_id(UE_id, eNB_id); //PhycellId of serving cell - targetCellId = UE_rrc_inst[UE_id].HandoverInfoUe.targetCellId ;//get_adjacent_cell_id(Mod_id,target_eNB_offset); //PhycellId of target cell - - if (pframe!=frame){ - pframe=frame; - size = do_MeasurementReport(UE_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); - LOG_D(RRC, "[UE %d] Frame %d: Sending MeasReport: servingCell(%d) targetCell(%d) rsrp_s(%d) rsrq_s(%d) rsrp_t(%d) rsrq_t(%d) \n", - UE_id, frame, cellId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); - LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", UE_id, frame, eNB_id); - LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][UE %02d][][--- PDCP_DATA_REQ/%d Bytes (MeasurementReport to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, UE_id, size, eNB_id, rrc_mui, eNB_id, DCCH); - result = pdcp_data_req(eNB_id, UE_id, frame, 0, DCCH, rrc_mui++, 0, size, buffer, 1); - AssertFatal (result == TRUE, "PDCP data request failed!\n"); - //LOG_D(RRC, "[UE %d] Frame %d Sending MeasReport (%d bytes) through DCCH%d to PDCP \n",Mod_id,frame, size, DCCH); + if (UE_rrc_inst[UE_id].measReportList[0][i] != NULL) { + measId = UE_rrc_inst[UE_id].measReportList[0][i]->measId; + + // Note: Values in the meas report have to be the mapped values...to implement binary search for LUT + rsrp_filtered = UE_rrc_inst[UE_id].rsrp_db_filtered[eNB_id];//nid_cell]; + rsrp_s = binary_search_float(RSRP_meas_mapping,nElem, rsrp_filtered); //mapped RSRP of serving cell + + rsrq_filtered = UE_rrc_inst[UE_id].rsrq_db_filtered[eNB_id];//nid_cell]; //RSRQ of serving cell + rsrq_s = binary_search_float(RSRQ_meas_mapping,nElem1,rsrp_filtered);//mapped RSRQ of serving cell + + LOG_D(RRC,"[UE %d] Frame %d: source eNB %d :rsrp_s: %d rsrq_s: %d tmp: %f tmp1: %f \n", + UE_id, frameP, eNB_id, rsrp_s,rsrq_s,rsrp_filtered,rsrq_filtered); + + rsrp_t = binary_search_float(RSRP_meas_mapping,nElem,UE_rrc_inst[UE_id].rsrp_db_filtered[target_eNB_offset]); //RSRP of target cell + rsrq_t = binary_search_float(RSRQ_meas_mapping,nElem1,UE_rrc_inst[UE_id].rsrq_db_filtered[target_eNB_offset]); //RSRQ of target cell + + // if (measFlag == 1) { + cellId = get_adjacent_cell_id(UE_id, eNB_id); //PhycellId of serving cell + targetCellId = UE_rrc_inst[UE_id].HandoverInfoUe.targetCellId ;//get_adjacent_cell_id(Mod_id,target_eNB_offset); //PhycellId of target cell + + if (pframe!=frameP){ + pframe=frameP; + size = do_MeasurementReport(UE_id, buffer,measId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); + LOG_D(RRC, "[UE %d] Frame %d: Sending MeasReport: servingCell(%d) targetCell(%d) rsrp_s(%d) rsrq_s(%d) rsrp_t(%d) rsrq_t(%d) \n", + UE_id, frameP, cellId,targetCellId,rsrp_s,rsrq_s,rsrp_t,rsrq_t); + LOG_I(RRC, "[UE %d] Frame %d : Generating Measurement Report for eNB %d\n", UE_id, frameP, eNB_id); + LOG_D(RLC, "[MSC_MSG][FRAME %05d][RRC_UE][UE %02d][][--- PDCP_DATA_REQ/%d Bytes (MeasurementReport to eNB %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", + frameP, UE_id, size, eNB_id, rrc_mui, eNB_id, DCCH); + result = pdcp_data_req(eNB_id, UE_id, frameP, 0, DCCH, rrc_mui++, 0, size, buffer, 1); + AssertFatal (result == TRUE, "PDCP data request failed!\n"); + //LOG_D(RRC, "[UE %d] Frame %d Sending MeasReport (%d bytes) through DCCH%d to PDCP \n",Mod_id,frameP, size, DCCH); + } + // measFlag = 0; //re-setting measFlag so that no more MeasReports are sent in this frameP + // } } - // measFlag = 0; //re-setting measFlag so that no more MeasReports are sent in this frame - // } - } } } // Measurement report triggering, described in 36.331 Section 5.5.4.1: called periodically -void ue_measurement_report_triggering(u8 Mod_id, u32 frame,u8 eNB_index) { - u8 i,j; - Hysteresis_t hys; - TimeToTrigger_t ttt_ms; - Q_OffsetRange_t ofn; - Q_OffsetRange_t ocn; - Q_OffsetRange_t ofs = 0; - Q_OffsetRange_t ocs = 0; - long a3_offset; - MeasObjectId_t measObjId; +void ue_measurement_report_triggering(module_id_t Mod_id, u32 frameP,u8 eNB_index) { + u8 i,j; + Hysteresis_t hys; + TimeToTrigger_t ttt_ms; + Q_OffsetRange_t ofn; + Q_OffsetRange_t ocn; + Q_OffsetRange_t ofs = 0; + Q_OffsetRange_t ocs = 0; + long a3_offset; + MeasObjectId_t measObjId; ReportConfigId_t reportConfigId; - + for(i=0 ; i<NB_CNX_UE ; i++) { - for(j=0 ; j<MAX_MEAS_ID ; j++) { - if(UE_rrc_inst[Mod_id].MeasId[i][j] != NULL) { - measObjId = UE_rrc_inst[Mod_id].MeasId[i][j]->measObjectId; - reportConfigId = UE_rrc_inst[Mod_id].MeasId[i][j]->reportConfigId; - if( /*UE_rrc_inst[Mod_id].MeasId[i][j] != NULL && */ UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1] != NULL) { - if(UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { - /* consider any neighboring cell detected on the associated frequency to be - * applicable when the concerned cell is not included in the blackCellsToAddModList - * defined within the VarMeasConfig for this measId */ - // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]); - if((UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1] != NULL) && - (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.present==ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && - (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == ReportConfigEUTRA__triggerType_PR_event)) { - hys = UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; - //LOG_N(RRC,"[UE%d] Frame %d Check below lines for segfault :), Fix me \n",Mod_id, frame); - ttt_ms = timeToTrigger_ms[UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger]; - // Freq specific offset of neighbor cell freq - ofn = ((UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? - *UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ - // cellIndividualOffset of neighbor cell - not defined yet - ocn = 0; - a3_offset = UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; - - switch (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { - case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1: - LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n",Mod_id, frame); - break; - case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2: - LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n",Mod_id, frame); - break; - case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3: - LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",Mod_id, frame); - if ((check_trigger_meas_event(Mod_id,frame,eNB_index,i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) && - (UE_rrc_inst[Mod_id].Info[0].State >= RRC_CONNECTED) && - (UE_rrc_inst[Mod_id].Info[0].T304_active == 0 ) && - (UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag == 1)) { - //trigger measurement reporting procedure (36.331, section 5.5.5) - if (UE_rrc_inst[Mod_id].measReportList[i][j] == NULL) { - UE_rrc_inst[Mod_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); - } - UE_rrc_inst[Mod_id].measReportList[i][j]->measId = UE_rrc_inst[Mod_id].MeasId[i][j]->measId; - UE_rrc_inst[Mod_id].measReportList[i][j]->numberOfReportsSent = 0; - rrc_ue_generate_MeasurementReport(Mod_id,frame,eNB_index); - UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; - LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n", Mod_id, frame, UE_rrc_inst[Mod_id].Info[0].State); - } - else { - if(UE_rrc_inst[Mod_id].measReportList[i][j] != NULL){ - free(UE_rrc_inst[Mod_id].measReportList[i][j]); - } - UE_rrc_inst[Mod_id].measReportList[i][j] = NULL; - } - break; - case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4: - LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n",Mod_id, frame); - break; - case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5: - LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n",Mod_id, frame); - break; - default: - LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d", - UE_rrc_inst[Mod_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); - break; + for(j=0 ; j<MAX_MEAS_ID ; j++) { + if(UE_rrc_inst[Mod_id].MeasId[i][j] != NULL) { + measObjId = UE_rrc_inst[Mod_id].MeasId[i][j]->measObjectId; + reportConfigId = UE_rrc_inst[Mod_id].MeasId[i][j]->reportConfigId; + if( /*UE_rrc_inst[Mod_id].MeasId[i][j] != NULL && */ UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1] != NULL) { + if(UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.present == MeasObjectToAddMod__measObject_PR_measObjectEUTRA) { + /* consider any neighboring cell detected on the associated frequency to be + * applicable when the concerned cell is not included in the blackCellsToAddModList + * defined within the VarMeasConfig for this measId */ + // LOG_I(RRC,"event %d %d %p \n", measObjId,reportConfigId, UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]); + if((UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1] != NULL) && + (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.present==ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA) && + (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.present == ReportConfigEUTRA__triggerType_PR_event)) { + hys = UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.hysteresis; + //LOG_N(RRC,"[UE%d] Frame %d Check below lines for segfault :), Fix me \n",Mod_id, frameP); + ttt_ms = timeToTrigger_ms[UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.timeToTrigger]; + // Freq specific offset of neighbor cell freq + ofn = ((UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq != NULL) ? + *UE_rrc_inst[Mod_id].MeasObj[i][measObjId-1]->measObject.choice.measObjectEUTRA.offsetFreq : 15); // /* 15 is the Default */ + // cellIndividualOffset of neighbor cell - not defined yet + ocn = 0; + a3_offset = UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.choice.eventA3.a3_Offset; + + switch (UE_rrc_inst[Mod_id].ReportConfig[i][reportConfigId-1]->reportConfig.choice.reportConfigEUTRA.triggerType.choice.event.eventId.present) { + case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA1: + LOG_D(RRC,"[UE %d] Frame %d : A1 event: check if serving becomes better than threshold\n",Mod_id, frameP); + break; + case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA2: + LOG_D(RRC,"[UE %d] Frame %d : A2 event, check if serving becomes worse than a threshold\n",Mod_id, frameP); + break; + case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA3: + LOG_D(RRC,"[UE %d] Frame %d : A3 event: check if a neighboring cell becomes offset better than serving to trigger a measurement event \n",Mod_id, frameP); + if ((check_trigger_meas_event(Mod_id,frameP,eNB_index,i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms)) && + (UE_rrc_inst[Mod_id].Info[0].State >= RRC_CONNECTED) && + (UE_rrc_inst[Mod_id].Info[0].T304_active == 0 ) && + (UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag == 1)) { + //trigger measurement reporting procedure (36.331, section 5.5.5) + if (UE_rrc_inst[Mod_id].measReportList[i][j] == NULL) { + UE_rrc_inst[Mod_id].measReportList[i][j] = malloc(sizeof(MEAS_REPORT_LIST)); + } + UE_rrc_inst[Mod_id].measReportList[i][j]->measId = UE_rrc_inst[Mod_id].MeasId[i][j]->measId; + UE_rrc_inst[Mod_id].measReportList[i][j]->numberOfReportsSent = 0; + rrc_ue_generate_MeasurementReport(Mod_id,frameP,eNB_index); + UE_rrc_inst[Mod_id].HandoverInfoUe.measFlag = 1; + LOG_I(RRC,"[UE %d] Frame %d: A3 event detected, state: %d \n", Mod_id, frameP, UE_rrc_inst[Mod_id].Info[0].State); + } + else { + if(UE_rrc_inst[Mod_id].measReportList[i][j] != NULL){ + free(UE_rrc_inst[Mod_id].measReportList[i][j]); + } + UE_rrc_inst[Mod_id].measReportList[i][j] = NULL; + } + break; + case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA4: + LOG_D(RRC,"[UE %d] Frame %d : received an A4 event, neighbor becomes offset better than a threshold\n",Mod_id, frameP); + break; + case ReportConfigEUTRA__triggerType__event__eventId_PR_eventA5: + LOG_D(RRC,"[UE %d] Frame %d: received an A5 event, serving becomes worse than threshold 1 and neighbor becomes better than threshold 2\n",Mod_id, frameP); + break; + default: + LOG_D(RRC,"Invalid ReportConfigEUTRA__triggerType__event__eventId: %d", + UE_rrc_inst[Mod_id].ReportConfig[i][j]->reportConfig.choice.reportConfigEUTRA.triggerType.present); + break; + } + } + } } - } } - } } - } } } -//check_trigger_meas_event(Mod_id, frame, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms) -u8 check_trigger_meas_event(u8 Mod_id,u32 frame, u8 eNB_index, u8 ue_cnx_index, u8 meas_index, - Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, - Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt) { +//check_trigger_meas_event(Mod_id, frameP, eNB_index, i,j,ofn,ocn,hys,ofs,ocs,a3_offset,ttt_ms) +u8 check_trigger_meas_event(module_id_t Mod_id,u32 frameP, u8 eNB_index, u8 ue_cnx_index, u8 meas_index, + Q_OffsetRange_t ofn, Q_OffsetRange_t ocn, Hysteresis_t hys, + Q_OffsetRange_t ofs, Q_OffsetRange_t ocs, long a3_offset, TimeToTrigger_t ttt) { u8 eNB_offset; u8 currentCellIndex = mac_xface->lte_frame_parms->Nid_cell; - + LOG_I(RRC,"ofn(%d) ocn(%d) hys(%d) ofs(%d) ocs(%d) a3_offset(%d) ttt(%d) rssi %3.1f\n", \ - ofn,ocn,hys,ofs,ocs,a3_offset,ttt,10*log10(mac_xface->get_RSSI(Mod_id))-mac_xface->get_rx_total_gain_dB(Mod_id)); - + ofn,ocn,hys,ofs,ocs,a3_offset,ttt,10*log10(mac_xface->get_RSSI(Mod_id))-mac_xface->get_rx_total_gain_dB(Mod_id)); + // for (eNB_offset = 0;(eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id))&& (eNB_offset!=eNB_index);eNB_offset++) { for (eNB_offset = 1;(eNB_offset<1+mac_xface->get_n_adj_cells(Mod_id));eNB_offset++) { - /* RHS: Verify that idx 0 corresponds to currentCellIndex in rsrp array */ - if(UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]+ofn+ocn-hys > UE_rrc_inst[Mod_id].rsrp_db_filtered[0/*eNB_index*/]+ofs+ocs - 1 /*+a3_offset*/) { - UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] += 2; //Called every subframe = 2ms - LOG_D(RRC,"[UE %d] Frame %d: Entry measTimer[%d][%d]: %d currentCell: %d betterCell: %d \n", - Mod_id, frame, ue_cnx_index,meas_index,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1],currentCellIndex,eNB_offset); - } - else { - UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] = 0; //Exit condition: Resetting the measurement timer - LOG_D(RRC,"[UE %d] Frame %d: Exit measTimer[%d][%d]: %d currentCell: %d betterCell: %d \n", - Mod_id, frame, ue_cnx_index,meas_index,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1],currentCellIndex,eNB_offset); - } - if (UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] >= ttt) { - UE_rrc_inst->HandoverInfoUe.targetCellId = get_adjacent_cell_id(Mod_id,eNB_offset-1); //check this! - LOG_D(RRC,"[UE %d] Frame %d eNB %d: Handover triggered: targetCellId: %d currentCellId: %d eNB_offset: %d rsrp source: %3.1f rsrp target: %3.1f\n", \ - Mod_id, frame, eNB_index, - UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset, - (dB_fixed_times10(UE_rrc_inst[Mod_id].rsrp_db[0])/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12), - (dB_fixed_times10(UE_rrc_inst[Mod_id].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); - UE_rrc_inst->Info[0].handoverTarget = eNB_offset; - return 1; - } + /* RHS: Verify that idx 0 corresponds to currentCellIndex in rsrp array */ + if(UE_rrc_inst[Mod_id].rsrp_db_filtered[eNB_offset]+ofn+ocn-hys > UE_rrc_inst[Mod_id].rsrp_db_filtered[0/*eNB_index*/]+ofs+ocs - 1 /*+a3_offset*/) { + UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] += 2; //Called every subframe = 2ms + LOG_D(RRC,"[UE %d] Frame %d: Entry measTimer[%d][%d]: %d currentCell: %d betterCell: %d \n", + Mod_id, frameP, ue_cnx_index,meas_index,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1],currentCellIndex,eNB_offset); + } + else { + UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] = 0; //Exit condition: Resetting the measurement timer + LOG_D(RRC,"[UE %d] Frame %d: Exit measTimer[%d][%d]: %d currentCell: %d betterCell: %d \n", + Mod_id, frameP, ue_cnx_index,meas_index,UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1],currentCellIndex,eNB_offset); + } + if (UE_rrc_inst->measTimer[ue_cnx_index][meas_index][eNB_offset-1] >= ttt) { + UE_rrc_inst->HandoverInfoUe.targetCellId = get_adjacent_cell_id(Mod_id,eNB_offset-1); //check this! + LOG_D(RRC,"[UE %d] Frame %d eNB %d: Handover triggered: targetCellId: %d currentCellId: %d eNB_offset: %d rsrp source: %3.1f rsrp target: %3.1f\n", \ + Mod_id, frameP, eNB_index, + UE_rrc_inst->HandoverInfoUe.targetCellId,ue_cnx_index,eNB_offset, + (dB_fixed_times10(UE_rrc_inst[Mod_id].rsrp_db[0])/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12), + (dB_fixed_times10(UE_rrc_inst[Mod_id].rsrp_db[eNB_offset])/10.0)-mac_xface->get_rx_total_gain_dB(Mod_id)-dB_fixed(mac_xface->lte_frame_parms->N_RB_DL*12)); + UE_rrc_inst->Info[0].handoverTarget = eNB_offset; + return 1; + } } return 0; } #ifdef Rel10 -int decode_MCCH_Message(u8 Mod_id, u32 frame, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area) { - +int decode_MCCH_Message(module_id_t Mod_id, u32 frameP, u8 eNB_index, u8 *Sdu, u8 Sdu_len,u8 mbsfn_sync_area) { + MCCH_Message_t *mcch=NULL; MBSFNAreaConfiguration_r9_t **mcch_message=&UE_rrc_inst[Mod_id].mcch_message[eNB_index]; asn_dec_rval_t dec_rval; - + if (UE_rrc_inst[Mod_id].Info[eNB_index].MCCHStatus[mbsfn_sync_area] == 1) { - LOG_D(RRC,"[UE %d] Frame %d: MCCH MESSAGE for MBSFN sync area %d has been already received!\n", - Mod_id, frame, mbsfn_sync_area); - return 0; // avoid decoding to prevent memory bloating + LOG_D(RRC,"[UE %d] Frame %d: MCCH MESSAGE for MBSFN sync area %d has been already received!\n", + Mod_id, frameP, mbsfn_sync_area); + return 0; // avoid decoding to prevent memory bloating } else { - dec_rval = uper_decode_complete(NULL, - &asn_DEF_MCCH_Message, - (void **)&mcch, - (const void *)Sdu, - Sdu_len); - if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { - LOG_E(RRC,"[UE %d] Failed to decode MCCH__MESSAGE (%d bits)\n",Mod_id,dec_rval.consumed); - //free the memory - SEQUENCE_free(&asn_DEF_MCCH_Message, (void*)mcch, 1); - return -1; - } + dec_rval = uper_decode_complete(NULL, + &asn_DEF_MCCH_Message, + (void **)&mcch, + (const void *)Sdu, + Sdu_len); + if ((dec_rval.code != RC_OK) && (dec_rval.consumed==0)) { + LOG_E(RRC,"[UE %d] Failed to decode MCCH__MESSAGE (%d bits)\n",Mod_id,dec_rval.consumed); + //free the memory + SEQUENCE_free(&asn_DEF_MCCH_Message, (void*)mcch, 1); + return -1; + } #ifdef XER_PRINT - xer_fprint(stdout, &asn_DEF_MCCH_Message, (void*)mcch); + xer_fprint(stdout, &asn_DEF_MCCH_Message, (void*)mcch); #endif - if (mcch->message.present == MCCH_MessageType_PR_c1) { - LOG_D(RRC,"[UE %d] Found mcch message \n",Mod_id); - if(mcch->message.choice.c1.present == MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9) { - /* + if (mcch->message.present == MCCH_MessageType_PR_c1) { + LOG_D(RRC,"[UE %d] Found mcch message \n",Mod_id); + if(mcch->message.choice.c1.present == MCCH_MessageType__c1_PR_mbsfnAreaConfiguration_r9) { + /* memcpy((void*)*mcch_message, (void*)&mcch->message.choice.c1.choice.mbsfnAreaConfiguration_r9, sizeof(MBSFNAreaConfiguration_r9_t)); */ - *mcch_message = &mcch->message.choice.c1.choice.mbsfnAreaConfiguration_r9; - LOG_I(RRC,"[UE %d] Frame %d : Found MBSFNAreaConfiguration from eNB %d \n",Mod_id, frame, eNB_index); - decode_MBSFNAreaConfiguration(Mod_id,eNB_index,frame, mbsfn_sync_area); + *mcch_message = &mcch->message.choice.c1.choice.mbsfnAreaConfiguration_r9; + LOG_I(RRC,"[UE %d] Frame %d : Found MBSFNAreaConfiguration from eNB %d \n",Mod_id, frameP, eNB_index); + decode_MBSFNAreaConfiguration(Mod_id,eNB_index,frameP, mbsfn_sync_area); + } } - } } return 0; } -void decode_MBSFNAreaConfiguration(u8 Mod_id, u8 eNB_index, u32 frame,u8 mbsfn_sync_area) { +void decode_MBSFNAreaConfiguration(module_id_t Mod_id, u8 eNB_index, u32 frameP,u8 mbsfn_sync_area) { LOG_D(RRC,"[UE %d] Frame %d : Number of MCH(s) in the MBSFN Sync Area %d is %d\n", - Mod_id, frame, mbsfn_sync_area, UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9.list.count); + Mod_id, frameP, mbsfn_sync_area, UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9.list.count); // store to MAC/PHY necessary parameters for receiving MTCHs rrc_mac_config_req(Mod_id,0,0,eNB_index, - (RadioResourceConfigCommonSIB_t *)NULL, - (struct PhysicalConfigDedicated *)NULL, - (MeasObjectToAddMod_t **)NULL, - (MAC_MainConfig_t *)NULL, - 0, - (struct LogicalChannelConfig *)NULL, - (MeasGapConfig_t *)NULL, - (TDD_Config_t *)NULL, - (MobilityControlInfo_t *)NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - (MBSFN_SubframeConfigList_t *)NULL + (RadioResourceConfigCommonSIB_t *)NULL, + (struct PhysicalConfigDedicated *)NULL, + (MeasObjectToAddMod_t **)NULL, + (MAC_MainConfig_t *)NULL, + 0, + (struct LogicalChannelConfig *)NULL, + (MeasGapConfig_t *)NULL, + (TDD_Config_t *)NULL, + (MobilityControlInfo_t *)NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + (MBSFN_SubframeConfigList_t *)NULL #ifdef Rel10 - , - 0, - (MBSFN_AreaInfoList_r9_t *)NULL, - &UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9 +, +0, +(MBSFN_AreaInfoList_r9_t *)NULL, +&UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9 #endif #ifdef CBA - , - 0, - 0 +, +0, +0 #endif - ); + ); UE_rrc_inst[Mod_id].Info[eNB_index].MCCHStatus[mbsfn_sync_area] = 1; - + // Config Radio Bearer for MBMS user data (similar way to configure for eNB side in init_MBMS function) - rrc_pdcp_config_asn1_req(eNB_index, Mod_id, frame, 0, - NULL, // SRB_ToAddModList - NULL, // DRB_ToAddModList - (DRB_ToReleaseList_t*)NULL, - 0, // security mode - NULL, // key rrc encryption - NULL, // key rrc integrity - NULL // key encryption + rrc_pdcp_config_asn1_req(eNB_index, Mod_id, frameP, 0, + NULL, // SRB_ToAddModList + NULL, // DRB_ToAddModList + (DRB_ToReleaseList_t*)NULL, + 0, // security mode + NULL, // key rrc encryption + NULL, // key rrc integrity + NULL // key encryption #ifdef Rel10 - ,&(UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9) + ,&(UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9) #endif - ); + ); - rrc_rlc_config_asn1_req(NB_eNB_INST+Mod_id, frame,0,eNB_index, - NULL,// SRB_ToAddModList - NULL,// DRB_ToAddModList - NULL,// DRB_ToReleaseList + rrc_rlc_config_asn1_req(eNB_index, Mod_id, frameP,0, + NULL,// SRB_ToAddModList + NULL,// DRB_ToAddModList + NULL,// DRB_ToReleaseList #ifdef Rel10 - &(UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9) + &(UE_rrc_inst[Mod_id].mcch_message[eNB_index]->pmch_InfoList_r9) #endif - ); + ); // */ - + } #endif // rel10 @@ -2713,14 +2714,14 @@ void *rrc_ue_task(void *args_p) { itti_mark_task_ready (TASK_RRC_UE); while(1) { - // Wait for a message - itti_receive_msg (TASK_RRC_UE, &msg_p); + // Wait for a message + itti_receive_msg (TASK_RRC_UE, &msg_p); - msg_name = ITTI_MSG_NAME (msg_p); - instance = ITTI_MSG_INSTANCE (msg_p); - Mod_id = instance - NB_eNB_INST; + msg_name = ITTI_MSG_NAME (msg_p); + instance = ITTI_MSG_INSTANCE (msg_p); + Mod_id = instance - NB_eNB_INST; - switch (ITTI_MSG_ID(msg_p)) { + switch (ITTI_MSG_ID(msg_p)) { case TERMINATE_MESSAGE: itti_exit_task (); break; @@ -2729,10 +2730,10 @@ void *rrc_ue_task(void *args_p) { LOG_I(RRC, "[UE %d] Received %s\n", Mod_id, msg_name); break; - /* MAC messages */ + /* MAC messages */ case RRC_MAC_IN_SYNC_IND: - LOG_D(RRC, "[UE %d] Received %s: frame %d, eNB %d\n", Mod_id, msg_name, - RRC_MAC_IN_SYNC_IND (msg_p).frame, RRC_MAC_IN_SYNC_IND (msg_p).enb_index); + LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name, + RRC_MAC_IN_SYNC_IND (msg_p).frameP, RRC_MAC_IN_SYNC_IND (msg_p).enb_index); UE_rrc_inst[Mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].N310_cnt = 0; if (UE_rrc_inst[Mod_id].Info[RRC_MAC_IN_SYNC_IND (msg_p).enb_index].T310_active == 1) @@ -2740,62 +2741,62 @@ void *rrc_ue_task(void *args_p) { break; case RRC_MAC_OUT_OF_SYNC_IND: - LOG_I(RRC, "[UE %d] Received %s: frame %d, eNB %d\n", Mod_id, msg_name, - RRC_MAC_OUT_OF_SYNC_IND (msg_p).frame, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index); + LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name, + RRC_MAC_OUT_OF_SYNC_IND (msg_p).frameP, RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index); UE_rrc_inst[Mod_id].Info[RRC_MAC_OUT_OF_SYNC_IND (msg_p).enb_index].N310_cnt ++; break; case RRC_MAC_BCCH_DATA_IND: - LOG_D(RRC, "[UE %d] Received %s: frame %d, eNB %d\n", Mod_id, msg_name, - RRC_MAC_BCCH_DATA_IND (msg_p).frame, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index); + LOG_D(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name, + RRC_MAC_BCCH_DATA_IND (msg_p).frameP, RRC_MAC_BCCH_DATA_IND (msg_p).enb_index); - decode_BCCH_DLSCH_Message (Mod_id, RRC_MAC_BCCH_DATA_IND (msg_p).frame, - RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, RRC_MAC_BCCH_DATA_IND (msg_p).sdu, - RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, - RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); + decode_BCCH_DLSCH_Message (Mod_id, RRC_MAC_BCCH_DATA_IND (msg_p).frameP, + RRC_MAC_BCCH_DATA_IND (msg_p).enb_index, RRC_MAC_BCCH_DATA_IND (msg_p).sdu, + RRC_MAC_BCCH_DATA_IND (msg_p).sdu_size, + RRC_MAC_BCCH_DATA_IND (msg_p).rsrq, RRC_MAC_BCCH_DATA_IND (msg_p).rsrp); break; case RRC_MAC_CCCH_DATA_CNF: LOG_I(RRC, "[UE %d] Received %s: eNB %d\n", Mod_id, msg_name, - RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index); + RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index); // reset the tx buffer to indicate RRC that ccch was successfully transmitted (for example if contention resolution succeeds) UE_rrc_inst[Mod_id].Srb0[RRC_MAC_CCCH_DATA_CNF (msg_p).enb_index].Tx_buffer.payload_size = 0; break; case RRC_MAC_CCCH_DATA_IND: - LOG_I(RRC, "[UE %d] Received %s: frame %d, eNB %d\n", Mod_id, msg_name, - RRC_MAC_CCCH_DATA_IND (msg_p).frame, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); + LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d\n", Mod_id, msg_name, + RRC_MAC_CCCH_DATA_IND (msg_p).frameP, RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); srb_info_p = &UE_rrc_inst[Mod_id].Srb0[RRC_MAC_CCCH_DATA_IND (msg_p).enb_index]; memcpy (srb_info_p->Rx_buffer.Payload, RRC_MAC_CCCH_DATA_IND (msg_p).sdu, - RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size); + RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size); srb_info_p->Rx_buffer.payload_size = RRC_MAC_CCCH_DATA_IND (msg_p).sdu_size; - rrc_ue_decode_ccch (Mod_id, RRC_MAC_CCCH_DATA_IND (msg_p).frame, srb_info_p, - RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); + rrc_ue_decode_ccch (Mod_id, RRC_MAC_CCCH_DATA_IND (msg_p).frameP, srb_info_p, + RRC_MAC_CCCH_DATA_IND (msg_p).enb_index); break; # ifdef Rel10 case RRC_MAC_MCCH_DATA_IND: - LOG_I(RRC, "[UE %d] Received %s: frame %d, eNB %d, mbsfn SA %d\n", Mod_id, msg_name, - RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); + LOG_I(RRC, "[UE %d] Received %s: frameP %d, eNB %d, mbsfn SA %d\n", Mod_id, msg_name, + RRC_MAC_MCCH_DATA_IND (msg_p).frameP, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); - decode_MCCH_Message (Mod_id, RRC_MAC_MCCH_DATA_IND (msg_p).frame, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, - RRC_MAC_MCCH_DATA_IND (msg_p).sdu, RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size, - RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); + decode_MCCH_Message (Mod_id, RRC_MAC_MCCH_DATA_IND (msg_p).frameP, RRC_MAC_MCCH_DATA_IND (msg_p).enb_index, + RRC_MAC_MCCH_DATA_IND (msg_p).sdu, RRC_MAC_MCCH_DATA_IND (msg_p).sdu_size, + RRC_MAC_MCCH_DATA_IND (msg_p).mbsfn_sync_area); break; # endif - /* PDCP messages */ +/* PDCP messages */ case RRC_DCCH_DATA_IND: - LOG_I(RRC, "[UE %d] Received %s: frame %d, DCCH %d, eNB %d\n", Mod_id, msg_name, - RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index); + LOG_I(RRC, "[UE %d] Received %s: frameP %d, DCCH %d, eNB %d\n", Mod_id, msg_name, + RRC_DCCH_DATA_IND (msg_p).frameP, RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).eNB_index); - rrc_ue_decode_dcch (Mod_id, RRC_DCCH_DATA_IND (msg_p).frame, - RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p, - RRC_DCCH_DATA_IND (msg_p).eNB_index); + rrc_ue_decode_dcch (Mod_id, RRC_DCCH_DATA_IND (msg_p).frameP, + RRC_DCCH_DATA_IND (msg_p).dcch_index, RRC_DCCH_DATA_IND (msg_p).sdu_p, + RRC_DCCH_DATA_IND (msg_p).eNB_index); // Message buffer has been processed, free it now. result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), RRC_DCCH_DATA_IND (msg_p).sdu_p); @@ -2803,268 +2804,268 @@ void *rrc_ue_task(void *args_p) { break; # if defined(ENABLE_USE_MME) - /* NAS messages */ + /* NAS messages */ case NAS_CELL_SELECTION_REQ: - Mod_id = 0; /* TODO force Mod_id to first UE, NAS UE not virtualized yet */ + Mod_id = 0; /* TODO force Mod_id to first UE, NAS UE not virtualized yet */ - LOG_I(RRC, "[UE %d] Received %s: state %d, plmnID %d, rat %x\n", Mod_id, msg_name, rrc_get_state(Mod_id), - NAS_CELL_SELECTION_REQ (msg_p).plmnID, NAS_CELL_SELECTION_REQ (msg_p).rat); + LOG_I(RRC, "[UE %d] Received %s: state %d, plmnID %d, rat %x\n", Mod_id, msg_name, rrc_get_state(Mod_id), + NAS_CELL_SELECTION_REQ (msg_p).plmnID, NAS_CELL_SELECTION_REQ (msg_p).rat); - /* Save cell selection criterion */ - { - UE_rrc_inst[Mod_id].plmnID = NAS_CELL_SELECTION_REQ (msg_p).plmnID; - UE_rrc_inst[Mod_id].rat = NAS_CELL_SELECTION_REQ (msg_p).rat; - } + /* Save cell selection criterion */ + { + UE_rrc_inst[Mod_id].plmnID = NAS_CELL_SELECTION_REQ (msg_p).plmnID; + UE_rrc_inst[Mod_id].rat = NAS_CELL_SELECTION_REQ (msg_p).rat; + } - switch (rrc_get_state(Mod_id)) { - case RRC_STATE_INACTIVE: - { - /* Need to first activate lower layers */ - MessageDef *message_p; + switch (rrc_get_state(Mod_id)) { + case RRC_STATE_INACTIVE: + { + /* Need to first activate lower layers */ + MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE); + message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE); - itti_send_msg_to_task(TASK_L2L1, NB_eNB_INST + Mod_id, message_p); + itti_send_msg_to_task(TASK_L2L1, NB_eNB_INST + Mod_id, message_p); - rrc_set_state (Mod_id, RRC_STATE_IDLE); - /* Fall through to next case */ - } + rrc_set_state (Mod_id, RRC_STATE_IDLE); + /* Fall through to next case */ + } - case RRC_STATE_IDLE: - { - /* Ask to layer 1 to find a cell matching the criterion */ - MessageDef *message_p; + case RRC_STATE_IDLE: + { + /* Ask to layer 1 to find a cell matching the criterion */ + MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ); + message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ); - PHY_FIND_CELL_REQ (message_p).earfcn_start = 1; - PHY_FIND_CELL_REQ (message_p).earfcn_end = 1; + PHY_FIND_CELL_REQ (message_p).earfcn_start = 1; + PHY_FIND_CELL_REQ (message_p).earfcn_end = 1; - itti_send_msg_to_task(TASK_PHY_UE, NB_eNB_INST + Mod_id, message_p); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SEARCHING); + itti_send_msg_to_task(TASK_PHY_UE, NB_eNB_INST + Mod_id, message_p); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SEARCHING); - break; - } + break; + } - case RRC_STATE_CONNECTED: - /* should not happen */ - LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); - break; + case RRC_STATE_CONNECTED: + /* should not happen */ + LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); + break; - default: - LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); - break; - } + default: + LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); break; + } + break; - case NAS_CONN_ESTABLI_REQ: + case NAS_CONN_ESTABLI_REQ: LOG_I(RRC, "[UE %d] Received %s: cause %d, type %d, s_tmsi %d, plmnID %d\n", Mod_id, msg_name, NAS_CONN_ESTABLI_REQ (msg_p).cause, - NAS_CONN_ESTABLI_REQ (msg_p).type, NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi, NAS_CONN_ESTABLI_REQ (msg_p).plmnID); + NAS_CONN_ESTABLI_REQ (msg_p).type, NAS_CONN_ESTABLI_REQ (msg_p).s_tmsi, NAS_CONN_ESTABLI_REQ (msg_p).plmnID); UE_rrc_inst[Mod_id].initialNasMsg = NAS_CONN_ESTABLI_REQ (msg_p).initialNasMsg; switch (rrc_get_state(Mod_id)) { - case RRC_STATE_IDLE: - { - if (rrc_get_sub_state(Mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) - { - rrc_ue_generate_RRCConnectionRequest(Mod_id, 0 /* TODO put frame number ! */, 0); - LOG_I(RRC, "not sending connection request\n"); + case RRC_STATE_IDLE: + { + if (rrc_get_sub_state(Mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) + { + rrc_ue_generate_RRCConnectionRequest(Mod_id, 0 /* TODO put frameP number ! */, 0); + LOG_I(RRC, "not sending connection request\n"); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); - } - break; - } + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); + } + break; + } - case RRC_STATE_INACTIVE: - case RRC_STATE_CONNECTED: - /* should not happen */ - LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); - break; + case RRC_STATE_INACTIVE: + case RRC_STATE_CONNECTED: + /* should not happen */ + LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); + break; - default: - LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); - break; + default: + LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); + break; } break; - case NAS_UPLINK_DATA_REQ: - { - uint32_t length; - uint8_t *buffer; + case NAS_UPLINK_DATA_REQ: + { + uint32_t length; + uint8_t *buffer; - LOG_I(RRC, "[UE %d] Received %s: UEid %d\n", Mod_id, msg_name, NAS_UPLINK_DATA_REQ (msg_p).UEid); + LOG_I(RRC, "[UE %d] Received %s: UEid %d\n", Mod_id, msg_name, NAS_UPLINK_DATA_REQ (msg_p).UEid); - /* Create message for PDCP (ULInformationTransfer_t) */ - length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data); + /* Create message for PDCP (ULInformationTransfer_t) */ + length = do_ULInformationTransfer(&buffer, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.length, NAS_UPLINK_DATA_REQ (msg_p).nasMsg.data); - /* Transfer data to PDCP */ - pdcp_rrc_data_req (0, Mod_id, 0 /* TODO put frame number ! */, 0, DCCH, rrc_mui++, 0, length, buffer, 1); - break; - } + /* Transfer data to PDCP */ + pdcp_rrc_data_req (0, Mod_id, 0 /* TODO put frameP number ! */, 0, DCCH, rrc_mui++, 0, length, buffer, 1); + break; + } # endif # if defined(ENABLE_RAL) - case RRC_RAL_SCAN_REQ: - LOG_I(RRC, "[UE %d] Received %s: state %d\n", Mod_id, msg_name); + case RRC_RAL_SCAN_REQ: + LOG_I(RRC, "[UE %d] Received %s: state %d\n", Mod_id, msg_name); - switch (rrc_get_state(Mod_id)) { - case RRC_STATE_INACTIVE: + switch (rrc_get_state(Mod_id)) { + case RRC_STATE_INACTIVE: { - /* Need to first activate lower layers */ - MessageDef *message_p; + /* Need to first activate lower layers */ + MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE); + message_p = itti_alloc_new_message(TASK_RRC_UE, ACTIVATE_MESSAGE); - itti_send_msg_to_task(TASK_L2L1, instance, message_p); + itti_send_msg_to_task(TASK_L2L1, instance, message_p); - rrc_set_state (Mod_id, RRC_STATE_IDLE); - /* Fall through to next case */ + rrc_set_state (Mod_id, RRC_STATE_IDLE); + /* Fall through to next case */ } - case RRC_STATE_IDLE: + case RRC_STATE_IDLE: { - if (rrc_get_sub_state(Mod_id) != RRC_SUB_STATE_IDLE_SEARCHING) { - /* Ask to layer 1 to find a cell matching the criterion */ - MessageDef *message_p; + if (rrc_get_sub_state(Mod_id) != RRC_SUB_STATE_IDLE_SEARCHING) { + /* Ask to layer 1 to find a cell matching the criterion */ + MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ); + message_p = itti_alloc_new_message(TASK_RRC_UE, PHY_FIND_CELL_REQ); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SEARCHING); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_SEARCHING); - PHY_FIND_CELL_REQ (message_p).transaction_id = RRC_RAL_SCAN_REQ (msg_p).transaction_id; - PHY_FIND_CELL_REQ (message_p).earfcn_start = 1; - PHY_FIND_CELL_REQ (message_p).earfcn_end = 1; //44 + PHY_FIND_CELL_REQ (message_p).transaction_id = RRC_RAL_SCAN_REQ (msg_p).transaction_id; + PHY_FIND_CELL_REQ (message_p).earfcn_start = 1; + PHY_FIND_CELL_REQ (message_p).earfcn_end = 1; //44 - itti_send_msg_to_task(TASK_PHY_UE, instance, message_p); - } - break; + itti_send_msg_to_task(TASK_PHY_UE, instance, message_p); + } + break; } - case RRC_STATE_CONNECTED: - /* should not happen */ - LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); - break; + case RRC_STATE_CONNECTED: + /* should not happen */ + LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); + break; - default: - LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); - break; - } - break; + default: + LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); + break; + } + break; - case PHY_FIND_CELL_IND: - LOG_I(RRC, "[UE %d] Received %s: state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); - switch (rrc_get_state(Mod_id)) { + case PHY_FIND_CELL_IND: + LOG_I(RRC, "[UE %d] Received %s: state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); + switch (rrc_get_state(Mod_id)) { case RRC_STATE_IDLE: - switch (rrc_get_sub_state(Mod_id)) { - case RRC_SUB_STATE_IDLE_SEARCHING: - { - MessageDef *message_p; - int i; - - message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_SCAN_CONF); + switch (rrc_get_sub_state(Mod_id)) { + case RRC_SUB_STATE_IDLE_SEARCHING: + { + MessageDef *message_p; + int i; - RRC_RAL_SCAN_CONF (message_p).transaction_id = PHY_FIND_CELL_IND(msg_p).transaction_id; - RRC_RAL_SCAN_CONF (message_p).num_scan_resp = PHY_FIND_CELL_IND(msg_p).cell_nb; - for (i = 0 ; i < PHY_FIND_CELL_IND(msg_p).cell_nb; i++) { - // TO DO - memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].link_addr, 0, sizeof(ral_link_addr_t)); - // TO DO - memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].network_id, 0, sizeof(ral_network_id_t)); + message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_SCAN_CONF); - RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength.choice = RAL_SIG_STRENGTH_CHOICE_DBM; - RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength._union.dbm = PHY_FIND_CELL_IND(msg_p).cells[i].rsrp; - } + RRC_RAL_SCAN_CONF (message_p).transaction_id = PHY_FIND_CELL_IND(msg_p).transaction_id; + RRC_RAL_SCAN_CONF (message_p).num_scan_resp = PHY_FIND_CELL_IND(msg_p).cell_nb; + for (i = 0 ; i < PHY_FIND_CELL_IND(msg_p).cell_nb; i++) { + // TO DO + memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].link_addr, 0, sizeof(ral_link_addr_t)); + // TO DO + memset(&RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].network_id, 0, sizeof(ral_network_id_t)); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE); + RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength.choice = RAL_SIG_STRENGTH_CHOICE_DBM; + RRC_RAL_SCAN_CONF (message_p).link_scan_resp[i].sig_strength._union.dbm = PHY_FIND_CELL_IND(msg_p).cells[i].rsrp; + } - itti_send_msg_to_task(TASK_RAL_UE, instance, message_p); - break; - } + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE); - default: - LOG_C(RRC, "[UE %d] Invalid RRC state %d substate %d\n", - Mod_id, - rrc_get_state(Mod_id), - rrc_get_sub_state(Mod_id)); + itti_send_msg_to_task(TASK_RAL_UE, instance, message_p); + break; } - break; - case RRC_STATE_INACTIVE: - case RRC_STATE_CONNECTED: + default: + LOG_C(RRC, "[UE %d] Invalid RRC state %d substate %d\n", + Mod_id, + rrc_get_state(Mod_id), + rrc_get_sub_state(Mod_id)); + } + break; + + case RRC_STATE_INACTIVE: + case RRC_STATE_CONNECTED: /* should not happen */ LOG_E(RRC, "[UE %d] indication %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); break; - default: + default: LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); break; - } - break; + } + break; - case PHY_MEAS_REPORT_IND: - { - MessageDef *message_p; - message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_MEASUREMENT_REPORT_IND); + case PHY_MEAS_REPORT_IND: + { + MessageDef *message_p; + message_p = itti_alloc_new_message(TASK_RRC_UE, RRC_RAL_MEASUREMENT_REPORT_IND); - memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold, - &PHY_MEAS_REPORT_IND(msg_p).threshold, - sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold)); + memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold, + &PHY_MEAS_REPORT_IND(msg_p).threshold, + sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).threshold)); - memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param, - &PHY_MEAS_REPORT_IND(msg_p).link_param, - sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param)); + memcpy(&RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param, + &PHY_MEAS_REPORT_IND(msg_p).link_param, + sizeof(RRC_RAL_MEASUREMENT_REPORT_IND (message_p).link_param)); - itti_send_msg_to_task(TASK_RAL_UE, instance, message_p); - break; - } + itti_send_msg_to_task(TASK_RAL_UE, instance, message_p); + break; + } - case RRC_RAL_CONFIGURE_THRESHOLD_REQ: - rrc_ue_ral_handle_configure_threshold_request(Mod_id, msg_p); - break; + case RRC_RAL_CONFIGURE_THRESHOLD_REQ: + rrc_ue_ral_handle_configure_threshold_request(Mod_id, msg_p); + break; - case RRC_RAL_CONNECTION_ESTABLISHMENT_REQ: - LOG_I(RRC, "[UE %d] Received %s\n", Mod_id, msg_name); - switch (rrc_get_state(Mod_id)) { - case RRC_STATE_IDLE: - { - if (rrc_get_sub_state(Mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) + case RRC_RAL_CONNECTION_ESTABLISHMENT_REQ: + LOG_I(RRC, "[UE %d] Received %s\n", Mod_id, msg_name); + switch (rrc_get_state(Mod_id)) { + case RRC_STATE_IDLE: { - rrc_ue_generate_RRCConnectionRequest(Mod_id, 0 /* TODO put frame number ! */, 0); - LOG_I(RRC, "not sending connection request\n"); + if (rrc_get_sub_state(Mod_id) == RRC_SUB_STATE_IDLE_SIB_COMPLETE) + { + rrc_ue_generate_RRCConnectionRequest(Mod_id, 0 /* TODO put frameP number ! */, 0); + LOG_I(RRC, "not sending connection request\n"); - rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); + rrc_set_sub_state (Mod_id, RRC_SUB_STATE_IDLE_CONNECTING); + } + break; } - break; - } - case RRC_STATE_INACTIVE: - case RRC_STATE_CONNECTED: + case RRC_STATE_INACTIVE: + case RRC_STATE_CONNECTED: /* should not happen */ LOG_E(RRC, "[UE %d] request %s in RRC state %d\n", Mod_id, msg_name, rrc_get_state(Mod_id)); break; - default: + default: LOG_C(RRC, "[UE %d] Invalid RRC state %d\n", Mod_id, rrc_get_state(Mod_id)); break; - } - break; + } + break; - case RRC_RAL_CONNECTION_RELEASE_REQ: - Mod_id = 0; /* TODO force Mod_id to first UE, NAS UE not virtualized yet */ - LOG_I(RRC, "[UE %d] Received %s\n", Mod_id, msg_name); - break; + case RRC_RAL_CONNECTION_RELEASE_REQ: + Mod_id = 0; /* TODO force Mod_id to first UE, NAS UE not virtualized yet */ + LOG_I(RRC, "[UE %d] Received %s\n", Mod_id, msg_name); + break; #endif - default: - LOG_E(RRC, "[UE %d] Received unexpected message %s\n", Mod_id, msg_name); - break; - } + default: + LOG_E(RRC, "[UE %d] Received unexpected message %s\n", Mod_id, msg_name); + break; + } - result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - msg_p = NULL; + result = itti_free (ITTI_MSG_ORIGIN_ID(msg_p), msg_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + msg_p = NULL; } } #endif diff --git a/openair2/RRC/LITE/rrc_common.c b/openair2/RRC/LITE/rrc_common.c index 6e7bebdedf462a4ee4e8decdaf9275f517272fae..7d19f4f25e9a8b1511ab891edeca503eb17b752a 100644 --- a/openair2/RRC/LITE/rrc_common.c +++ b/openair2/RRC/LITE/rrc_common.c @@ -40,6 +40,7 @@ #include "extern.h" #include "LAYER2/MAC/extern.h" #include "COMMON/openair_defs.h" +#include "COMMON/platform_types.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "LAYER2/RLC/rlc.h" #include "COMMON/mac_rrc_primitives.h" @@ -54,7 +55,7 @@ extern UE_MAC_INST *UE_mac_inst; extern mui_t rrc_eNB_mui; //configure BCCH & CCCH Logical Channels and associated rrc_buffers, configure associated SRBs -void openair_rrc_on(u8 Mod_id, u8 eNB_flag) { +void openair_rrc_on(module_id_t Mod_id, eNB_flag_t eNB_flag) { unsigned short i; if (eNB_flag == 1) { @@ -208,8 +209,8 @@ void rrc_config_buffer(SRB_INFO *Srb_info, u8 Lchan_type, u8 Role) { void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active,u8 HO_active){ /*-----------------------------------------------------------------------------*/ - int i; - OAI_UECapability_t *UECap; + module_id_t module_id; + OAI_UECapability_t *UECap = NULL; // uint8_t dummy_buffer[100]; LOG_D(RRC, "[OPENAIR][INIT] Init function start: NB_UE_INST=%d, NB_eNB_INST=%d\n", NB_UE_INST, NB_eNB_INST); @@ -221,9 +222,9 @@ void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active,u8 HO_active){ // fill UE capability UECap = fill_ue_capability (); - for (i = 0; i < NB_UE_INST; i++) { - UE_rrc_inst[i].UECapability = UECap->sdu; - UE_rrc_inst[i].UECapability_size = UECap->sdu_size; + for (module_id = 0; module_id < NB_UE_INST; module_id++) { + UE_rrc_inst[module_id].UECapability = UECap->sdu; + UE_rrc_inst[module_id].UECapability_size = UECap->sdu_size; } /* do_UECapabilityEnquiry(0, @@ -232,8 +233,8 @@ void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active,u8 HO_active){ 0);*/ #ifdef Rel10 LOG_I(RRC,"[UE] eMBMS active state is %d \n", eMBMS_active); - for (i=0;i<NB_UE_INST;i++) { - UE_rrc_inst[i].MBMS_flag = (uint8_t)eMBMS_active; + for (module_id=0;module_id<NB_UE_INST;module_id++) { + UE_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active; } #endif } @@ -244,17 +245,17 @@ void openair_rrc_top_init(int eMBMS_active, u8 cba_group_active,u8 HO_active){ eNB_rrc_inst = (eNB_RRC_INST*) malloc16(NB_eNB_INST*sizeof(eNB_RRC_INST)); memset (eNB_rrc_inst, 0, NB_eNB_INST * sizeof(eNB_RRC_INST)); LOG_I(RRC,"[eNB] handover active state is %d \n", HO_active); - for (i=0;i<NB_eNB_INST;i++) { - eNB_rrc_inst[i].HO_flag = (uint8_t)HO_active; + for (module_id=0;module_id<NB_eNB_INST;module_id++) { + eNB_rrc_inst[module_id].HO_flag = (uint8_t)HO_active; } #ifdef Rel10 LOG_I(RRC,"[eNB] eMBMS active state is %d \n", eMBMS_active); - for (i=0;i<NB_eNB_INST;i++) { - eNB_rrc_inst[i].MBMS_flag = (uint8_t)eMBMS_active; + for (module_id=0;module_id<NB_eNB_INST;module_id++) { + eNB_rrc_inst[module_id].MBMS_flag = (uint8_t)eMBMS_active; } #endif #ifdef CBA - for (i=0;i<NB_eNB_INST;i++) { + for (module_id=0;module_id<NB_eNB_INST;module_id++) { eNB_rrc_inst[i].num_active_cba_groups = cba_group_active; } #endif @@ -287,7 +288,7 @@ void rrc_top_cleanup(void) { } -void rrc_t310_expiration(u32 frame, u8 Mod_id, u8 eNB_index) { +void rrc_t310_expiration(frame_t frameP, u8 Mod_id, u8 eNB_index) { if (UE_rrc_inst[Mod_id].Info[eNB_index].State != RRC_CONNECTED) { LOG_D(RRC, "Timer 310 expired, going to RRC_IDLE\n"); @@ -305,7 +306,7 @@ void rrc_t310_expiration(u32 frame, u8 Mod_id, u8 eNB_index) { UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id); rrc_pdcp_config_req (eNB_index, Mod_id, frame, 0, ACTION_REMOVE, UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id, 0); - rrc_rlc_config_req (Mod_id + NB_eNB_INST, frame, 0, ACTION_REMOVE, + rrc_rlc_config_req (eNB_index, Mod_id, frame, 0, ACTION_REMOVE, UE_rrc_inst[Mod_id].Srb2[eNB_index].Srb_info.Srb_id, SIGNALLING_RADIO_BEARER, Rlc_info_um); UE_rrc_inst[Mod_id].Srb2[eNB_index].Active = 0; UE_rrc_inst[Mod_id].Srb2[eNB_index].Status = IDLE; @@ -317,9 +318,9 @@ void rrc_t310_expiration(u32 frame, u8 Mod_id, u8 eNB_index) { } } -RRC_status_t rrc_rx_tx(u8 Mod_id,u32 frame, u8 eNB_flag,u8 index){ +RRC_status_t rrc_rx_tx(u8 Mod_id,frame_t frameP, eNB_flag_t eNB_flagP,u8 index){ - if(eNB_flag == 0) { + if(eNB_flagP == 0) { // check timers if (UE_rrc_inst[Mod_id].Info[index].T300_active == 1) { diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index e37e347d4ccac7b11d5e4be20f0e691ee5279241..5d499b32bee19bb0f997634558b94f64946c8da7 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -111,7 +111,7 @@ static const uint8_t RRC_TRANSACTION_IDENTIFIER_NUMBER = 4; mui_t rrc_eNB_mui = 0; /*------------------------------------------------------------------------------*/ -static void init_SI (u8 Mod_id +static void init_SI (module_id_t Mod_id #if defined(ENABLE_ITTI) , RrcConfigurationReq *configuration #endif @@ -344,7 +344,7 @@ static void init_SI (u8 Mod_id #ifdef Rel10 /*------------------------------------------------------------------------------*/ -static void init_MCCH (u8 Mod_id) { +static void init_MCCH (module_id_t Mod_id) { int sync_area=0; // initialize RRC_eNB_INST MCCH entry @@ -425,15 +425,15 @@ static void init_MCCH (u8 Mod_id) { } /*------------------------------------------------------------------------------*/ -static void init_MBMS (u8 Mod_id, u32 frame) { +static void init_MBMS (module_id_t Mod_id, frame_t frameP) { // init the configuration for MTCH if (eNB_rrc_inst[Mod_id].MBMS_flag > 0) { - LOG_D(RRC,"[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", Mod_id, frame); //check the lcid + LOG_D(RRC,"[eNB %d] Frame %d : Radio Bearer config request for MBMS\n", Mod_id, frameP); //check the lcid // Configuring PDCP and RLC for MBMS Radio Bearer - rrc_pdcp_config_asn1_req (Mod_id, 0, frame, 1, + rrc_pdcp_config_asn1_req (Mod_id, 0, frameP, 1, NULL, // SRB_ToAddModList NULL, // DRB_ToAddModList (DRB_ToReleaseList_t *) NULL, @@ -447,7 +447,7 @@ static void init_MBMS (u8 Mod_id, u32 frame) { #endif ); - rrc_rlc_config_asn1_req(Mod_id, frame, 1, 0, + rrc_rlc_config_asn1_req(Mod_id, 0,frameP, 1, NULL,// SRB_ToAddModList NULL,// DRB_ToAddModList NULL,// DRB_ToReleaseList @@ -459,7 +459,7 @@ static void init_MBMS (u8 Mod_id, u32 frame) { #endif /*------------------------------------------------------------------------------*/ -static void rrc_lite_eNB_init_security(u8 Mod_id, u8 UE_index) +static void rrc_lite_eNB_init_security(module_id_t Mod_id, u8 UE_index) { #if defined(ENABLE_SECURITY) char ascii_buffer[65]; @@ -477,7 +477,7 @@ static void rrc_lite_eNB_init_security(u8 Mod_id, u8 UE_index) } /*------------------------------------------------------------------------------*/ -uint8_t rrc_eNB_get_next_transaction_identifier(uint8_t Mod_id) +uint8_t rrc_eNB_get_next_transaction_identifier(module_id_t Mod_id) { static uint8_t rrc_transaction_identifier[NUMBER_OF_eNB_MAX]; @@ -489,7 +489,7 @@ uint8_t rrc_eNB_get_next_transaction_identifier(uint8_t Mod_id) /*------------------------------------------------------------------------------*/ /* Functions to handle UE index in eNB UE list */ -static uint8_t rrc_eNB_get_next_free_UE_index (uint8_t Mod_id, uint64_t UE_identity) +static uint8_t rrc_eNB_get_next_free_UE_index (module_id_t Mod_id, uint64_t UE_identity) { uint8_t i, first_index = UE_INDEX_INVALID, reg = 0; @@ -515,24 +515,24 @@ static uint8_t rrc_eNB_get_next_free_UE_index (uint8_t Mod_id, uint64_t UE_ident } } -void rrc_eNB_free_UE_index (uint8_t Mod_id, uint8_t UE_id) +void rrc_eNB_free_UE_index (module_id_t enb_mod_idP, module_id_t ue_mod_idP) { - AssertFatal(Mod_id < NB_eNB_INST, "eNB index invalid (%d/%d) for UE %d!", Mod_id, NB_eNB_INST, UE_id); - AssertFatal(UE_id < NUMBER_OF_UE_MAX, "UE index invalid (%d/%d) for eNB %d!", UE_id, NUMBER_OF_UE_MAX, Mod_id); + AssertFatal(enb_mod_idP < NB_eNB_INST, "eNB inst invalid (%d/%d) for UE %d!", enb_mod_idP, NB_eNB_INST, ue_mod_idP); + AssertFatal(ue_mod_idP < NUMBER_OF_UE_MAX, "UE inst invalid (%d/%d) for eNB %d!", ue_mod_idP, NUMBER_OF_UE_MAX, enb_mod_idP); - LOG_I (RRC, "[eNB %d] Removing UE %d rv 0x%" PRIx64 "\n", Mod_id, UE_id, eNB_rrc_inst[Mod_id].Info.UE_list[UE_id]); - eNB_rrc_inst[Mod_id].Info.UE[UE_id].Status = RRC_IDLE; - eNB_rrc_inst[Mod_id].Info.UE_list[UE_id] = 0; + LOG_I (RRC, "[eNB %d] Removing UE %d rv 0x%" PRIx64 "\n", enb_mod_idP, ue_mod_idP, eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP]); + eNB_rrc_inst[enb_mod_idP].Info.UE[ue_mod_idP].Status = RRC_IDLE; + eNB_rrc_inst[enb_mod_idP].Info.UE_list[ue_mod_idP] = 0; } /*------------------------------------------------------------------------------*/ -void rrc_eNB_process_RRCConnectionSetupComplete (u8 Mod_id, - u32 frame, +void rrc_eNB_process_RRCConnectionSetupComplete (module_id_t Mod_id, + frame_t frameP, u8 UE_index, RRCConnectionSetupComplete_r8_IEs_t *rrcConnectionSetupComplete) { LOG_I (RRC, "[eNB %d][RAPROC] Frame %d : Logical Channel UL-DCCH, ""processing RRCConnectionSetupComplete from UE %d\n", - Mod_id, frame, UE_index); + Mod_id, frameP, UE_index); #if defined(ENABLE_USE_MME) if (EPC_MODE_ENABLED == 1) @@ -544,13 +544,13 @@ void rrc_eNB_process_RRCConnectionSetupComplete (u8 Mod_id, #endif { // RRC loop back (no S1AP), send SecurityModeCommand to UE - rrc_eNB_generate_SecurityModeCommand (Mod_id, frame, UE_index); - // rrc_eNB_generate_UECapabilityEnquiry(Mod_id,frame,UE_index); + rrc_eNB_generate_SecurityModeCommand (Mod_id, frameP, UE_index); + // rrc_eNB_generate_UECapabilityEnquiry(Mod_id,frameP,UE_index); } } /*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_SecurityModeCommand (u8 Mod_id, u32 frame, u16 UE_index) +void rrc_eNB_generate_SecurityModeCommand (module_id_t Mod_id, frame_t frameP, u16 UE_index) { uint8_t buffer[100]; uint8_t size; @@ -560,20 +560,20 @@ void rrc_eNB_generate_SecurityModeCommand (u8 Mod_id, u32 frame, u16 UE_index) LOG_I (RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate SecurityModeCommand (bytes %d, UE id %d)\n", - Mod_id, frame, size, UE_index); + Mod_id, frameP, size, UE_index); LOG_D (RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (securityModeCommand to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, DCCH); - //rrc_rlc_data_req(Mod_id,frame, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (Mod_id, UE_index, frame, 1, DCCH, + frameP, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, DCCH); + //rrc_rlc_data_req(Mod_id,frameP, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); + pdcp_rrc_data_req (Mod_id, UE_index, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); } /*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_UECapabilityEnquiry (u8 Mod_id, u32 frame, u16 UE_index) +void rrc_eNB_generate_UECapabilityEnquiry (module_id_t Mod_id, frame_t frameP, u16 UE_index) { uint8_t buffer[100]; @@ -583,20 +583,20 @@ void rrc_eNB_generate_UECapabilityEnquiry (u8 Mod_id, u32 frame, u16 UE_index) LOG_I (RRC, "[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate UECapabilityEnquiry (bytes %d, UE id %d)\n", - Mod_id, frame, size, UE_index); + Mod_id, frameP, size, UE_index); LOG_D (RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (UECapabilityEnquiry to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, DCCH); - //rrc_rlc_data_req(Mod_id,frame, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (Mod_id, UE_index, frame, 1, DCCH, + frameP, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, DCCH); + //rrc_rlc_data_req(Mod_id,frameP, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); + pdcp_rrc_data_req (Mod_id, UE_index, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); } /*------------------------------------------------------------------------------*/ -static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 frame, +static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (module_id_t Mod_id, frame_t frameP, u16 UE_index, u8 ho_state) { @@ -671,7 +671,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 cba_RNTI->buf[1] = 0xff; LOG_D (RRC, "[eNB %d] Frame %d: cba_RNTI = %x in group %d is attribued to UE %d\n", - Mod_id, frame, + Mod_id, frameP, rrc_inst->cba_rnti[UE_index % rrc_inst->num_active_cba_groups], UE_index % rrc_inst->num_active_cba_groups, UE_index); } @@ -680,7 +680,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 cba_RNTI->buf[0] = 0x0; cba_RNTI->buf[1] = 0x0; LOG_D (RRC, "[eNB %d] Frame %d: no cba_RNTI is configured for UE %d\n", - Mod_id, frame, UE_index); + Mod_id, frameP, UE_index); } @@ -952,7 +952,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 ASN_SEQUENCE_ADD (&ReportConfig_list->list, ReportConfig_A1); if (ho_state == 1 /*HO_MEASURMENT*/ ){ - LOG_I(RRC,"[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", Mod_id, frame); + LOG_I(RRC,"[eNB %d] frame %d: requesting A2, A3, A4, A5, and A6 event reporting\n", Mod_id, frameP); ReportConfig_A2->reportConfigId = 3; ReportConfig_A2->reportConfig.present = ReportConfigToAddMod__reportConfig_PR_reportConfigEUTRA; ReportConfig_A2->reportConfig.choice.reportConfigEUTRA.triggerType.present = ReportConfigEUTRA__triggerType_PR_event; @@ -1043,7 +1043,7 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRP = FilterCoefficient_fc4; *quantityConfig->quantityConfigEUTRA->filterCoefficientRSRQ = FilterCoefficient_fc4; - LOG_I(RRC,"[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n",Mod_id, frame); + LOG_I(RRC,"[eNB %d] Frame %d: potential handover preparation: store the information in an intermediate structure in case of failure\n",Mod_id, frameP); // store the information in an intermediate structure for Hanodver management //rrc_inst->handover_info.as_config.sourceRadioResourceConfig.srb_ToAddModList = CALLOC(1,sizeof()); rrc_inst->handover_info[UE_index] = CALLOC(1,sizeof(*(rrc_inst->handover_info[UE_index]))); @@ -1126,22 +1126,22 @@ static void rrc_eNB_generate_defaultRRCConnectionReconfiguration (u8 Mod_id, u32 #endif LOG_I (RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration (bytes %d, UE id %d)\n", - Mod_id, frame, size, UE_index); + Mod_id, frameP, size, UE_index); - LOG_D (RRC,"[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, DCCH); - //rrc_rlc_data_req(Mod_id,frame, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - pdcp_rrc_data_req (Mod_id, UE_index, frame, 1, DCCH, + LOG_D (RRC,"[MSC_MSG][FRAME %05d][RRC_eNB][MOD %u/%u][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration to UE %d MUI %d) --->][PDCP][MOD %u/%u][RB %u]\n", + frameP, Mod_id, UE_index, size, UE_index, rrc_eNB_mui, Mod_id, UE_index, DCCH); + //rrc_rlc_data_req(Mod_id,frameP, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); + pdcp_rrc_data_req (Mod_id, UE_index, frameP, 1, DCCH, rrc_eNB_mui++, 0, size, buffer, 1); } /*------------------------------------------------------------------------------*/ -void rrc_eNB_process_MeasurementReport (u8 Mod_id, u32 frame, u16 UE_index, +void rrc_eNB_process_MeasurementReport (module_id_t Mod_id, frame_t frameP, u16 UE_index, MeasResults_t * measResults2) { LOG_I (RRC,"[eNB %d] Frame %d: Process Measurement Report From UE %d (Measurement Id %d)\n", - Mod_id, frame, UE_index, (int) measResults2->measId); + Mod_id, frameP, UE_index, (int) measResults2->measId); if (measResults2->measResultNeighCells->choice.measResultListEUTRA.list.count > 0) { LOG_I (RRC, "Physical Cell Id %d\n", (int) measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); @@ -1164,11 +1164,11 @@ void rrc_eNB_process_MeasurementReport (u8 Mod_id, u32 frame, u16 UE_index, if(eNB_rrc_inst[Mod_id].handover_info[UE_index]->ho_prepare != 0xF0){ rrc_eNB_generate_HandoverPreparationInformation(Mod_id, - frame, + frameP, UE_index, measResults2->measResultNeighCells->choice.measResultListEUTRA.list.array[0]->physCellId); }else{ - LOG_D(RRC,"[eNB %d] Frame %d: Ignoring MeasReport from UE %d as Handover is in progress... \n",Mod_id,frame, UE_index); + LOG_D(RRC,"[eNB %d] Frame %d: Ignoring MeasReport from UE %d as Handover is in progress... \n",Mod_id,frameP, UE_index); } //Look for IP address of the target eNB //Send Handover Request -> target eNB @@ -1187,7 +1187,7 @@ void rrc_eNB_process_MeasurementReport (u8 Mod_id, u32 frame, u16 UE_index, } /*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_HandoverPreparationInformation (u8 Mod_id, u32 frame, u8 UE_index, PhysCellId_t targetPhyId) { +void rrc_eNB_generate_HandoverPreparationInformation (module_id_t Mod_id, frame_t frameP, u8 UE_index, PhysCellId_t targetPhyId) { u8 UE_id_target; u8 mod_id_target = get_adjacent_cell_mod_id(targetPhyId); HANDOVER_INFO *handoverInfo = CALLOC(1,sizeof(*handoverInfo)); @@ -1233,7 +1233,7 @@ void rrc_eNB_generate_HandoverPreparationInformation (u8 Mod_id, u32 frame, u8 U UE_id_target = rrc_eNB_get_next_free_UE_index(mod_id_target, eNB_rrc_inst[Mod_id].Info.UE_list[UE_index]); //this should return a new index if (UE_id_target!=0xFF) { - LOG_N(RRC,"[eNB %d] Frame %d : Emulate sending HandoverPreparationInformation msg from eNB source %d to eNB target %d: source UE_id %d target UE_id %d source_modId: %d target_modId: %d\n",Mod_id,frame,eNB_rrc_inst[Mod_id].physCellId,targetPhyId,UE_index,UE_id_target,Mod_id,mod_id_target); + LOG_N(RRC,"[eNB %d] Frame %d : Emulate sending HandoverPreparationInformation msg from eNB source %d to eNB target %d: source UE_id %d target UE_id %d source_modId: %d target_modId: %d\n",Mod_id,frameP,eNB_rrc_inst[Mod_id].physCellId,targetPhyId,UE_index,UE_id_target,Mod_id,mod_id_target); eNB_rrc_inst[mod_id_target].handover_info[UE_id_target] = CALLOC(1,sizeof(*(eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]))); memcpy((void *)&eNB_rrc_inst[mod_id_target].handover_info[UE_id_target]->as_context, (void *)&eNB_rrc_inst[Mod_id].handover_info[UE_index]->as_context, @@ -1260,18 +1260,18 @@ void rrc_eNB_generate_HandoverPreparationInformation (u8 Mod_id, u32 frame, u8 U } /*------------------------------------------------------------------------------*/ -void rrc_eNB_process_handoverPreparationInformation(u8 Mod_id,u32 frame, u16 UE_index) { +void rrc_eNB_process_handoverPreparationInformation(module_id_t Mod_id,frame_t frameP, u16 UE_index) { - LOG_I(RRC,"[eNB %d] Frame %d : Logical Channel UL-DCCH, processing RRCHandoverPreparationInformation, sending RRCConnectionReconfiguration to UE %d \n",Mod_id,frame,UE_index); + LOG_I(RRC,"[eNB %d] Frame %d : Logical Channel UL-DCCH, processing RRCHandoverPreparationInformation, sending RRCConnectionReconfiguration to UE %d \n",Mod_id,frameP,UE_index); //eNB_rrc_inst[Mod_id].Info.UE_list[UE_index] - rrc_eNB_generate_RRCConnectionReconfiguration_handover(Mod_id,frame,UE_index,NULL,0); + rrc_eNB_generate_RRCConnectionReconfiguration_handover(Mod_id,frameP,UE_index,NULL,0); } /*------------------------------------------------------------------------------*/ -void check_handovers(u8 Mod_id, u32 frame) { +void check_handovers(module_id_t Mod_id, frame_t frameP) { u8 i; int result; @@ -1279,18 +1279,18 @@ void check_handovers(u8 Mod_id, u32 frame) { if(eNB_rrc_inst[Mod_id].handover_info[i] != NULL) { if(eNB_rrc_inst[Mod_id].handover_info[i]->ho_prepare == 0xFF) { LOG_D(RRC,"[eNB %d] Frame %d: Incoming handover detected for new UE_idx %d (source eNB %d->target eNB %d) \n", - Mod_id, frame, i,Mod_id, eNB_rrc_inst[Mod_id].handover_info[i]->modid_t); + Mod_id, frameP, i,Mod_id, eNB_rrc_inst[Mod_id].handover_info[i]->modid_t); // source eNB generates rrcconnectionreconfiguration to prepare the HO - rrc_eNB_process_handoverPreparationInformation(Mod_id,frame,i); + rrc_eNB_process_handoverPreparationInformation(Mod_id,frameP,i); eNB_rrc_inst[Mod_id].handover_info[i]->ho_prepare = 0xF1; } if(eNB_rrc_inst[Mod_id].handover_info[i]->ho_complete == 0xF1) { LOG_D(RRC,"[eNB %d] Frame %d: handover Command received for new UE_idx %d current eNB %d target eNB: %d \n", - Mod_id, frame, i,Mod_id,eNB_rrc_inst[Mod_id].handover_info[i]->modid_t); - //rrc_eNB_process_handoverPreparationInformation(Mod_id,frame,i); - result = pdcp_data_req(Mod_id, i, frame, 1, - (i* NB_RB_MAX)+DCCH, + Mod_id, frameP, i,Mod_id,eNB_rrc_inst[Mod_id].handover_info[i]->modid_t); + //rrc_eNB_process_handoverPreparationInformation(Mod_id,frameP,i); + result = pdcp_data_req(Mod_id, i, frameP, 1, + DCCH, rrc_eNB_mui++,0, eNB_rrc_inst[Mod_id].handover_info[i]->size, eNB_rrc_inst[Mod_id].handover_info[i]->buf,1); @@ -1303,7 +1303,7 @@ void check_handovers(u8 Mod_id, u32 frame) { /*------------------------------------------------------------------------------*/ // 5.3.5.4 RRCConnectionReconfiguration including the mobilityControlInfo to prepare the UE handover -void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 frame,u16 UE_index,u8 *nas_pdu,u32 nas_length) { +void rrc_eNB_generate_RRCConnectionReconfiguration_handover (module_id_t Mod_id, frame_t frameP,u16 UE_index,u8 *nas_pdu,u32 nas_length) { u8 buffer[RRC_BUF_SIZE]; u16 size; @@ -1365,13 +1365,13 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram struct RRCConnectionReconfiguration_r8_IEs__dedicatedInfoNASList *dedicatedInfoNASList; - LOG_D(RRC,"[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ", Mod_id, frame); + LOG_D(RRC,"[eNB %d] Frame %d: handover preparation: get the newSourceUEIdentity (C-RNTI): ", Mod_id, frameP); for (i=0;i<2;i++) { rv[i]=taus()&0xff; LOG_D(RRC," %x.",rv[i]); } - LOG_D(RRC,"[eNB %d] Frame %d : handover reparation: add target eNB SRB1 and PHYConfigDedicated reconfiguration\n",Mod_id, frame); + LOG_D(RRC,"[eNB %d] Frame %d : handover reparation: add target eNB SRB1 and PHYConfigDedicated reconfiguration\n",Mod_id, frameP); // 1st: reconfigure SRB SRB_configList2 = CALLOC(1,sizeof(*SRB_configList)); SRB1_config = CALLOC(1,sizeof(*SRB1_config)); @@ -1558,7 +1558,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram physicalConfigDedicated2->schedulingRequestConfig->choice.setup.dsr_TransMax = SchedulingRequestConfig__setup__dsr_TransMax_n4; LOG_D(RRC,"handover_config [MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %d) --->][MAC_eNB][MOD %02d][]\n", - frame, Mod_id, UE_index, Mod_id); + frameP, Mod_id, UE_index, Mod_id); rrc_mac_config_req (Mod_id, 1, UE_index, 0, (RadioResourceConfigCommonSIB_t *) NULL, eNB_rrc_inst[Mod_id].physicalConfigDedicated[UE_index], @@ -1913,7 +1913,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram memset((void *)mobilityInfo,0,sizeof(*mobilityInfo)); mobilityInfo->targetPhysCellId = (PhysCellId_t) two_tier_hexagonal_cellIds[rrc_inst->handover_info[UE_index]->modid_t]; LOG_D(RRC,"[eNB %d] Frame %d: handover preparation: targetPhysCellId: %d mod_id: %d UE_index: %d \n", - Mod_id,frame, mobilityInfo->targetPhysCellId,Mod_id,UE_index); + Mod_id,frameP, mobilityInfo->targetPhysCellId,Mod_id,UE_index); mobilityInfo->additionalSpectrumEmission = CALLOC(1,sizeof(*mobilityInfo->additionalSpectrumEmission)); *mobilityInfo->additionalSpectrumEmission = 1; //Check this value! @@ -1999,7 +1999,8 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram sizeof(SPS_Config_t)); */ LOG_I(RRC,"[eNB %d] Frame %d: adding new UE\n"); - Idx = (UE_index * NB_RB_MAX) + DCCH; + //Idx = (UE_index * NB_RB_MAX) + DCCH; + Idx = DCCH; // SRB1 eNB_rrc_inst[Mod_id].Srb1[UE_index].Active = 1; eNB_rrc_inst[Mod_id].Srb1[UE_index].Srb_info.Srb_id = Idx; @@ -2018,10 +2019,10 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram LOG_I (RRC,"[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %d\n",Mod_id, Idx, UE_index); - // rrc_pdcp_config_req (Mod_id, frame, 1, ACTION_ADD, idx, UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(Mod_id,frame,1,ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_pdcp_config_req (Mod_id, frameP, 1, ACTION_ADD, idx, UNDEF_SECURITY_MODE); + // rrc_rlc_config_req(Mod_id,frameP,1,ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - rrc_pdcp_config_asn1_req (Mod_id, UE_index, frame, 1, + rrc_pdcp_config_asn1_req (Mod_id, UE_index, frameP, 1, eNB_rrc_inst[Mod_id].SRB_configList[UE_index], (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL, @@ -2034,7 +2035,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram #endif ); - rrc_rlc_config_asn1_req (Mod_id, frame, 1, UE_index, + rrc_rlc_config_asn1_req (Mod_id, UE_index,frameP, 1, eNB_rrc_inst[Mod_id].SRB_configList[UE_index], (DRB_ToAddModList_t *) NULL, (DRB_ToReleaseList_t *) NULL @@ -2058,7 +2059,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram NULL, NULL, dedicatedInfoNASList); LOG_I (RRC,"[eNB %d] Frame %d, Logical Channel DL-DCCH, Generate RRCConnectionReconfiguration for handover (bytes %d, UE id %d)\n", - Mod_id, frame, size, UE_index); + Mod_id, frameP, size, UE_index); // to be updated if needed /*if (eNB_rrc_inst[Mod_id].SRB1_config[UE_index]->logicalChannelConfig) { if (eNB_rrc_inst[Mod_id].SRB1_config[UE_index]->logicalChannelConfig->present == SRB_ToAddMod__logicalChannelConfig_PR_explicitValue) { @@ -2074,11 +2075,11 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram */ LOG_D (RRC,"[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- PDCP_DATA_REQ/%d Bytes (rrcConnectionReconfiguration_handover to UE %d MUI %d) --->][PDCP][MOD %02d][RB %02d]\n", - frame, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, - (UE_index * NB_RB_MAX) + DCCH); + frameP, Mod_id, size, UE_index, rrc_eNB_mui, Mod_id, + DCCH); - //rrc_rlc_data_req(Mod_id,frame, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); - //pdcp_data_req (Mod_id, frame, 1, (UE_index * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1); + //rrc_rlc_data_req(Mod_id,frameP, 1,(UE_index*NB_RB_MAX)+DCCH,rrc_eNB_mui++,0,size,(char*)buffer); + //pdcp_data_req (Mod_id, frameP, 1, (UE_index * NB_RB_MAX) + DCCH,rrc_eNB_mui++, 0, size, (char *) buffer, 1); rrc_mac_config_req (Mod_id, 1, UE_index, 0, (RadioResourceConfigCommonSIB_t *) NULL, eNB_rrc_inst[Mod_id].physicalConfigDedicated[UE_index], @@ -2120,19 +2121,19 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram eNB_rrc_inst[sourceModId].handover_info[eNB_rrc_inst[Mod_id].handover_info[UE_index]->ueid_s]->ho_complete = 0xF1; //eNB_rrc_inst[Mod_id].handover_info[UE_index]->ho_complete = 0xFF; LOG_D(RRC,"[eNB %d] Frame %d: setting handover complete to 0xF1 for (%d,%d) and to 0xFF for (%d,%d)\n", - Mod_id, frame, + Mod_id, frameP, sourceModId,eNB_rrc_inst[Mod_id].handover_info[UE_index]->ueid_s, Mod_id, UE_index); } else LOG_W(RRC,"[eNB %d] Frame %d: rrc_eNB_generate_RRCConnectionReconfiguration_handover: Could not find source eNB mod_id.\n", - Mod_id, frame); + Mod_id, frameP); } /* - void ue_rrc_process_rrcConnectionReconfiguration(u8 Mod_id,u32 frame, + void ue_rrc_process_rrcConnectionReconfiguration(u8 Mod_id,frame_t frameP, RRCConnectionReconfiguration_t *rrcConnectionReconfiguration, u8 CH_index) { @@ -2140,7 +2141,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.present == RRCConnectionReconfiguration__criticalExtensions__c1_PR_rrcConnectionReconfiguration_r8) { if (rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated) { - rrc_ue_process_radioResourceConfigDedicated(Mod_id,frame,CH_index, + rrc_ue_process_radioResourceConfigDedicated(Mod_id,frameP,CH_index, rrcConnectionReconfiguration->criticalExtensions.choice.c1.choice.rrcConnectionReconfiguration_r8.radioResourceConfigDedicated); @@ -2152,7 +2153,7 @@ void rrc_eNB_generate_RRCConnectionReconfiguration_handover (u8 Mod_id, u32 fram */ /*------------------------------------------------------------------------------*/ -void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, +void rrc_eNB_process_RRCConnectionReconfigurationComplete (module_id_t Mod_id, frame_t frameP, u8 UE_index, RRCConnectionReconfigurationComplete_r8_IEs_t *rrcConnectionReconfigurationComplete) { @@ -2212,7 +2213,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, #endif // Refresh SRBs/DRBs - rrc_pdcp_config_asn1_req (Mod_id, UE_index, frame, 1, + rrc_pdcp_config_asn1_req (Mod_id, UE_index, frameP, 1, SRB_configList, DRB_configList, (DRB_ToReleaseList_t *) NULL, eNB_rrc_inst[Mod_id].ciphering_algorithm[UE_index] | @@ -2225,7 +2226,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, #endif ); // Refresh SRBs/DRBs - rrc_rlc_config_asn1_req (Mod_id, frame, 1, UE_index, + rrc_rlc_config_asn1_req (Mod_id, UE_index, frameP, 1, SRB_configList, DRB_configList, (DRB_ToReleaseList_t *) NULL #ifdef Rel10 @@ -2244,7 +2245,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, { LOG_I (RRC, "[eNB %d] Frame %d : Logical Channel UL-DCCH, Received RRCConnectionReconfigurationComplete from UE %d, reconfiguring DRB %d/LCID %d\n", - Mod_id, frame, UE_index, + Mod_id, frameP, UE_index, (int) DRB_configList->list.array[i]->drb_Identity, (UE_index * NB_RB_MAX) + (int) *DRB_configList->list.array[i]-> @@ -2252,9 +2253,9 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, if (eNB_rrc_inst[Mod_id].DRB_active[UE_index][i] == 0) { /* - rrc_pdcp_config_req (Mod_id, frame, 1, ACTION_ADD, + rrc_pdcp_config_req (Mod_id, frameP, 1, ACTION_ADD, (UE_index * NB_RB_MAX) + *DRB_configList->list.array[i]->logicalChannelIdentity,UNDEF_SECURITY_MODE); - rrc_rlc_config_req(Mod_id,frame,1,ACTION_ADD, + rrc_rlc_config_req(Mod_id,frameP,1,ACTION_ADD, (UE_index * NB_RB_MAX) + (int)*eNB_rrc_inst[Mod_id].DRB_config[UE_index][i]->logicalChannelIdentity, RADIO_ACCESS_BEARER,Rlc_info_um); */ @@ -2262,7 +2263,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, LOG_D (RRC, "[eNB %d] Frame %d: Establish RLC UM Bidirectional, DRB %d Active\n", - Mod_id, frame, + Mod_id, frameP, (int) DRB_configList->list.array[i]->drb_Identity); #ifdef NAS_NETLINK @@ -2308,7 +2309,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, LOG_D (RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (DRB UE %d) --->][MAC_eNB][MOD %02d][]\n", - frame, Mod_id, UE_index, Mod_id); + frameP, Mod_id, UE_index, Mod_id); if (DRB_configList->list.array[i]->logicalChannelIdentity) DRB2LCHAN[i] = (u8) * @@ -2347,18 +2348,18 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, if (eNB_rrc_inst[Mod_id].DRB_active[UE_index][i] == 1) { // DRB has just been removed so remove RLC + PDCP for DRB - /* rrc_pdcp_config_req (Mod_id, frame, 1, ACTION_REMOVE, + /* rrc_pdcp_config_req (Mod_id, frameP, 1, ACTION_REMOVE, (UE_index * NB_RB_MAX) + DRB2LCHAN[i],UNDEF_SECURITY_MODE); */ - rrc_rlc_config_req (Mod_id, frame, 1, ACTION_REMOVE, - (UE_index * NB_RB_MAX) + - DRB2LCHAN[i], RADIO_ACCESS_BEARER, + rrc_rlc_config_req (Mod_id, UE_index, frameP, 1, ACTION_REMOVE, + DRB2LCHAN[i], + RADIO_ACCESS_BEARER, Rlc_info_um); } eNB_rrc_inst[Mod_id].DRB_active[UE_index][i] = 0; LOG_D (RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (DRB UE %d) --->][MAC_eNB][MOD %02d][]\n", - frame, Mod_id, UE_index, Mod_id); + frameP, Mod_id, UE_index, Mod_id); rrc_mac_config_req (Mod_id, 1, UE_index, 0, (RadioResourceConfigCommonSIB_t *) NULL, @@ -2389,7 +2390,7 @@ void rrc_eNB_process_RRCConnectionReconfigurationComplete (u8 Mod_id, u32 frame, } /*------------------------------------------------------------------------------*/ -void rrc_eNB_generate_RRCConnectionSetup (u8 Mod_id, u32 frame, u16 UE_index) { +void rrc_eNB_generate_RRCConnectionSetup (module_id_t Mod_id, frame_t frameP, u16 UE_index) { LogicalChannelConfig_t *SRB1_logicalChannelConfig; //,*SRB2_logicalChannelConfig; SRB_ToAddModList_t **SRB_configList; @@ -2441,7 +2442,7 @@ void rrc_eNB_generate_RRCConnectionSetup (u8 Mod_id, u32 frame, u16 UE_index) { LOG_D (RRC, "[MSC_MSG][FRAME %05d][RRC_eNB][MOD %02d][][--- MAC_CONFIG_REQ (SRB1 UE %d) --->][MAC_eNB][MOD %02d][]\n", - frame, Mod_id, UE_index, Mod_id); + frameP, Mod_id, UE_index, Mod_id); rrc_mac_config_req (Mod_id, 1, UE_index, 0, (RadioResourceConfigCommonSIB_t *) NULL, eNB_rrc_inst[Mod_id].physicalConfigDedicated[UE_index], @@ -2471,14 +2472,14 @@ void rrc_eNB_generate_RRCConnectionSetup (u8 Mod_id, u32 frame, u16 UE_index) { } LOG_I (RRC, "[eNB %d][RAPROC] Frame %d : Logical Channel DL-CCCH, Generating RRCConnectionSetup (bytes %d, UE %d)\n", - Mod_id, frame, eNB_rrc_inst[Mod_id].Srb0.Tx_buffer.payload_size, + Mod_id, frameP, eNB_rrc_inst[Mod_id].Srb0.Tx_buffer.payload_size, UE_index); } /*------------------------------------------------------------------------------*/ #if defined(ENABLE_ITTI) -char openair_rrc_lite_eNB_init (u8 Mod_id) +char openair_rrc_lite_eNB_init (module_id_t Mod_id) { /* Dummy function, initialization will be done through ITTI messaging */ return 0; @@ -2594,7 +2595,7 @@ char openair_rrc_lite_eNB_init (u8 Mod_id) } /*------------------------------------------------------------------------------*/ -int rrc_eNB_decode_ccch (u8 Mod_id, u32 frame, SRB_INFO * Srb_info) +int rrc_eNB_decode_ccch (module_id_t Mod_id, frame_t frameP, SRB_INFO * Srb_info) { /*------------------------------------------------------------------------------*/ @@ -2610,7 +2611,7 @@ int rrc_eNB_decode_ccch (u8 Mod_id, u32 frame, SRB_INFO * Srb_info) //memset(ul_ccch_msg,0,sizeof(UL_CCCH_Message_t)); LOG_T (RRC, "[eNB %d] Frame %d: Decoding UL CCCH %x.%x.%x.%x.%x.%x (%p)\n", - Mod_id, frame, ((uint8_t *) Srb_info->Rx_buffer.Payload)[0], + Mod_id, frameP, ((uint8_t *) Srb_info->Rx_buffer.Payload)[0], ((uint8_t *) Srb_info->Rx_buffer.Payload)[1], ((uint8_t *) Srb_info->Rx_buffer.Payload)[2], ((uint8_t *) Srb_info->Rx_buffer.Payload)[3], @@ -2665,19 +2666,19 @@ for (i = 0; i < 8; i++) case UL_CCCH_MessageType__c1_PR_NOTHING: LOG_I (RRC, "[eNB %d] Frame %d : Received PR_NOTHING on UL-CCCH-Message\n", - Mod_id, frame); + Mod_id, frameP); break; case UL_CCCH_MessageType__c1_PR_rrcConnectionReestablishmentRequest: LOG_D (RRC, "[MSC_MSG][FRAME %05d][MAC_eNB][MOD %02d][][--- MAC_DATA_IND (rrcConnectionReestablishmentRequest on SRB0) -->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, Mod_id); + frameP, Mod_id, Mod_id); LOG_I (RRC, "[eNB %d] Frame %d : RRCConnectionReestablishmentRequest not supported yet\n", - Mod_id, frame); + Mod_id, frameP); break; case UL_CCCH_MessageType__c1_PR_rrcConnectionRequest: LOG_D (RRC, "[MSC_MSG][FRAME %05d][MAC_eNB][MOD %02d][][--- MAC_DATA_IND (rrcConnectionRequest on SRB0) -->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, Mod_id); + frameP, Mod_id, Mod_id); rrcConnectionRequest = &ul_ccch_msg->message.choice.c1.choice.rrcConnectionRequest.criticalExtensions.choice.rrcConnectionRequest_r8; { @@ -2708,7 +2709,7 @@ for (i = 0; i < 8; i++) (u8 *) rrcConnectionRequest->ue_Identity.choice.randomValue.buf, 5); LOG_I (RRC, "[eNB %d] Frame %d : Accept new connection from UE %d (0x%" PRIx64 ")\n", - Mod_id, frame, UE_index, + Mod_id, frameP, UE_index, eNB_rrc_inst[Mod_id].Info.UE_list[UE_index]); //CONFIG SRB2 (DCCHs, ONE per User) //meas && lchan Cfg @@ -2720,7 +2721,8 @@ for (i = 0; i < 8; i++) send_msg (&S_rrc, msg_rrc_MR_attach_ind (Mod_id, Mac_id)); #else - Idx = (UE_index * NB_RB_MAX) + DCCH; + //LG COMMENT Idx = (UE_index * NB_RB_MAX) + DCCH; + Idx = DCCH; // SRB1 eNB_rrc_inst[Mod_id].Srb1[UE_index].Active = 1; eNB_rrc_inst[Mod_id].Srb1[UE_index].Srb_info.Srb_id = Idx; @@ -2737,19 +2739,19 @@ for (i = 0; i < 8; i++) memcpy (&eNB_rrc_inst[Mod_id].Srb2[UE_index].Srb_info. Lchan_desc[1], &DCCH_LCHAN_DESC, LCHAN_DESC_SIZE); - rrc_eNB_generate_RRCConnectionSetup (Mod_id, frame, UE_index); + rrc_eNB_generate_RRCConnectionSetup (Mod_id, frameP, UE_index); //LOG_D(RRC, "[MSC_NBOX][FRAME %05d][RRC_eNB][MOD %02d][][Tx RRCConnectionSetup][RRC_eNB][MOD %02d][]\n", - // frame, Mod_id, Mod_id); + // frameP, Mod_id, Mod_id); //LOG_D(RRC,"[eNB %d] RLC AM allocation index@0 is %d\n",Mod_id,rlc[Mod_id].m_rlc_am_array[0].allocation); //LOG_D(RRC,"[eNB %d] RLC AM allocation index@1 is %d\n",Mod_id,rlc[Mod_id].m_rlc_am_array[1].allocation); LOG_I (RRC,"[eNB %d] CALLING RLC CONFIG SRB1 (rbid %d) for UE %d\n",Mod_id, Idx, UE_index); - // rrc_pdcp_config_req (Mod_id, frame, 1, ACTION_ADD, idx, UNDEF_SECURITY_MODE); + // rrc_pdcp_config_req (Mod_id, frameP, 1, ACTION_ADD, idx, UNDEF_SECURITY_MODE); - // rrc_rlc_config_req(Mod_id,frame,1,ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); + // rrc_rlc_config_req(Mod_id,frameP,1,ACTION_ADD,Idx,SIGNALLING_RADIO_BEARER,Rlc_info_am_config); - rrc_pdcp_config_asn1_req (Mod_id, UE_index, frame, 1, + rrc_pdcp_config_asn1_req (Mod_id, UE_index, frameP, 1, eNB_rrc_inst[Mod_id]. SRB_configList[UE_index], (DRB_ToAddModList_t *) NULL, @@ -2763,7 +2765,7 @@ for (i = 0; i < 8; i++) #endif ); - rrc_rlc_config_asn1_req (Mod_id, frame, 1, UE_index, + rrc_rlc_config_asn1_req (Mod_id, UE_index, frameP, 1, eNB_rrc_inst[Mod_id]. SRB_configList[UE_index], (DRB_ToAddModList_t *) NULL, @@ -2792,7 +2794,7 @@ for (i = 0; i < 8; i++) break; default: - LOG_E (RRC, "[eNB %d] Frame %d : Unknown message\n", Mod_id, frame); + LOG_E (RRC, "[eNB %d] Frame %d : Unknown message\n", Mod_id, frameP); rval = -1; break; } @@ -2800,14 +2802,14 @@ for (i = 0; i < 8; i++) } else { - LOG_E (RRC, "[eNB %d] Frame %d : Unknown error \n", Mod_id, frame); + LOG_E (RRC, "[eNB %d] Frame %d : Unknown error \n", Mod_id, frameP); rval = -1; } return rval; } /*------------------------------------------------------------------------------*/ -int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, +int rrc_eNB_decode_dcch (module_id_t Mod_id, frame_t frameP, u8 Srb_id, u8 UE_index, u8 * Rx_sdu, u8 sdu_size) { /*------------------------------------------------------------------------------*/ @@ -2820,12 +2822,12 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, if ((Srb_id != 1) && (Srb_id != 2)) { LOG_E (RRC, "[eNB %d] Frame %d: Received message on SRB%d, should not have ...\n", - Mod_id, frame, Srb_id); + Mod_id, frameP, Srb_id); } //memset(ul_dcch_msg,0,sizeof(UL_DCCH_Message_t)); - LOG_D (RRC, "[eNB %d] Frame %d: Decoding UL-DCCH Message\n", Mod_id, frame); + LOG_D (RRC, "[eNB %d] Frame %d: Decoding UL-DCCH Message\n", Mod_id, frameP); dec_rval = uper_decode (NULL, &asn_DEF_UL_DCCH_Message, (void **) &ul_dcch_msg, Rx_sdu, sdu_size, 0, 0); @@ -2870,7 +2872,7 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, if ((dec_rval.code != RC_OK) && (dec_rval.consumed == 0)) { LOG_E (RRC, "[UE %d] Frame %d : Failed to decode UL-DCCH (%d bytes)\n", - Mod_id, frame, dec_rval.consumed); + Mod_id, frameP, dec_rval.consumed); return -1; } @@ -2889,8 +2891,8 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND " "%d bytes (measurementReport) --->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, DCCH, sdu_size, Mod_id); - rrc_eNB_process_MeasurementReport (Mod_id, frame, UE_index, + frameP, Mod_id, DCCH, sdu_size, Mod_id); + rrc_eNB_process_MeasurementReport (Mod_id, frameP, UE_index, &ul_dcch_msg->message.choice.c1. choice.measurementReport. criticalExtensions.choice.c1. @@ -2902,14 +2904,14 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " "(RRCConnectionReconfigurationComplete) --->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, DCCH, sdu_size, Mod_id); + frameP, Mod_id, DCCH, sdu_size, Mod_id); if (ul_dcch_msg->message.choice.c1.choice. rrcConnectionReconfigurationComplete.criticalExtensions. present == RRCConnectionReconfigurationComplete__criticalExtensions_PR_rrcConnectionReconfigurationComplete_r8) { rrc_eNB_process_RRCConnectionReconfigurationComplete (Mod_id, - frame, + frameP, UE_index, &ul_dcch_msg-> message. @@ -2938,14 +2940,14 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " "(rrcConnectionReestablishmentComplete) --->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, DCCH, sdu_size, Mod_id); + frameP, Mod_id, DCCH, sdu_size, Mod_id); break; case UL_DCCH_MessageType__c1_PR_rrcConnectionSetupComplete: LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " "(RRCConnectionSetupComplete) --->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, DCCH, sdu_size, Mod_id); + frameP, Mod_id, DCCH, sdu_size, Mod_id); if (ul_dcch_msg->message.choice.c1.choice. rrcConnectionSetupComplete.criticalExtensions.present == @@ -2956,7 +2958,7 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, present == RRCConnectionSetupComplete__criticalExtensions__c1_PR_rrcConnectionSetupComplete_r8) { - rrc_eNB_process_RRCConnectionSetupComplete (Mod_id, frame, + rrc_eNB_process_RRCConnectionSetupComplete (Mod_id, frameP, UE_index, &ul_dcch_msg-> message.choice. @@ -2972,7 +2974,7 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, LOG_D (RRC, "[MSC_NBOX][FRAME %05d][RRC_eNB][MOD %02d][][Rx RRCConnectionSetupComplete\n" "Now CONNECTED with UE %d][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, UE_index, Mod_id); + frameP, Mod_id, UE_index, Mod_id); } } break; @@ -2980,24 +2982,24 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, case UL_DCCH_MessageType__c1_PR_securityModeComplete: LOG_I (RRC, "[eNB %d] Frame %d received securityModeComplete on UL-DCCH %d from UE %d\n", - Mod_id, frame, DCCH, UE_index); + Mod_id, frameP, DCCH, UE_index); LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(securityModeComplete) --->][RRC_eNB][MOD %02d][]\n", frame, + "(securityModeComplete) --->][RRC_eNB][MOD %02d][]\n", frameP, Mod_id, DCCH, sdu_size, Mod_id); #ifdef XER_PRINT xer_fprint (stdout, &asn_DEF_UL_DCCH_Message, (void *) ul_dcch_msg); #endif // confirm with PDCP about the security mode for DCCH - //rrc_pdcp_config_req (Mod_id, frame, 1,ACTION_SET_SECURITY_MODE, (UE_index * NB_RB_MAX) + DCCH, 0x77); + //rrc_pdcp_config_req (Mod_id, frameP, 1,ACTION_SET_SECURITY_MODE, (UE_index * NB_RB_MAX) + DCCH, 0x77); // continue the procedure - rrc_eNB_generate_UECapabilityEnquiry (Mod_id, frame, UE_index); + rrc_eNB_generate_UECapabilityEnquiry (Mod_id, frameP, UE_index); break; case UL_DCCH_MessageType__c1_PR_securityModeFailure: LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " - "(securityModeFailure) --->][RRC_eNB][MOD %02d][]\n", frame, + "(securityModeFailure) --->][RRC_eNB][MOD %02d][]\n", frameP, Mod_id, DCCH, sdu_size, Mod_id); #ifdef XER_PRINT xer_fprint (stdout, &asn_DEF_UL_DCCH_Message, (void *) ul_dcch_msg); @@ -3005,17 +3007,17 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, // cancel the security mode in PDCP // followup with the remaining procedure - rrc_eNB_generate_UECapabilityEnquiry (Mod_id, frame, UE_index); + rrc_eNB_generate_UECapabilityEnquiry (Mod_id, frameP, UE_index); break; case UL_DCCH_MessageType__c1_PR_ueCapabilityInformation: LOG_I (RRC, "[eNB %d] Frame %d received ueCapabilityInformation on UL-DCCH %d from UE %d\n", - Mod_id, frame, DCCH, UE_index); + Mod_id, frameP, DCCH, UE_index); LOG_D (RRC, "[MSC_MSG][FRAME %05d][RLC][MOD %02d][RB %02d][--- RLC_DATA_IND %d bytes " "(UECapabilityInformation) --->][RRC_eNB][MOD %02d][]\n", - frame, Mod_id, DCCH, sdu_size, Mod_id); + frameP, Mod_id, DCCH, sdu_size, Mod_id); #ifdef XER_PRINT xer_fprint (stdout, &asn_DEF_UL_DCCH_Message, (void *) ul_dcch_msg); #endif @@ -3045,7 +3047,7 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, } #endif - rrc_eNB_generate_defaultRRCConnectionReconfiguration (Mod_id, frame, + rrc_eNB_generate_defaultRRCConnectionReconfiguration (Mod_id, frameP, UE_index, eNB_rrc_inst[Mod_id].HO_flag); break; @@ -3083,14 +3085,14 @@ int rrc_eNB_decode_dcch (u8 Mod_id, u32 frame, u8 Srb_id, u8 UE_index, #endif default: - LOG_E (RRC, "[UE %d] Frame %d : Unknown message\n", Mod_id, frame); + LOG_E (RRC, "[UE %d] Frame %d : Unknown message\n", Mod_id, frameP); return -1; } return 0; } else { - LOG_E (RRC, "[UE %d] Frame %d : Unknown error\n", Mod_id, frame); + LOG_E (RRC, "[UE %d] Frame %d : Unknown error\n", Mod_id, frameP); return -1; } @@ -3125,7 +3127,7 @@ void *rrc_enb_task(void *args_p) { /* Messages from MAC */ case RRC_MAC_CCCH_DATA_IND: - LOG_I(RRC, "[eNB %d] Received %s: frame %d,\n", instance, msg_name, + LOG_I(RRC, "[eNB %d] Received %s: frameP %d,\n", instance, msg_name, RRC_MAC_CCCH_DATA_IND (msg_p).frame); srb_info_p = &eNB_rrc_inst[instance].Srb0; @@ -3138,7 +3140,7 @@ void *rrc_enb_task(void *args_p) { /* Messages from PDCP */ case RRC_DCCH_DATA_IND: - LOG_I(RRC, "[eNB %d][UE %d] Received %s: frame %d, DCCH %d\n", instance, RRC_DCCH_DATA_IND (msg_p).ue_index, msg_name, + LOG_I(RRC, "[eNB %d][UE %d] Received %s: frameP %d, DCCH %d\n", instance, RRC_DCCH_DATA_IND (msg_p).ue_index, msg_name, RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index); rrc_eNB_decode_dcch (instance, RRC_DCCH_DATA_IND (msg_p).frame, RRC_DCCH_DATA_IND (msg_p).dcch_index, diff --git a/openair2/UTIL/OCG/OCG.h b/openair2/UTIL/OCG/OCG.h index 8c82a5508657d2b6652dd9b09545930d2e3dbfce..8550f27f9ca79ca377202bab77ceb0befaefef7d 100644 --- a/openair2/UTIL/OCG/OCG.h +++ b/openair2/UTIL/OCG/OCG.h @@ -45,6 +45,7 @@ #define __OCG_H__ #include "PHY/impl_defs_top.h" +#include "platform_types.h" #if defined(ENABLE_USE_MME) # include "s1ap_eNB.h" @@ -625,9 +626,9 @@ The following diagram is based on graphviz (http://www.graphviz.org/), you need typedef struct { unsigned char nb_ue; - unsigned char first_ue; + module_id_t first_ue; unsigned char nb_enb; - unsigned char first_enb; + module_id_t first_enb; } master_info_t; typedef struct @@ -643,9 +644,9 @@ The following diagram is based on graphviz (http://www.graphviz.org/), you need unsigned char nb_enb_remote; unsigned char nb_rn_local; unsigned char nb_rn_remote; - unsigned char first_enb_local; - unsigned char first_rn_local; - unsigned char first_ue_local; + module_id_t first_enb_local; + module_id_t first_rn_local; + module_id_t first_ue_local; unsigned short master_id; unsigned char nb_master; unsigned int master_list; diff --git a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_main.c b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_main.c index 14ecd591fb78ff8004a0122a76ccd9371a3e5b93..b56b675a516031ec0cacf10de00204c7f4bd24b9 100755 --- a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_main.c +++ b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_main.c @@ -2,9 +2,9 @@ * Eurecom OpenAirInterface 3 * Copyright(c) 2012 Eurecom * - * Source eRALlte_main.c + * Source lteRALenb_main.c * Version 0.1 - * Date 06/22/2012 + * Date 01/17/2014 * Product MIH RAL LTE * Subsystem RAL main process running at the network side * Authors Michelle Wetterwald, Lionel Gauthier, Frederic Maurel @@ -20,26 +20,19 @@ #define LTE_RAL_ENB_MAIN_C //----------------------------------------------------------------------------- #include <stdio.h> -# include <sys/epoll.h> +#include <sys/epoll.h> #include <sys/select.h> #include <net/if.h> #include <getopt.h> #include <stdlib.h> #include <time.h> //----------------------------------------------------------------------------- +#include "assertions.h" #include "lteRALenb.h" #include "intertask_interface.h" #include "OCG.h" //----------------------------------------------------------------------------- -// LTE AS sub-system -//#include "nas_ue_ioctl.h" - -#ifdef RAL_REALTIME -//LG#include "rrc_nas_primitives.h" -//LG#include "nasrg_constant.h" -//LG#include "nasrg_iocontrol.h" -#endif /****************************************************************************/ @@ -47,174 +40,10 @@ /****************************************************************************/ extern OAI_Emulation oai_emulation; -//int init_flag = 0; - /****************************************************************************/ /******************* L O C A L D E F I N I T I O N S *******************/ /****************************************************************************/ -// static struct ral_lte_priv rl_priv; -// // -// static void arg_usage(const char* name); -// static int parse_opts(int argc, char* argv[]); -// static void NAS_Netlink_socket_init(void); -// static void get_IPv6_addr(const char* if_name); -// static int RAL_initialize(int argc, const char *argv[]); - -//struct ral_lte_priv rl_priv; - -// void arg_usage(const char* name); -// int parse_opts(int argc, char* argv[]); -// void get_IPv6_addr(const char* if_name); -// int RAL_initialize(int argc, const char *argv[]); - - - -/****************************************************************************/ -// Next part is used to receive the triggers -/****************************************************************************/ -/* -#ifdef MUSER_CONTROL - -#define USER_IP_ADDRESS "127.0.0.1" -#define USER_REMOTE_PORT "0" -#define NAS_IP_ADDRESS "127.0.0.1" -#define NAS_LISTENING_PORT_FOR_USER "22222" - -int g_sockd_user; -signed int g_user_congestion = 0; -unsigned int g_ratio_modif = 0; -//--------------------------------------------------------------------------- -int lteRALenb_trigger_connect(void){ -//--------------------------------------------------------------------------- - struct addrinfo hints; - struct addrinfo *result, *rp; - int s, on; - struct sockaddr_in *addr = NULL; - struct sockaddr_in6 *addr6 = NULL; - unsigned char buf[sizeof(struct sockaddr_in6)]; - - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 - hints.ai_socktype = SOCK_DGRAM; // Datagram socket - hints.ai_flags = 0; - hints.ai_protocol = 0; // Any protocol - - s = getaddrinfo(g_mih_user_ip_address, g_mih_user_remote_port, &hints, &result); - if (s != 0) { - LOG_E (RAL_ENB,"getaddrinfo: %s\n", gai_strerror(s)); - return -1; - } - - for (rp = result; rp != NULL; rp = rp->ai_next) { - g_sockd_user = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); - if (g_sockd_user == -1) - continue; - - on = 1; - setsockopt( g_sockd_user, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); - - if(rp->ai_family == AF_INET) { - LOG_D (RAL_ENB, "Destination address %s is an ipv4 address\n",g_mih_user_ip_address); - addr = (struct sockaddr_in *)(&buf[0]); - addr->sin_port = htons(atoi(g_nas_listening_port_for_mih_user)); - addr->sin_family = AF_INET; - s = inet_pton(AF_INET, g_nas_ip_address, &addr->sin_addr); - if (s <= 0) { - if (s == 0) { - LOG_E (RAL_ENB, " IP address should be a IPv4 ADDR - But found not in presentation format : %s\n", g_nas_ip_address); - } else { - LOG_E (RAL_ENB, " %s - inet_pton( IPv4 ADDR %s): %s\n", __FUNCTION__, g_nas_ip_address, strerror(s)); - } - return -1; - } - - s = bind(g_sockd_user, (const struct sockaddr *)addr, sizeof(struct sockaddr_in)); - if (s == -1) { - LOG_D (RAL_ENB, "IPv4 Address Bind: %s\n", strerror(errno)); - return -1; - } - // sockd_mihf is of type SOCK_DGRAM, rp->ai_addr is the address to which datagrams are sent by default - if (connect(g_sockd_user, rp->ai_addr, rp->ai_addrlen) != -1) { - LOG_D (RAL_ENB, " lteRALeNB is now ready to receive triggers\n"); - return 0; - } else { - close(g_sockd_user); - } - } else if (rp->ai_family == AF_INET6) { - LOG_D (RAL_ENB, "Destination address %s is an ipv6 address\n",g_mih_user_ip_address); - addr6 = (struct sockaddr_in6 *)(&buf[0]); - addr6->sin6_port = htons(atoi(g_nas_listening_port_for_mih_user)); - addr6->sin6_family = AF_INET6; - s = inet_pton(AF_INET, g_nas_ip_address, &addr6->sin6_addr); - if (s <= 0) { - if (s == 0) { - LOG_E (RAL_ENB, "IP address should be a IPv6 ADDR, But found not in presentation format : %s\n", g_nas_ip_address); - } else { - LOG_E (RAL_ENB, "%s - inet_pton( IPv6 ADDR %s): %s\n", __FUNCTION__, g_nas_ip_address, strerror(s)); - } - return -1; - } - - s = bind(g_sockd_user, (const struct sockaddr *)addr6, sizeof(struct sockaddr_in)); - if (s == -1) { - LOG_D (RAL_ENB, "IPv6 Address Bind: %s\n", strerror(errno)); - return -1; - } - if (connect(g_sockd_user, rp->ai_addr, rp->ai_addrlen) != -1) { - LOG_D (RAL_ENB, "lteRALeNB is now ready to receive triggers\n"); - return 0; - } else { - close(g_sockd_user); - } - } else { - LOG_E (RAL_ENB, "%s is an unknown address format %d\n",g_mih_user_ip_address,rp->ai_family); - } - close(g_sockd_user); - } - - if (rp == NULL) { // No address succeeded - LOG_E (RAL_ENB, "Could not establish socket to MIH-User\n"); - return -1; - } - return -1; -} - -//--------------------------------------------------------------------------- -int lteRALenb_trigger_receive(int sock){ -//--------------------------------------------------------------------------- - unsigned char str[50]; - int t, done; - t=recv(sock, str, 50, 0); - if (t <= 0) { - if (t < 0) perror("lteRALenb_trigger_receive : recv"); - done = 1; - } - printf("\nmessage from USER, length: %d\n", t); - switch (str[0]) { - case 0xff: - printf("USER ASK FOR STOPPING CONGESTION - not supported yet\n"); - break; - case 0x01: - printf("USER ASK FOR TRIGGERING CONGESTION\n"); - g_enb_ral_obj[instanceP].rlcBufferOccupancy[0] = 95; - RAL_NAS_report_congestion(0); - break; - default: - printf("received %hx\n", str[0]); - return -1; - } - return 0; -} - -#endif - */ -/****************************************************************************/ - - - - /**************************************************************************** ** Name: get_IPv6_addr() ** ** Description: Gets the IPv6 address of the specified network interface. ** @@ -309,6 +138,7 @@ void eRAL_init_default_values(void) { int eRAL_initialize(void){ //----------------------------------------------------------------------------- ral_enb_instance_t instance = 0; + unsigned int mod_id = 0; char *char_tmp = NULL; MIH_C_init(); @@ -319,27 +149,29 @@ int eRAL_initialize(void){ g_enb_ral_fd2instance = hashtable_create (32, NULL, hash_free_int_func); - for (instance = 0; instance < oai_emulation.info.nb_enb_local; instance++) { + for (mod_id = 0; mod_id < oai_emulation.info.nb_enb_local; mod_id++) { char_tmp = calloc(1, strlen(g_conf_enb_ral_listening_port) + 3); // 2 digits + \0 ->99 instances - sprintf(char_tmp,"%d", atoi(g_conf_enb_ral_listening_port) + instance); - g_enb_ral_obj[instance].ral_listening_port = char_tmp; + instance = mod_id; + + sprintf(char_tmp,"%d", atoi(g_conf_enb_ral_listening_port) + mod_id); + g_enb_ral_obj[mod_id].ral_listening_port = char_tmp; - g_enb_ral_obj[instance].ral_ip_address = strdup(g_conf_enb_ral_ip_address); - g_enb_ral_obj[instance].ral_link_address = strdup(g_conf_enb_ral_link_address); + g_enb_ral_obj[mod_id].ral_ip_address = strdup(g_conf_enb_ral_ip_address); + g_enb_ral_obj[mod_id].ral_link_address = strdup(g_conf_enb_ral_link_address); char_tmp = calloc(1, strlen(g_conf_enb_mihf_remote_port) + 3); // 2 digits + \0 ->99 instances sprintf(char_tmp, "%d", atoi(g_conf_enb_mihf_remote_port) + instance); - g_enb_ral_obj[instance].mihf_remote_port = char_tmp; + g_enb_ral_obj[mod_id].mihf_remote_port = char_tmp; - g_enb_ral_obj[instance].mihf_ip_address = strdup(g_conf_enb_mihf_ip_address); + g_enb_ral_obj[mod_id].mihf_ip_address = strdup(g_conf_enb_mihf_ip_address); char_tmp = calloc(1, strlen(g_conf_enb_mihf_id) + 3); // 2 digits + \0 ->99 instances sprintf(char_tmp, "%s%02d",g_conf_enb_mihf_id, instance); - g_enb_ral_obj[instance].mihf_id = char_tmp; + g_enb_ral_obj[mod_id].mihf_id = char_tmp; char_tmp = calloc(1, strlen(g_conf_enb_ral_link_id) + 3); // 2 digits + \0 ->99 instances - sprintf(char_tmp, "%s%02d",g_conf_enb_ral_link_id, instance); - g_enb_ral_obj[instance].link_id = char_tmp; + sprintf(char_tmp, "%s%02d",g_conf_enb_ral_link_id, mod_id); + g_enb_ral_obj[mod_id].link_id = char_tmp; char_tmp = NULL; // excluded MIH_C_LINK_AC_TYPE_NONE @@ -347,7 +179,7 @@ int eRAL_initialize(void){ // excluded MIH_C_LINK_AC_TYPE_LINK_LOW_POWER // excluded MIH_C_LINK_AC_TYPE_LINK_POWER_DOWN // excluded MIH_C_LINK_AC_TYPE_LINK_POWER_UP - g_enb_ral_obj[instance].mih_supported_link_action_list = (1 << MIH_C_LINK_AC_TYPE_LINK_FLOW_ATTR) | + g_enb_ral_obj[mod_id].mih_supported_link_action_list = (1 << MIH_C_LINK_AC_TYPE_LINK_FLOW_ATTR) | (1 << MIH_C_LINK_AC_TYPE_LINK_ACTIVATE_RESOURCES) | (1 << MIH_C_LINK_AC_TYPE_LINK_DEACTIVATE_RESOURCES); // excluded MIH_C_BIT_LINK_DETECTED @@ -355,105 +187,32 @@ int eRAL_initialize(void){ // excluded MIH_C_BIT_LINK_HANDOVER_IMMINENT // excluded MIH_C_BIT_LINK_HANDOVER_COMPLETE // excluded MIH_C_BIT_LINK_PDU_TRANSMIT_STATUS - g_enb_ral_obj[instance].mih_supported_link_event_list = MIH_C_BIT_LINK_UP | MIH_C_BIT_LINK_DOWN | MIH_C_BIT_LINK_PARAMETERS_REPORT; + g_enb_ral_obj[mod_id].mih_supported_link_event_list = MIH_C_BIT_LINK_UP | MIH_C_BIT_LINK_DOWN | MIH_C_BIT_LINK_PARAMETERS_REPORT; // excluded MIH_C_BIT_LINK_GET_PARAMETERS // excluded MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS - g_enb_ral_obj[instance].mih_supported_link_command_list = MIH_C_BIT_LINK_EVENT_SUBSCRIBE | MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS | + g_enb_ral_obj[mod_id].mih_supported_link_command_list = MIH_C_BIT_LINK_EVENT_SUBSCRIBE | MIH_C_BIT_LINK_CONFIGURE_THRESHOLDS | MIH_C_BIT_LINK_EVENT_UNSUBSCRIBE | MIH_C_BIT_LINK_ACTION; - g_enb_ral_obj[instance].link_mihcap_flag = MIH_C_BIT_EVENT_SERVICE_SUPPORTED | MIH_C_BIT_COMMAND_SERVICE_SUPPORTED | MIH_C_BIT_INFORMATION_SERVICE_SUPPORTED; + g_enb_ral_obj[mod_id].link_mihcap_flag = MIH_C_BIT_EVENT_SERVICE_SUPPORTED | MIH_C_BIT_COMMAND_SERVICE_SUPPORTED | MIH_C_BIT_INFORMATION_SERVICE_SUPPORTED; - g_enb_ral_obj[instance].net_caps = MIH_C_BIT_NET_CAPS_QOS_CLASS5 | MIH_C_BIT_NET_CAPS_INTERNET_ACCESS | MIH_C_BIT_NET_CAPS_MIH_CAPABILITY; + g_enb_ral_obj[mod_id].net_caps = MIH_C_BIT_NET_CAPS_QOS_CLASS5 | MIH_C_BIT_NET_CAPS_INTERNET_ACCESS | MIH_C_BIT_NET_CAPS_MIH_CAPABILITY; - g_enb_ral_obj[instance].transaction_id = (MIH_C_TRANSACTION_ID_T)rand(); + g_enb_ral_obj[mod_id].transaction_id = (MIH_C_TRANSACTION_ID_T)rand(); - //LOG_N(RAL_ENB, "[MSC_NEW][%s][MIH-F=%s]\n", getTimeStamp4Log(), g_mihf_id); - //LOG_N(RAL_ENB, "[MSC_NEW][%s][RAL=%s]\n", getTimeStamp4Log(), g_link_id); - //LOG_N(RAL_ENB, "[MSC_NEW][%s][NAS=%s]\n", getTimeStamp4Log(), "nas"); + g_enb_ral_obj[mod_id].ue_htbl = hashtable_create(32, NULL, NULL); - g_enb_ral_obj[instance].ue_htbl = hashtable_create(32, NULL, NULL); - - LOG_D(RAL_ENB, " Connect to the MIH-F for instance %d...\n", instance); - g_enb_ral_obj[instance].mih_sock_desc = -1; - if (eRAL_mihf_connect(instance) < 0 ) { - LOG_E(RAL_ENB, " %s : Could not connect to MIH-F...\n", __FUNCTION__); - // TO DO RETRY LATER - //exit(-1); - } else { - itti_subscribe_event_fd(TASK_RAL_ENB, g_enb_ral_obj[instance].mih_sock_desc); - hashtable_insert(g_enb_ral_fd2instance, g_enb_ral_obj[instance].mih_sock_desc, (void*)instance); - } + LOG_D(RAL_ENB, " Connect to the MIH-F for module id instance %d...\n", mod_id, instance); + g_enb_ral_obj[mod_id].mih_sock_desc = -1; + AssertFatal(eRAL_mihf_connect(instance) >= 0, " %s : Could not connect to MIH-F...\n", __FUNCTION__); + itti_subscribe_event_fd(TASK_RAL_ENB, g_enb_ral_obj[mod_id].mih_sock_desc); + hashtable_insert(g_enb_ral_fd2instance, g_enb_ral_obj[mod_id].mih_sock_desc, (void*)instance); + + eRAL_send_link_register_indication(instance, &g_enb_ral_obj[mod_id].transaction_id); + g_enb_ral_obj[mod_id].transaction_id += 1; } - - - - - - /*Initialize the NAS driver communication channel - */ -#ifdef RAL_REALTIME - //LG IAL_NAS_ioctl_init(); -#endif -#ifdef RAL_DUMMY - //LG NAS_Netlink_socket_init(); - //LG LOG_D(RAL_ENB, " Waiting for a connection from the NAS Driver ...\n"); - //LG t = sizeof(nas_socket); - //LG if ((g_sockd_nas = accept(netl_s, (struct sockaddr *)&nas_socket, &t)) == -1) { - //LG perror("RAL_initialize : g_sockd_nas - accept() failed"); - //LG exit(1); - //LG } -#endif - LOG_D(RAL_ENB, "NAS Driver Connected.\n\n"); - - /* Start listening to user commands for triggers*/ -#ifdef MUSER_CONTROL - //LG lteRALenb_trigger_connect(); -#endif - - - /*Get the interface IPv6 address - */ -#ifdef RAL_DUMMY - //LG get_IPv6_addr("eth0"); -#else -#ifdef RAL_REALTIME - //LG get_IPv6_addr("oai0"); -#endif -#endif - - // Get list of MTs - //LG LOG_D(RAL_ENB, "Obtaining list of MTs\n\n"); -#ifdef RAL_REALTIME - //init_flag=1; - //LG RAL_process_NAS_message(IO_OBJ_CNX, IO_CMD_LIST,0,0); - //LG RAL_process_NAS_message(IO_OBJ_RB, IO_CMD_LIST,0,0); - //init_flag=0; -#endif -#ifdef RAL_DUMMY - //LG eRALlte_NAS_get_MTs_list(); -#endif -// RAL_printInitStatus(0); -// g_enb_ral_obj[instanceP].pending_req_flag = 0; -// // -// g_enb_ral_obj[instanceP].pending_mt_timer = -1; -// g_enb_ral_obj[instanceP].pending_mt_flag = 0; -// // -// LOG_D(RAL_ENB, " List of MTs initialized\n\n"); - -// // Initialize measures for demo3 -// g_enb_ral_obj[instanceP].meas_polling_interval = RAL_DEFAULT_MEAS_POLLING_INTERVAL; -// g_enb_ral_obj[instanceP].meas_polling_counter = 1; - -// g_enb_ral_obj[instanceP].congestion_flag = RAL_FALSE; -// g_enb_ral_obj[instanceP].measures_triggered_flag = RAL_FALSE; -// g_enb_ral_obj[instanceP].congestion_threshold = RAL_DEFAULT_CONGESTION_THRESHOLD; -// transaction_id = (MIH_C_TRANSACTION_ID_T)0; - -// eRALlte_send_link_register_indication(&transaction_id); - return 0; } @@ -554,83 +313,3 @@ void* eRAL_task(void *args_p) { } } -/****************************************************************************/ -/****************** E X P O R T E D F U N C T I O N S ******************/ -/****************************************************************************/ -/*int main(int argc, const char *argv[]){ -//----------------------------------------------------------------------------- - int rc, done; - fd_set readfds; - struct timeval tv; - int time_counter = 1; - - RAL_initialize(argc, argv); - - g_enb_ral_obj[instanceP].pending_mt_timer = 0; - - done = 0; - do { - // Initialize fd_set and wait for input - FD_ZERO(&readfds); - FD_SET(g_sockd_mihf, &readfds); - #ifdef RAL_DUMMY - FD_SET(g_sockd_nas, &readfds); - #endif - #ifdef MUSER_CONTROL - FD_SET (g_sockd_user, &readfds); - #endif - tv.tv_sec = MIH_C_RADIO_POLLING_INTERVAL_SECONDS; - tv.tv_usec = MIH_C_RADIO_POLLING_INTERVAL_MICRO_SECONDS; - - rc = select(FD_SETSIZE, &readfds, NULL, NULL, &tv); - if (rc < 0) { - perror("main : select() failed"); - done = 1; - } - // Something is ready for being read - else if (rc >= 0){ - // Read data coming from the MIH Function - if (FD_ISSET(g_sockd_mihf, &readfds)) { - done = eRALlte_mih_link_process_message(); - } - #ifdef RAL_DUMMY - // Read data coming from the NAS driver - if (FD_ISSET(g_sockd_nas, &readfds)) { - //printf("Received something from NAS\n"); - done = eRALlte_NAS_process_message(); - } - #endif - #ifdef MUSER_CONTROL - // Get triggers - if (FD_ISSET(g_sockd_user,&readfds)){ - done = lteRALenb_trigger_receive(g_sockd_user); - } - #endif - - // Wait until next pending MT's timer expiration - if (g_enb_ral_obj[instanceP].pending_mt_timer > 0) { - g_enb_ral_obj[instanceP].pending_mt_timer --; - eRALlte_process_verify_pending_mt_status(); - } - - if (time_counter ++ == 11){ - // check if a new MT appeared or disappeared - #ifdef RAL_REALTIME - RAL_process_NAS_message(IO_OBJ_CNX, IO_CMD_LIST,0,0); - #endif - time_counter = 1; - } - //get measures from NAS - timer = 21x100ms -- impair - if (g_enb_ral_obj[instanceP].meas_polling_counter ++ == g_enb_ral_obj[instanceP].meas_polling_interval){ - RAL_NAS_measures_polling(); - g_enb_ral_obj[instanceP].meas_polling_counter =1; - } - - } - } while (!done); - - close(g_sockd_mihf); - MIH_C_exit(); - return 0; -} - */ diff --git a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_subscribe.c b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_subscribe.c index 7481a921e811770ac50bba53c0b85957e6eb3ce6..3bf717e5e9baa657f937c0a2cb1bd6b31419abef 100755 --- a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_subscribe.c +++ b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_subscribe.c @@ -2,7 +2,7 @@ * Eurecom OpenAirInterface 3 * Copyright(c) 2012 Eurecom * - * Source eRAL_subscribe.c + * Source lteRALenb_subscribe.c * * Version 0.1 * @@ -27,18 +27,18 @@ /**************************************************************************** ** ** - ** Name: eRAL_subscribe_request() ** + ** Name: eRAL_subscribe_request() ** ** ** ** Description: Subscribes the MIH-F to receive specified link event ** - ** indications and sends Link Event Subscribe confirmation ** - ** to the MIH-F. ** + ** indications and sends Link Event Subscribe confirmation ** + ** to the MIH-F. ** ** ** - ** Inputs: msgP: Pointer to the received MIH message ** - ** Others: None ** + ** Inputs: msgP: Pointer to the received MIH message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: ralpriv ** + ** Outputs: None ** + ** Return: None ** + ** Others: ralpriv ** ** ** ***************************************************************************/ void eRAL_subscribe_request(ral_enb_instance_t instanceP, MIH_C_Message_Link_Event_Subscribe_request_t* msgP) @@ -69,18 +69,18 @@ void eRAL_subscribe_request(ral_enb_instance_t instanceP, MIH_C_Message_Link_Eve /**************************************************************************** ** ** - ** Name: eRAL_unsubscribe_request() ** + ** Name: eRAL_unsubscribe_request() ** ** ** ** Description: Unsubscribes the MIH-F to receive specified link event ** - ** indications and sends Link Event Unsubscribe confirmation ** - ** to the MIH-F. ** + ** indications and sends Link Event Unsubscribe confirmation ** + ** to the MIH-F. ** ** ** - ** Inputs: msgP: Pointer to the received MIH message ** - ** Others: None ** + ** Inputs: msgP: Pointer to the received MIH message ** + ** Others: None ** ** ** - ** Outputs: None ** - ** Return: None ** - ** Others: ralpriv ** + ** Outputs: None ** + ** Return: None ** + ** Others: ralpriv ** ** ** ***************************************************************************/ void eRAL_unsubscribe_request(ral_enb_instance_t instanceP, MIH_C_Message_Link_Event_Unsubscribe_request_t* msgP) diff --git a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_thresholds.c b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_thresholds.c index 409133a0919aa1a5503540a709aacc2286d8dd33..5ea03f53c6c969535a414bfaf06873fa5d833ac8 100755 --- a/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_thresholds.c +++ b/openair3/RAL-LTE/LTE_RAL_ENB/SRC/lteRALenb_thresholds.c @@ -29,7 +29,7 @@ /**************************************************************************** ** ** - ** Name: eRAL_configure_thresholds_request() ** + ** Name: eRAL_configure_thresholds_request() ** ** ** ** Description: Forwards the Link_Configure_Thresholds.request message ** ** to the RRC layer. ** diff --git a/targets/SIMU/USER/Makefile b/targets/SIMU/USER/Makefile index dee4d545f4bcd2393324afcc0f29c056fe32399c..03b86385f00886d6607d63426bb2da201020f102 100644 --- a/targets/SIMU/USER/Makefile +++ b/targets/SIMU/USER/Makefile @@ -135,6 +135,9 @@ endif ifeq ($(RLC_STOP_ON_LOST_PDU), 1) CFLAGS += -DRLC_STOP_ON_LOST_PDU endif +ifeq ($(STOP_ON_IP_TRAFFIC_OVERLOAD), 1) +CFLAGS += -DSTOP_ON_IP_TRAFFIC_OVERLOAD +endif ifeq ($(ENABLE_RAL), 1) CFLAGS += -DENABLE_RAL diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 52984ea267c8f68c1d7466ca73434a45b71eabef..62bdf3b89c7089be1184c172083093873510e9c0 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -42,13 +42,12 @@ #ifdef SMBV #include "PHY/TOOLS/smbv.h" -char smbv_fname[] = "smbv_config_file.smbv"; +char smbv_fname[] = "smbv_config_file.smbv"; unsigned short smbv_nframes = 4; // how many frames to configure 1,..,4 unsigned short config_frames[4] = {2,9,11,13}; -// unsigned short config_frames[4] = {1}; -unsigned char smbv_frame_cnt = 0; -u8 config_smbv = 0; -char smbv_ip[16]; +unsigned char smbv_frame_cnt = 0; +u8 config_smbv = 0; +char smbv_ip[16]; #endif #include "oaisim_functions.h" @@ -76,12 +75,9 @@ char smbv_ip[16]; # include "create_tasks.h" #endif -#define RF - -//#define DEBUG_SIM - -#define MCS_COUNT 24//added for PHY abstraction -#define N_TRIALS 1 +#define RF 1 +#define MCS_COUNT 24 /*added for PHY abstraction */ +#define N_TRIALS 1 /* DCI0_5MHz_TDD0_t UL_alloc_pdu; @@ -90,61 +86,54 @@ char smbv_ip[16]; DCI2_5MHz_2A_M10PRB_TDD_t DLSCH_alloc_pdu2; */ -#define UL_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,24) -#define CCCH_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) -#define RA_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) -#define DLSCH_RB_ALLOC 0x1fff +#define UL_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,24) +#define CCCH_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) +#define RA_RB_ALLOC computeRIV(lte_frame_parms->N_RB_UL,0,3) +#define DLSCH_RB_ALLOC 0x1fff -#define DECOR_DIST 100 -#define SF_VAR 10 +#define DECOR_DIST 100 +#define SF_VAR 10 //constant for OAISIM soft realtime calibration -#define SF_DEVIATION_OFFSET_NS 100000 //= 0.1ms : should be as a number of UE -#define SLEEP_STEP_US 100 // = 0.01ms could be adaptive, should be as a number of UE -#define K 2 // averaging coefficient -#define TARGET_SF_TIME_NS 1000000 // 1ms = 1000000 ns -//#ifdef OPENAIR2 -//u16 NODE_ID[1]; -//u8 NB_INST = 2; -//#endif //OPENAIR2 -u32 frame = 0; -//int eMBMS_active = 0; -char stats_buffer[16384]; -channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; -channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX]; +#define SF_DEVIATION_OFFSET_NS 100000 /*= 0.1ms : should be as a number of UE */ +#define SLEEP_STEP_US 100 /* = 0.01ms could be adaptive, should be as a number of UE */ +#define K 2 /* averaging coefficient */ +#define TARGET_SF_TIME_NS 1000000 /* 1ms = 1000000 ns */ + +frame_t frame = 0; +char stats_buffer[16384]; +channel_desc_t *eNB2UE[NUMBER_OF_eNB_MAX][NUMBER_OF_UE_MAX]; +channel_desc_t *UE2eNB[NUMBER_OF_UE_MAX][NUMBER_OF_eNB_MAX]; //Added for PHY abstraction -node_desc_t *enb_data[NUMBER_OF_eNB_MAX]; -node_desc_t *ue_data[NUMBER_OF_UE_MAX]; +node_desc_t *enb_data[NUMBER_OF_eNB_MAX]; +node_desc_t *ue_data[NUMBER_OF_UE_MAX]; // Added for PHY abstraction -extern Node_list ue_node_list; -extern Node_list enb_node_list; -extern int pdcp_period, omg_period; - -extern double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; -int map1, map2; -extern double **ShaF; -double snr_dB, sinr_dB, snr_direction; //,sinr_direction; -extern double snr_step; -extern u8 set_sinr; //,set_snr=0; -extern u8 ue_connection_test; -extern u8 set_seed; -u8 cooperation_flag; // for cooperative communication -extern u8 target_dl_mcs; -extern u8 target_ul_mcs; -u8 rate_adaptation_flag; -extern u8 abstraction_flag, ethernet_flag; -extern u16 Nid_cell; +extern Node_list ue_node_list; +extern Node_list enb_node_list; +extern int pdcp_period, omg_period; + +extern double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; +int map1, map2; +extern double **ShaF; +double snr_dB, sinr_dB, snr_direction; //,sinr_direction; +extern double snr_step; +extern u8 set_sinr; +extern u8 ue_connection_test; +extern u8 set_seed; +u8 cooperation_flag; // for cooperative communication +extern u8 target_dl_mcs; +extern u8 target_ul_mcs; +u8 rate_adaptation_flag; +extern u8 abstraction_flag; +extern u8 ethernet_flag; +extern u16 Nid_cell; extern struct timespec time_spec; -extern unsigned long time_last, time_now; -extern int td, td_avg, sleep_time_us; +extern unsigned long time_last; +extern unsigned long time_now; +extern int td; +extern int td_avg; +extern int sleep_time_us; extern LTE_DL_FRAME_PARMS *frame_parms; -//double sinr_bler_map[MCS_COUNT][2][16]; -//double sinr_bler_map_up[MCS_COUNT][2][16]; -//extern double SINRpost_eff[301]; -//extern int mcsPost; -//extern int nrbPost; -//extern int frbPost; -//extern void kpi_gen(); #ifdef XFORMS int otg_enabled; @@ -152,26 +141,26 @@ int otg_enabled; // this should reflect the channel models in openair1/SIMULATION/TOOLS/defs.h mapping small_scale_names[] = { - {"custom", custom}, - {"SCM_A", SCM_A}, - {"SCM_B", SCM_B}, - {"SCM_C", SCM_C}, - {"SCM_D", SCM_D}, - {"EPA", EPA}, - {"EVA", EVA}, - {"ETU", ETU}, - {"MBSFN", MBSFN}, - {"Rayleigh8", Rayleigh8}, - {"Rayleigh1", Rayleigh1}, - {"Rayleigh1_800", Rayleigh1_800}, - {"Rayleigh1_corr", Rayleigh1_corr}, - {"Rayleigh1_anticorr", Rayleigh1_anticorr}, - {"Rice8", Rice8}, - {"Rice1", Rice1}, - {"Rice1_corr", Rice1_corr}, - {"Rice1_anticorr", Rice1_anticorr}, - {"AWGN", AWGN}, - {NULL, -1} + {"custom", custom}, + {"SCM_A", SCM_A}, + {"SCM_B", SCM_B}, + {"SCM_C", SCM_C}, + {"SCM_D", SCM_D}, + {"EPA", EPA}, + {"EVA", EVA}, + {"ETU", ETU}, + {"MBSFN", MBSFN}, + {"Rayleigh8", Rayleigh8}, + {"Rayleigh1", Rayleigh1}, + {"Rayleigh1_800", Rayleigh1_800}, + {"Rayleigh1_corr", Rayleigh1_corr}, + {"Rayleigh1_anticorr", Rayleigh1_anticorr}, + {"Rice8", Rice8}, + {"Rice1", Rice1}, + {"Rice1_corr", Rice1_corr}, + {"Rice1_anticorr", Rice1_anticorr}, + {"AWGN", AWGN}, + {NULL, -1} }; //static void *sigh(void *arg); @@ -236,12 +225,12 @@ void log_thread_init() { log_shutdown = 0; if ((pthread_mutex_init (&log_lock, NULL) != 0) || (pthread_cond_init (&log_notify, NULL) != 0)) { - return; + return; } if (pthread_create (&log_thread, NULL, log_thread_function, (void*) NULL) != 0) { - log_thread_finalize (); - return; + log_thread_finalize (); + return; } #endif @@ -254,27 +243,27 @@ int log_thread_finalize() { #ifndef LOG_NO_THREAD if (pthread_mutex_lock (&log_lock) != 0) { - return -1; + return -1; } log_shutdown = 1; /* Wake up LOG thread */ if ((pthread_cond_broadcast (&log_notify) != 0) || (pthread_mutex_unlock (&log_lock) != 0)) { - err = -1; + err = -1; } if (pthread_join (log_thread, NULL) != 0) { - err = -1; + err = -1; } if (pthread_mutex_unlock (&log_lock) != 0) { - err = -1; + err = -1; } if (!err) { - //log_list_free(&log_list); - pthread_mutex_lock (&log_lock); - pthread_mutex_destroy (&log_lock); - pthread_cond_destroy (&log_notify); + //log_list_free(&log_list); + pthread_mutex_lock (&log_lock); + pthread_mutex_destroy (&log_lock); + pthread_cond_destroy (&log_notify); } #endif @@ -282,73 +271,73 @@ int log_thread_finalize() { } #if defined(ENABLE_ITTI) -static void set_cli_start(uint8_t instance, uint8_t start) { - if (instance < NB_eNB_INST) { - oai_emulation.info.cli_start_enb[instance] = start; +static void set_cli_start(module_id_t module_idP, uint8_t start) { + if (module_idP < NB_eNB_INST) { + oai_emulation.info.cli_start_enb[module_idP] = start; } else { - oai_emulation.info.cli_start_ue[instance - NB_eNB_INST] = start; + oai_emulation.info.cli_start_ue[module_idP - NB_eNB_INST] = start; } } #endif #ifdef OPENAIR2 int omv_write(int pfd, Node_list enb_node_list, Node_list ue_node_list, Data_Flow_Unit omv_data) { - int i, j; + module_id_t i, j; omv_data.end = 0; //omv_data.total_num_nodes = NB_UE_INST + NB_eNB_INST; for (i = 0; i < NB_eNB_INST; i++) { - if (enb_node_list != NULL) { - omv_data.geo[i].x = (enb_node_list->node->X_pos < 0.0) ? 0.0 : enb_node_list->node->X_pos; - omv_data.geo[i].y = (enb_node_list->node->Y_pos < 0.0) ? 0.0 : enb_node_list->node->Y_pos; - omv_data.geo[i].z = 1.0; - omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_enb; - omv_data.geo[i].node_type = 0; //eNB - enb_node_list = enb_node_list->next; - omv_data.geo[i].Neighbors = 0; - for (j = NB_eNB_INST; j < NB_UE_INST + NB_eNB_INST; j++) { - if (is_UE_active (i, j - NB_eNB_INST) == 1) { - omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; - omv_data.geo[i].Neighbors++; - LOG_D( - OMG, - "[eNB %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_eNB_INST, is_UE_active(i,j-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); - } + if (enb_node_list != NULL) { + omv_data.geo[i].x = (enb_node_list->node->X_pos < 0.0) ? 0.0 : enb_node_list->node->X_pos; + omv_data.geo[i].y = (enb_node_list->node->Y_pos < 0.0) ? 0.0 : enb_node_list->node->Y_pos; + omv_data.geo[i].z = 1.0; + omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_enb; + omv_data.geo[i].node_type = 0; //eNB + enb_node_list = enb_node_list->next; + omv_data.geo[i].Neighbors = 0; + for (j = NB_eNB_INST; j < NB_UE_INST + NB_eNB_INST; j++) { + if (is_UE_active (i, j - NB_eNB_INST) == 1) { + omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; + omv_data.geo[i].Neighbors++; + LOG_D( + OMG, + "[eNB %d][UE %d] is_UE_active(i,j) %d geo (x%d, y%d) num neighbors %d\n", i, j-NB_eNB_INST, is_UE_active(i,j-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); + } + } } - } } for (i = NB_eNB_INST; i < NB_UE_INST + NB_eNB_INST; i++) { - if (ue_node_list != NULL) { - omv_data.geo[i].x = (ue_node_list->node->X_pos < 0.0) ? 0.0 : ue_node_list->node->X_pos; - omv_data.geo[i].y = (ue_node_list->node->Y_pos < 0.0) ? 0.0 : ue_node_list->node->Y_pos; - omv_data.geo[i].z = 1.0; - omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_ue; - omv_data.geo[i].node_type = 1; //UE - //trial - omv_data.geo[i].state = 1; - omv_data.geo[i].rnti = 88; - omv_data.geo[i].connected_eNB = 0; - omv_data.geo[i].RSRP = 66; - omv_data.geo[i].RSRQ = 55; - omv_data.geo[i].Pathloss = 44; - omv_data.geo[i].RSSI[0] = 33; - omv_data.geo[i].RSSI[1] = 22; - if ((sizeof(omv_data.geo[0].RSSI) / sizeof(omv_data.geo[0].RSSI[0])) > 2) - { - omv_data.geo[i].RSSI[2] = 11; - } + if (ue_node_list != NULL) { + omv_data.geo[i].x = (ue_node_list->node->X_pos < 0.0) ? 0.0 : ue_node_list->node->X_pos; + omv_data.geo[i].y = (ue_node_list->node->Y_pos < 0.0) ? 0.0 : ue_node_list->node->Y_pos; + omv_data.geo[i].z = 1.0; + omv_data.geo[i].mobility_type = oai_emulation.info.omg_model_ue; + omv_data.geo[i].node_type = 1; //UE + //trial + omv_data.geo[i].state = 1; + omv_data.geo[i].rnti = 88; + omv_data.geo[i].connected_eNB = 0; + omv_data.geo[i].RSRP = 66; + omv_data.geo[i].RSRQ = 55; + omv_data.geo[i].Pathloss = 44; + omv_data.geo[i].RSSI[0] = 33; + omv_data.geo[i].RSSI[1] = 22; + if ((sizeof(omv_data.geo[0].RSSI) / sizeof(omv_data.geo[0].RSSI[0])) > 2) + { + omv_data.geo[i].RSSI[2] = 11; + } - ue_node_list = ue_node_list->next; - omv_data.geo[i].Neighbors = 0; - for (j = 0; j < NB_eNB_INST; j++) { - if (is_UE_active (j, i - NB_eNB_INST) == 1) { - omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; - omv_data.geo[i].Neighbors++; - LOG_D( - OMG, - "[UE %d][eNB %d] is_UE_active %d geo (x%d, y%d) num neighbors %d\n", i-NB_eNB_INST, j, is_UE_active(j,i-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); - } + ue_node_list = ue_node_list->next; + omv_data.geo[i].Neighbors = 0; + for (j = 0; j < NB_eNB_INST; j++) { + if (is_UE_active (j, i - NB_eNB_INST) == 1) { + omv_data.geo[i].Neighbor[omv_data.geo[i].Neighbors] = j; + omv_data.geo[i].Neighbors++; + LOG_D( + OMG, + "[UE %d][eNB %d] is_UE_active %d geo (x%d, y%d) num neighbors %d\n", i-NB_eNB_INST, j, is_UE_active(j,i-NB_eNB_INST), omv_data.geo[i].x, omv_data.geo[i].y, omv_data.geo[i].Neighbors); + } + } } - } } LOG_E(OMG, "pfd %d \n", pfd); if (write (pfd, &omv_data, sizeof(struct Data_Flow_Unit)) == -1) @@ -370,54 +359,59 @@ int pfd[2]; // fd for omv : fixme: this could be a local var #ifdef OPENAIR2 static Data_Flow_Unit omv_data; #endif //ALU -static s32 UE_id = 0, eNB_id = 0; +static module_id_t UE_inst = 0; +static module_id_t eNB_inst = 0; #ifdef Rel10 -static s32 RN_id=0; +static module_id_t RN_inst=0; #endif Packet_OTG_List *otg_pdcp_buffer; typedef enum l2l1_task_state_e { - L2L1_WAITTING, - L2L1_RUNNING, - L2L1_TERMINATED, + L2L1_WAITTING, + L2L1_RUNNING, + L2L1_TERMINATED, } l2l1_task_state_t; /*------------------------------------------------------------------------------*/ void *l2l1_task(void *args_p) { - l2l1_task_state_t l2l1_state = L2L1_WAITTING; - clock_t t; + l2l1_task_state_t l2l1_state = L2L1_WAITTING; + clock_t t; // Framing variables - s32 slot, last_slot, next_slot; + s32 slot, last_slot, next_slot; #ifdef Rel10 - relaying_type_t r_type = no_relay; // no relaying + relaying_type_t r_type = no_relay; // no relaying #endif - lte_subframe_t direction; + lte_subframe_t direction; - char fname[64], vname[64]; + char fname[64], vname[64]; #ifdef XFORMS // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) // at eNB 0, an UL scope for every UE - FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; + FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; FD_lte_phy_scope_enb *form_enb[NUMBER_OF_UE_MAX]; - char title[255]; - char xname[32] = "oaisim"; - int xargc=1; - char *xargv[1]; + char title[255]; + char xname[32] = "oaisim"; + int xargc = 1; + char *xargv[1]; #endif #ifdef PRINT_STATS - int len; - FILE *UE_stats[NUMBER_OF_UE_MAX], *UE_stats_th[NUMBER_OF_UE_MAX], *eNB_stats[NUMBER_OF_eNB_MAX], *eNB_avg_thr, *eNB_l2_stats; - char UE_stats_filename[255]; - char eNB_stats_filename[255]; - char UE_stats_th_filename[255]; - char eNB_stats_th_filename[255]; + int len; + FILE *UE_stats[NUMBER_OF_UE_MAX]; + FILE *UE_stats_th[NUMBER_OF_UE_MAX]; + FILE *eNB_stats[NUMBER_OF_eNB_MAX]; + FILE *eNB_avg_thr; + FILE *eNB_l2_stats; + char UE_stats_filename[255]; + char eNB_stats_filename[255]; + char UE_stats_th_filename[255]; + char eNB_stats_th_filename[255]; #endif #ifdef XFORMS @@ -425,50 +419,50 @@ void *l2l1_task(void *args_p) { fl_initialize (&xargc, xargv, NULL, 0, 0); eNB_id = 0; for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - // DL scope at UEs - form_ue[UE_id] = create_lte_phy_scope_ue(); - sprintf (title, "LTE DL SCOPE eNB %d to UE %d", eNB_id, UE_id); - fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - // UL scope at eNB 0 - form_enb[UE_id] = create_lte_phy_scope_enb(); - sprintf (title, "LTE UL SCOPE UE %d to eNB %d", UE_id, eNB_id); - fl_show_form (form_enb[UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); - - if (openair_daq_vars.use_ia_receiver == 1) { - fl_set_button(form_ue[UE_id]->button_0,1); - fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); - fl_set_object_color(form_ue[UE_id]->button_0, FL_GREEN, FL_GREEN); - } + // DL scope at UEs + form_ue[UE_id] = create_lte_phy_scope_ue(); + sprintf (title, "LTE DL SCOPE eNB %d to UE %d", eNB_id, UE_id); + fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + // UL scope at eNB 0 + form_enb[UE_id] = create_lte_phy_scope_enb(); + sprintf (title, "LTE UL SCOPE UE %d to eNB %d", UE_id, eNB_id); + fl_show_form (form_enb[UE_id]->lte_phy_scope_enb, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); + + if (openair_daq_vars.use_ia_receiver == 1) { + fl_set_button(form_ue[UE_id]->button_0,1); + fl_set_object_label(form_ue[UE_id]->button_0, "IA Receiver ON"); + fl_set_object_color(form_ue[UE_id]->button_0, FL_GREEN, FL_GREEN); + } } #endif #ifdef PRINT_STATS for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { - sprintf(UE_stats_filename,"UE_stats%d.txt",UE_id); - UE_stats[UE_id] = fopen (UE_stats_filename, "w"); + sprintf(UE_stats_filename,"UE_stats%d.txt",UE_id); + UE_stats[UE_id] = fopen (UE_stats_filename, "w"); } for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { - sprintf(eNB_stats_filename,"eNB_stats%d.txt",eNB_id); - eNB_stats[eNB_id] = fopen (eNB_stats_filename, "w"); + sprintf(eNB_stats_filename,"eNB_stats%d.txt",eNB_id); + eNB_stats[eNB_id] = fopen (eNB_stats_filename, "w"); } if(abstraction_flag==0) { - for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { - sprintf(UE_stats_th_filename,"UE_stats_th%d_tx%d.txt",UE_id,oai_emulation.info.transmission_mode); - UE_stats_th[UE_id] = fopen (UE_stats_th_filename, "w"); - } - sprintf(eNB_stats_th_filename,"eNB_stats_th_tx%d.txt",oai_emulation.info.transmission_mode); - eNB_avg_thr = fopen (eNB_stats_th_filename, "w"); + for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { + sprintf(UE_stats_th_filename,"UE_stats_th%d_tx%d.txt",UE_id,oai_emulation.info.transmission_mode); + UE_stats_th[UE_id] = fopen (UE_stats_th_filename, "w"); + } + sprintf(eNB_stats_th_filename,"eNB_stats_th_tx%d.txt",oai_emulation.info.transmission_mode); + eNB_avg_thr = fopen (eNB_stats_th_filename, "w"); } else { - for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { - sprintf(UE_stats_th_filename,"UE_stats_abs_th%d_tx%d.txt",UE_id,oai_emulation.info.transmission_mode); - UE_stats_th[UE_id] = fopen (UE_stats_th_filename, "w"); - } - sprintf(eNB_stats_th_filename,"eNB_stats_abs_th_tx%d.txt",oai_emulation.info.transmission_mode); - eNB_avg_thr = fopen (eNB_stats_th_filename, "w"); + for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { + sprintf(UE_stats_th_filename,"UE_stats_abs_th%d_tx%d.txt",UE_id,oai_emulation.info.transmission_mode); + UE_stats_th[UE_id] = fopen (UE_stats_th_filename, "w"); + } + sprintf(eNB_stats_th_filename,"eNB_stats_abs_th_tx%d.txt",oai_emulation.info.transmission_mode); + eNB_avg_thr = fopen (eNB_stats_th_filename, "w"); } #ifdef OPENAIR2 eNB_l2_stats = fopen ("eNB_l2_stats.txt", "w"); @@ -485,50 +479,19 @@ void *l2l1_task(void *args_p) { LOG_I(EMU, "TASK_L2L1 is READY\n"); if (oai_emulation.info.nb_enb_local > 0) { - /* Wait for the initialize message */ - do { - if (message_p != NULL) { - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - itti_receive_msg (TASK_L2L1, &message_p); - - switch (ITTI_MSG_ID(message_p)) { - case INITIALIZE_MESSAGE: - l2l1_state = L2L1_RUNNING; - break; - - case ACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 1); - break; - - case DEACTIVATE_MESSAGE: - set_cli_start(ITTI_MSG_INSTANCE (message_p), 0); - break; - - case TERMINATE_MESSAGE: - l2l1_state = L2L1_TERMINATED; - break; - - default: - LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); - break; - } - } while (l2l1_state == L2L1_WAITTING); - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } -#endif - - for (frame = 0; (l2l1_state != L2L1_TERMINATED) && (frame < oai_emulation.info.n_frames); frame++) { + /* Wait for the initialize message */ + do { + if (message_p != NULL) { + result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } + itti_receive_msg (TASK_L2L1, &message_p); -#if defined(ENABLE_ITTI) - do { - // Checks if a message has been sent to L2L1 task - itti_poll_msg (TASK_L2L1, &message_p); + switch (ITTI_MSG_ID(message_p)) { + case INITIALIZE_MESSAGE: + l2l1_state = L2L1_RUNNING; + break; - if (message_p != NULL) { - switch (ITTI_MSG_ID(message_p)) { case ACTIVATE_MESSAGE: set_cli_start(ITTI_MSG_INSTANCE (message_p), 1); break; @@ -541,191 +504,233 @@ void *l2l1_task(void *args_p) { l2l1_state = L2L1_TERMINATED; break; - case MESSAGE_TEST: - LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p)); - break; - - default: LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); break; - } + } + } while (l2l1_state == L2L1_WAITTING); + result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } +#endif - result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); - AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); - } - } while(message_p != NULL); + for (frame = 0; (l2l1_state != L2L1_TERMINATED) && (frame < oai_emulation.info.n_frames); frame++) { + +#if defined(ENABLE_ITTI) + do { + // Checks if a message has been sent to L2L1 task + itti_poll_msg (TASK_L2L1, &message_p); + + if (message_p != NULL) { + switch (ITTI_MSG_ID(message_p)) { + case ACTIVATE_MESSAGE: + set_cli_start(ITTI_MSG_INSTANCE (message_p), 1); + break; + + case DEACTIVATE_MESSAGE: + set_cli_start(ITTI_MSG_INSTANCE (message_p), 0); + break; + + case TERMINATE_MESSAGE: + l2l1_state = L2L1_TERMINATED; + break; + + case MESSAGE_TEST: + LOG_I(EMU, "Received %s\n", ITTI_MSG_NAME(message_p)); + break; + + + default: + LOG_E(EMU, "Received unexpected message %s\n", ITTI_MSG_NAME(message_p)); + break; + } + + result = itti_free (ITTI_MSG_ORIGIN_ID(message_p), message_p); + AssertFatal (result == EXIT_SUCCESS, "Failed to free memory (%d)!\n", result); + } + } while(message_p != NULL); #endif - /* + /* // Handling the cooperation Flag if (cooperation_flag == 2) { if ((PHY_vars_eNB_g[0]->eNB_UE_stats[0].mode == PUSCH) && (PHY_vars_eNB_g[0]->eNB_UE_stats[1].mode == PUSCH)) PHY_vars_eNB_g[0]->cooperation_flag = 2; } - */ - if (ue_connection_test == 1) { - if ((frame % 20) == 0) { - snr_dB += snr_direction; - sinr_dB -= snr_direction; - } - if (snr_dB == -20) { - snr_direction = snr_step; + */ + if (ue_connection_test == 1) { + if ((frame % 20) == 0) { + snr_dB += snr_direction; + sinr_dB -= snr_direction; + } + if (snr_dB == -20) { + snr_direction = snr_step; + } + else + if (snr_dB == 20) { + snr_direction = -snr_step; + } } - else - if (snr_dB == 20) { - snr_direction = -snr_step; - } - } - oai_emulation.info.frame = frame; - //oai_emulation.info.time_ms += 1; - oai_emulation.info.time_s += 0.1; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01) - // if n_frames not set by the user or is greater than max num frame then set adjust the frame counter - if ((oai_emulation.info.n_frames_flag == 0) || (oai_emulation.info.n_frames >= 0xffff)) { - frame %= (oai_emulation.info.n_frames - 1); - } + oai_emulation.info.frame = frame; + //oai_emulation.info.time_ms += 1; + oai_emulation.info.time_s += 0.1; // emu time in s, each frame lasts for 10 ms // JNote: TODO check the coherency of the time and frame (I corrected it to 10 (instead of 0.01) + // if n_frames not set by the user or is greater than max num frame then set adjust the frame counter + if ((oai_emulation.info.n_frames_flag == 0) || (oai_emulation.info.n_frames >= 0xffff)) { + frame %= (oai_emulation.info.n_frames - 1); + } - update_omg (); // frequency is defined in the omg_global params configurable by the user + update_omg (); // frequency is defined in the omg_global params configurable by the user - update_omg_ocm (); + update_omg_ocm (); #ifdef OPENAIR2 - // check if pipe is still open - if ((oai_emulation.info.omv_enabled == 1)) { - omv_write (pfd[1], enb_node_list, ue_node_list, omv_data); - } + // check if pipe is still open + if ((oai_emulation.info.omv_enabled == 1)) { + omv_write (pfd[1], enb_node_list, ue_node_list, omv_data); + } #endif #ifdef DEBUG_OMG - if ((((int) oai_emulation.info.time_s) % 100) == 0) { - for (UE_id = oai_emulation.info.first_ue_local; UE_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); UE_id++) { - get_node_position (UE, UE_id); + if ((((int) oai_emulation.info.time_s) % 100) == 0) { + for (UE_id = oai_emulation.info.first_ue_local; UE_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local); UE_id++) { + get_node_position (UE, UE_id); + } } - } #endif - update_ocm (); + update_ocm (); - for (slot = 0; slot < 20; slot++) { + for (slot = 0; slot < 20; slot++) { - wait_for_slot_isr (); + wait_for_slot_isr (); #if defined(ENABLE_ITTI) - itti_update_lte_time(frame, slot); + itti_update_lte_time(frame, slot); #endif - last_slot = (slot - 1) % 20; - if (last_slot < 0) - last_slot += 20; - next_slot = (slot + 1) % 20; + last_slot = (slot - 1) % 20; + if (last_slot < 0) + last_slot += 20; + next_slot = (slot + 1) % 20; - oai_emulation.info.time_ms = frame * 10 + (slot >> 1); + oai_emulation.info.time_ms = frame * 10 + (slot >> 1); - direction = subframe_select (frame_parms, next_slot >> 1); + direction = subframe_select (frame_parms, next_slot >> 1); #ifdef PROC - if(Channel_Flag==1) - Channel_Func(s_re2,s_im2,r_re2,r_im2,r_re02,r_im02,r_re0_d,r_im0_d,r_re0_u,r_im0_u,eNB2UE,UE2eNB,enb_data,ue_data,abstraction_flag,frame_parms,slot); + if(Channel_Flag==1) + Channel_Func(s_re2,s_im2,r_re2,r_im2,r_re02,r_im02,r_re0_d,r_im0_d,r_re0_u,r_im0_u,eNB2UE,UE2eNB,enb_data,ue_data,abstraction_flag,frame_parms,slot); - if(Channel_Flag==0) + if(Channel_Flag==0) #endif - { + { #if defined(ENABLE_ITTI) - log_set_instance_type (LOG_INSTANCE_ENB); + log_set_instance_type (LOG_INSTANCE_ENB); #endif - if ((next_slot % 2) == 0) - clear_eNB_transport_info (oai_emulation.info.nb_enb_local); - - for (eNB_id = oai_emulation.info.first_enb_local; (eNB_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)); eNB_id++) { - if (oai_emulation.info.cli_start_enb[eNB_id] != 0) { - //printf ("debug: Nid_cell %d\n", PHY_vars_eNB_g[eNB_id]->lte_frame_parms.Nid_cell); - //printf ("debug: frame_type %d,tdd_config %d\n", PHY_vars_eNB_g[eNB_id]->lte_frame_parms.frame_type,PHY_vars_eNB_g[eNB_id]->lte_frame_parms.tdd_config); - LOG_D( - EMU, - "PHY procedures eNB %d for frame %d, slot %d (subframe TX %d, RX %d) TDD %d/%d Nid_cell %d\n", eNB_id, frame, slot, next_slot >> 1, last_slot>>1, PHY_vars_eNB_g[eNB_id]->lte_frame_parms.frame_type, PHY_vars_eNB_g[eNB_id]->lte_frame_parms.tdd_config, PHY_vars_eNB_g[eNB_id]->lte_frame_parms.Nid_cell); + if ((next_slot % 2) == 0) + clear_eNB_transport_info (oai_emulation.info.nb_enb_local); + + for (eNB_inst = oai_emulation.info.first_enb_local; (eNB_inst < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local)); eNB_inst++) { + if (oai_emulation.info.cli_start_enb[eNB_inst] != 0) { + LOG_D( + EMU, + "PHY procedures eNB %d for frame %d, slot %d (subframe TX %d, RX %d) TDD %d/%d Nid_cell %d\n", + eNB_inst, + frame, + slot, + next_slot >> 1, + last_slot>>1, + PHY_vars_eNB_g[eNB_inst]->lte_frame_parms.frame_type, + PHY_vars_eNB_g[eNB_inst]->lte_frame_parms.tdd_config, + PHY_vars_eNB_g[eNB_inst]->lte_frame_parms.Nid_cell); #ifdef OPENAIR2 - //Appliation: traffic gen - update_otg_eNB (eNB_id, oai_emulation.info.time_ms); + //Appliation: traffic gen + update_otg_eNB (eNB_inst, oai_emulation.info.time_ms); - //IP/OTG to PDCP and PDCP to IP operation - pdcp_run (frame, 1, 0, eNB_id); //PHY_vars_eNB_g[eNB_id]->Mod_id + //IP/OTG to PDCP and PDCP to IP operation + pdcp_run (frame, 1, 0, eNB_inst); //PHY_vars_eNB_g[eNB_id]->Mod_id #endif - // PHY_vars_eNB_g[eNB_id]->frame = frame; - phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_id], abstraction_flag, no_relay, NULL); + // PHY_vars_eNB_g[eNB_id]->frame = frame; + phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_inst], abstraction_flag, no_relay, NULL); #ifdef PRINT_STATS - if(last_slot==9 && frame%10==0) - if(eNB_avg_thr) - fprintf(eNB_avg_thr,"%d %d\n",PHY_vars_eNB_g[eNB_id]->frame,(PHY_vars_eNB_g[eNB_id]->total_system_throughput)/((PHY_vars_eNB_g[eNB_id]->frame+1)*10)); - if (eNB_stats[eNB_id]) { - len = dump_eNB_stats(PHY_vars_eNB_g[eNB_id], stats_buffer, 0); - rewind (eNB_stats[eNB_id]); - fwrite (stats_buffer, 1, len, eNB_stats[eNB_id]); - fflush(eNB_stats[eNB_id]); - } + if(last_slot==9 && frame%10==0) + if(eNB_avg_thr) + fprintf(eNB_avg_thr,"%d %d\n",PHY_vars_eNB_g[eNB_inst]->frame,(PHY_vars_eNB_g[eNB_inst]->total_system_throughput)/((PHY_vars_eNB_g[eNB_inst]->frame+1)*10)); + if (eNB_stats[eNB_inst]) { + len = dump_eNB_stats(PHY_vars_eNB_g[eNB_inst], stats_buffer, 0); + rewind (eNB_stats[eNB_inst]); + fwrite (stats_buffer, 1, len, eNB_stats[eNB_inst]); + fflush(eNB_stats[eNB_inst]); + } #ifdef OPENAIR2 - if (eNB_l2_stats) { - len = dump_eNB_l2_stats (stats_buffer, 0); - rewind (eNB_l2_stats); - fwrite (stats_buffer, 1, len, eNB_l2_stats); - fflush(eNB_l2_stats); - } + if (eNB_l2_stats) { + len = dump_eNB_l2_stats (stats_buffer, 0); + rewind (eNB_l2_stats); + fwrite (stats_buffer, 1, len, eNB_l2_stats); + fflush(eNB_l2_stats); + } #endif #endif - } - } - // Call ETHERNET emulation here - //emu_transport (frame, last_slot, next_slot, direction, oai_emulation.info.frame_type, ethernet_flag); + } + } + // Call ETHERNET emulation here + //emu_transport (frame, last_slot, next_slot, direction, oai_emulation.info.frame_type, ethernet_flag); #if defined(ENABLE_ITTI) - log_set_instance_type (LOG_INSTANCE_UE); + log_set_instance_type (LOG_INSTANCE_UE); #endif - if ((next_slot % 2) == 0) - clear_UE_transport_info (oai_emulation.info.nb_ue_local); - for (UE_id = oai_emulation.info.first_ue_local; - (UE_id < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local)); UE_id++) { - if (oai_emulation.info.cli_start_ue[UE_id] != 0) { + if ((next_slot % 2) == 0) + clear_UE_transport_info (oai_emulation.info.nb_ue_local); + for (UE_inst = oai_emulation.info.first_ue_local; + (UE_inst < (oai_emulation.info.first_ue_local + oai_emulation.info.nb_ue_local)); UE_inst++) { + if (oai_emulation.info.cli_start_ue[UE_inst] != 0) { #if defined(ENABLE_ITTI) && defined(ENABLE_USE_MME) - + #else - if (frame >= (UE_id * 20)) // activate UE only after 20*UE_id frames so that different UEs turn on separately + if (frame >= (UE_inst * 20)) // activate UE only after 20*UE_id frames so that different UEs turn on separately #endif - { - LOG_D(EMU, "PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", UE_id, frame, slot, next_slot >> 1, last_slot>>1); - - if (PHY_vars_UE_g[UE_id]->UE_mode[0] != NOT_SYNCHED) { - if (frame > 0) { - PHY_vars_UE_g[UE_id]->frame = frame; - + { + LOG_D(EMU, "PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", + UE_inst, + frame, + slot, + next_slot >> 1, + last_slot>>1); + + if (PHY_vars_UE_g[UE_inst]->UE_mode[0] != NOT_SYNCHED) { + if (frame > 0) { + PHY_vars_UE_g[UE_inst]->frame = frame; + #ifdef OPENAIR2 - //Application - update_otg_UE (UE_id, oai_emulation.info.time_ms); - - //Access layer - pdcp_run (frame, 0, UE_id, 0); + //Application + update_otg_UE (UE_inst, oai_emulation.info.time_ms); + + //Access layer + pdcp_run (frame, 0, UE_inst, 0); #endif - - phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_id], 0, abstraction_flag, normal_txrx, - no_relay, NULL); - ue_data[UE_id]->tx_power_dBm = PHY_vars_UE_g[UE_id]->tx_power_dBm; - } - } - else { - if (abstraction_flag == 1) { - LOG_E( - EMU, - "sync not supported in abstraction mode (UE%d,mode%d)\n", UE_id, PHY_vars_UE_g[UE_id]->UE_mode[0]); - exit (-1); - } - if ((frame > 0) && (last_slot == (LTE_SLOTS_PER_FRAME - 2))) { - initial_sync (PHY_vars_UE_g[UE_id], normal_txrx); - - /* + + phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_inst], 0, abstraction_flag, normal_txrx, + no_relay, NULL); + ue_data[UE_inst]->tx_power_dBm = PHY_vars_UE_g[UE_inst]->tx_power_dBm; + } + } + else { + if (abstraction_flag == 1) { + LOG_E( + EMU, + "sync not supported in abstraction mode (UE%d,mode%d)\n", UE_inst, PHY_vars_UE_g[UE_inst]->UE_mode[0]); + exit (-1); + } + if ((frame > 0) && (last_slot == (LTE_SLOTS_PER_FRAME - 2))) { + initial_sync (PHY_vars_UE_g[UE_inst], normal_txrx); + + /* write_output("dlchan00.m","dlch00",&(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[0][0][0]),(6*(PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)),1,1); if (PHY_vars_UE_g[0]->lte_frame_parms.nb_antennas_rx>1) write_output("dlchan01.m","dlch01",&(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[0][1][0]),(6*(PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)),1,1); @@ -737,70 +742,72 @@ void *l2l1_task(void *args_p) { write_output("pbch_rxF_ext0.m","pbch_ext0",PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->rxdataF_ext[0],6*12*4,1,1); write_output("pbch_rxF_comp0.m","pbch_comp0",PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->rxdataF_comp[0],6*12*4,1,1); write_output("pbch_rxF_llr.m","pbch_llr",PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->llr,(frame_parms->Ncp==0) ? 1920 : 1728,1,4); - */ - } - } + */ + } + } #ifdef PRINT_STATS - if(last_slot==2 && frame%10==0) - if (UE_stats_th[UE_id]) - fprintf(UE_stats_th[UE_id],"%d %d\n",frame, PHY_vars_UE_g[UE_id]->bitrate[0]/1000); - if (UE_stats[UE_id]) { - len = dump_ue_stats (PHY_vars_UE_g[UE_id], stats_buffer, 0, normal_txrx, 0); - rewind (UE_stats[UE_id]); - fwrite (stats_buffer, 1, len, UE_stats[UE_id]); - fflush(UE_stats[UE_id]); - } + if(last_slot==2 && frame%10==0) { + if (UE_stats_th[UE_inst]) { + fprintf(UE_stats_th[UE_inst],"%d %d\n",frame, PHY_vars_UE_g[UE_inst]->bitrate[0]/1000); + } + } + if (UE_stats[UE_inst]) { + len = dump_ue_stats (PHY_vars_UE_g[UE_inst], stats_buffer, 0, normal_txrx, 0); + rewind (UE_stats[UE_inst]); + fwrite (stats_buffer, 1, len, UE_stats[UE_inst]); + fflush(UE_stats[UE_inst]); + } #endif - } - } - } -#ifdef Rel10 - for (RN_id=oai_emulation.info.first_rn_local; - RN_id<oai_emulation.info.first_rn_local+oai_emulation.info.nb_rn_local; - RN_id++) { - // UE id and eNB id of the RN - UE_id= oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local + RN_id;// NB_UE_INST + RN_id - eNB_id= oai_emulation.info.first_enb_local+oai_emulation.info.nb_enb_local + RN_id;// NB_eNB_INST + RN_id - // currently only works in FDD - if (oai_emulation.info.eMBMS_active_state == 4) { - r_type = multicast_relay; - //LOG_I(EMU,"Activating the multicast relaying\n"); - } - else { - LOG_E(EMU,"Not supported eMBMS option when relaying is enabled %d\n", r_type); - exit(-1); - } - PHY_vars_RN_g[RN_id]->frame = frame; - if ( oai_emulation.info.frame_type == 0) { - // RN == UE - if (frame>0) { - if (PHY_vars_UE_g[UE_id]->UE_mode[0] != NOT_SYNCHED) { - LOG_D(EMU,"[RN %d] PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", - RN_id, UE_id, frame, slot, next_slot >> 1,last_slot>>1); - PHY_vars_UE_g[UE_id]->frame = frame; - phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_id], 0, abstraction_flag,normal_txrx, - r_type, PHY_vars_RN_g[RN_id]); + } + } } - else if (last_slot == (LTE_SLOTS_PER_FRAME-2)) { - initial_sync(PHY_vars_UE_g[UE_id],normal_txrx); +#ifdef Rel10 + for (RN_id=oai_emulation.info.first_rn_local; + RN_id<oai_emulation.info.first_rn_local+oai_emulation.info.nb_rn_local; + RN_id++) { + // UE id and eNB id of the RN + UE_inst= oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local + RN_id;// NB_UE_INST + RN_id + eNB_inst= oai_emulation.info.first_enb_local+oai_emulation.info.nb_enb_local + RN_id;// NB_eNB_INST + RN_id + // currently only works in FDD + if (oai_emulation.info.eMBMS_active_state == 4) { + r_type = multicast_relay; + //LOG_I(EMU,"Activating the multicast relaying\n"); + } + else { + LOG_E(EMU,"Not supported eMBMS option when relaying is enabled %d\n", r_type); + exit(-1); + } + PHY_vars_RN_g[RN_id]->frame = frame; + if ( oai_emulation.info.frame_type == 0) { + // RN == UE + if (frame>0) { + if (PHY_vars_UE_g[UE_id]->UE_mode[0] != NOT_SYNCHED) { + LOG_D(EMU,"[RN %d] PHY procedures UE %d for frame %d, slot %d (subframe TX %d, RX %d)\n", + RN_id, UE_id, frame, slot, next_slot >> 1,last_slot>>1); + PHY_vars_UE_g[UE_id]->frame = frame; + phy_procedures_UE_lte (last_slot, next_slot, PHY_vars_UE_g[UE_id], 0, abstraction_flag,normal_txrx, + r_type, PHY_vars_RN_g[RN_id]); + } + else if (last_slot == (LTE_SLOTS_PER_FRAME-2)) { + initial_sync(PHY_vars_UE_g[UE_id],normal_txrx); + } + } + // RN == eNB + LOG_D(EMU,"[RN %d] PHY procedures eNB %d for frame %d, slot %d (subframe TX %d, RX %d)\n", + RN_id, eNB_id, frame, slot, next_slot >> 1,last_slot>>1); + phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_id], abstraction_flag, + r_type, PHY_vars_RN_g[RN_id]); + } + else { + LOG_E(EMU,"TDD is not supported for multicast relaying %d\n", r_type); + exit(-1); + } } - } - // RN == eNB - LOG_D(EMU,"[RN %d] PHY procedures eNB %d for frame %d, slot %d (subframe TX %d, RX %d)\n", - RN_id, eNB_id, frame, slot, next_slot >> 1,last_slot>>1); - phy_procedures_eNB_lte (last_slot, next_slot, PHY_vars_eNB_g[eNB_id], abstraction_flag, - r_type, PHY_vars_RN_g[RN_id]); - } - else { - LOG_E(EMU,"TDD is not supported for multicast relaying %d\n", r_type); - exit(-1); - } - } #endif - emu_transport (frame, last_slot, next_slot, direction, oai_emulation.info.frame_type, ethernet_flag); - if ((direction == SF_DL) || (frame_parms->frame_type == 0)) { - // consider only sec id 0 - /* for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { + emu_transport (frame, last_slot, next_slot, direction, oai_emulation.info.frame_type, ethernet_flag); + if ((direction == SF_DL) || (frame_parms->frame_type == 0)) { + // consider only sec id 0 + /* for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { if (abstraction_flag == 0) { do_OFDM_mod(PHY_vars_eNB_g[eNB_id]->lte_eNB_common_vars.txdataF[0], PHY_vars_eNB_g[eNB_id]->lte_eNB_common_vars.txdata[0], @@ -808,15 +815,15 @@ void *l2l1_task(void *args_p) { frame_parms); } }*/ - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - do_DL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, eNB2UE, enb_data, ue_data, next_slot, abstraction_flag, - frame_parms, UE_id); - } - } - if ((direction == SF_UL) || (frame_parms->frame_type == 0)) { //if ((subframe<2) || (subframe>4)) - do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, enb_data, ue_data, next_slot, abstraction_flag, - frame_parms, frame); - /* + for (UE_inst = 0; UE_inst < NB_UE_INST; UE_inst++) { + do_DL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, eNB2UE, enb_data, ue_data, next_slot, abstraction_flag, + frame_parms, UE_inst); + } + } + if ((direction == SF_UL) || (frame_parms->frame_type == 0)) { //if ((subframe<2) || (subframe>4)) + do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, enb_data, ue_data, next_slot, abstraction_flag, + frame_parms, frame); + /* int ccc; fprintf(SINRpost,"SINRdb For eNB New Subframe : \n "); for(ccc = 0 ; ccc<301; ccc++) @@ -824,11 +831,11 @@ void *l2l1_task(void *args_p) { fprintf(SINRpost,"_ %f ", SINRpost_eff[ccc]); } fprintf(SINRpost,"SINRdb For eNB : %f \n ", SINRpost_eff[ccc]); - */ - } - if ((direction == SF_S)) { //it must be a special subframe - if (next_slot % 2 == 0) { //DL part - /* for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { + */ + } + if ((direction == SF_S)) { //it must be a special subframe + if (next_slot % 2 == 0) { //DL part + /* for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { if (abstraction_flag == 0) { do_OFDM_mod(PHY_vars_eNB_g[eNB_id]->lte_eNB_common_vars.txdataF[0], PHY_vars_eNB_g[eNB_id]->lte_eNB_common_vars.txdata[0], @@ -836,22 +843,22 @@ void *l2l1_task(void *args_p) { frame_parms); } }*/ - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - do_DL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, eNB2UE, enb_data, ue_data, next_slot, abstraction_flag, - frame_parms, UE_id); - } - /* + for (UE_inst = 0; UE_inst < NB_UE_INST; UE_inst++) { + do_DL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, eNB2UE, enb_data, ue_data, next_slot, abstraction_flag, + frame_parms, UE_inst); + } + /* for (aarx=0;aarx<UE2eNB[1][0]->nb_rx;aarx++) for (aatx=0;aatx<UE2eNB[1][0]->nb_tx;aatx++) for (k=0;k<UE2eNB[1][0]->channel_length;k++) printf("SB(%d,%d,%d)->(%f,%f)\n",k,aarx,aatx,UE2eNB[1][0]->ch[aarx+(aatx*UE2eNB[1][0]->nb_rx)][k].r,UE2eNB[1][0]->ch[aarx+(aatx*UE2eNB[1][0]->nb_rx)][k].i); - */ - } - else { // UL part - do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, enb_data, ue_data, next_slot, abstraction_flag, - frame_parms, frame); + */ + } + else { // UL part + do_UL_sig (r_re0, r_im0, r_re, r_im, s_re, s_im, UE2eNB, enb_data, ue_data, next_slot, abstraction_flag, + frame_parms, frame); - /* int ccc; + /* int ccc; fprintf(SINRpost,"SINRdb For eNB New Subframe : \n "); for(ccc = 0 ; ccc<301; ccc++) { @@ -859,105 +866,105 @@ void *l2l1_task(void *args_p) { } fprintf(SINRpost,"SINRdb For eNB : %f \n ", SINRpost_eff[ccc]); } - */} - } - if ((last_slot == 1) && (frame == 0) && (abstraction_flag == 0) && (oai_emulation.info.n_frames == 1)) { - - write_output ("dlchan0.m", "dlch0", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[0][0][0]), - (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); - write_output ("dlchan1.m", "dlch1", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[1][0][0]), - (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); - write_output ("dlchan2.m", "dlch2", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[2][0][0]), - (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); - write_output ("pbch_rxF_comp0.m", "pbch_comp0", PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->rxdataF_comp[0], - 6 * 12 * 4, 1, 1); - write_output ("pbch_rxF_llr.m", "pbch_llr", PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->llr, - (frame_parms->Ncp == 0) ? 1920 : 1728, 1, 4); - } - /* + */} + } + if ((last_slot == 1) && (frame == 0) && (abstraction_flag == 0) && (oai_emulation.info.n_frames == 1)) { + + write_output ("dlchan0.m", "dlch0", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[0][0][0]), + (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); + write_output ("dlchan1.m", "dlch1", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[1][0][0]), + (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); + write_output ("dlchan2.m", "dlch2", &(PHY_vars_UE_g[0]->lte_ue_common_vars.dl_ch_estimates[2][0][0]), + (6 * (PHY_vars_UE_g[0]->lte_frame_parms.ofdm_symbol_size)), 1, 1); + write_output ("pbch_rxF_comp0.m", "pbch_comp0", PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->rxdataF_comp[0], + 6 * 12 * 4, 1, 1); + write_output ("pbch_rxF_llr.m", "pbch_llr", PHY_vars_UE_g[0]->lte_ue_pbch_vars[0]->llr, + (frame_parms->Ncp == 0) ? 1920 : 1728, 1, 4); + } + /* if ((last_slot==1) && (frame==1)) { write_output("dlsch_rxF_comp0.m","dlsch0_rxF_comp0",PHY_vars_UE->lte_ue_pdsch_vars[eNB_id]->rxdataF_comp[0],300*(-(PHY_vars_UE->lte_frame_parms.Ncp*2)+14),1,1); write_output("pdcch_rxF_comp0.m","pdcch0_rxF_comp0",PHY_vars_UE->lte_ue_pdcch_vars[eNB_id]->rxdataF_comp[0],4*300,1,1); } - */ - - if (next_slot % 2 == 0) { - clock_gettime (CLOCK_REALTIME, &time_spec); - time_last = time_now; - time_now = (unsigned long) time_spec.tv_nsec; - td = (int) (time_now - time_last); - if (td > 0) { - td_avg = (int) (((K * (long) td) + (((1 << 3) - K) * ((long) td_avg))) >> 3); // in us - LOG_T( - EMU, - "sleep frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", frame, time_now, time_last, td_avg, td/1000, (td_avg-TARGET_SF_TIME_NS)/1000); - } - if (td_avg < (TARGET_SF_TIME_NS - SF_DEVIATION_OFFSET_NS)) { - sleep_time_us += SLEEP_STEP_US; - LOG_D(EMU, "Faster than realtime increase the avg sleep time for %d us, frame %d\n", sleep_time_us, frame); - // LOG_D(EMU,"Faster than realtime increase the avg sleep time for %d us, frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", sleep_time_us,frame, time_now,time_last,td_avg, td/1000,(td_avg-TARGET_SF_TIME_NS)/1000); - } - else - if (td_avg > (TARGET_SF_TIME_NS + SF_DEVIATION_OFFSET_NS)) { - sleep_time_us -= SLEEP_STEP_US; - LOG_D( - EMU, - "Slower than realtime reduce the avg sleep time for %d us, frame %d, time_now\n", sleep_time_us, frame); - //LOG_T(EMU,"Slower than realtime reduce the avg sleep time for %d us, frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", sleep_time_us,frame, time_now,time_last,td_avg, td/1000,(td_avg-TARGET_SF_TIME_NS)/1000); - } - } // end if next_slot%2 - } // if Channel_Flag==0 - - } //end of slot - - if ((frame >= 1) && (frame <= 9) && (abstraction_flag == 0) + */ + + if (next_slot % 2 == 0) { + clock_gettime (CLOCK_REALTIME, &time_spec); + time_last = time_now; + time_now = (unsigned long) time_spec.tv_nsec; + td = (int) (time_now - time_last); + if (td > 0) { + td_avg = (int) (((K * (long) td) + (((1 << 3) - K) * ((long) td_avg))) >> 3); // in us + LOG_T( + EMU, + "sleep frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", frame, time_now, time_last, td_avg, td/1000, (td_avg-TARGET_SF_TIME_NS)/1000); + } + if (td_avg < (TARGET_SF_TIME_NS - SF_DEVIATION_OFFSET_NS)) { + sleep_time_us += SLEEP_STEP_US; + LOG_D(EMU, "Faster than realtime increase the avg sleep time for %d us, frame %d\n", sleep_time_us, frame); + // LOG_D(EMU,"Faster than realtime increase the avg sleep time for %d us, frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", sleep_time_us,frame, time_now,time_last,td_avg, td/1000,(td_avg-TARGET_SF_TIME_NS)/1000); + } + else + if (td_avg > (TARGET_SF_TIME_NS + SF_DEVIATION_OFFSET_NS)) { + sleep_time_us -= SLEEP_STEP_US; + LOG_D( + EMU, + "Slower than realtime reduce the avg sleep time for %d us, frame %d, time_now\n", sleep_time_us, frame); + //LOG_T(EMU,"Slower than realtime reduce the avg sleep time for %d us, frame %d, time_now %ldus,time_last %ldus,average time difference %ldns, CURRENT TIME DIFF %dus, avgerage difference from the target %dus\n", sleep_time_us,frame, time_now,time_last,td_avg, td/1000,(td_avg-TARGET_SF_TIME_NS)/1000); + } + } // end if next_slot%2 + } // if Channel_Flag==0 + + } //end of slot + + if ((frame >= 1) && (frame <= 9) && (abstraction_flag == 0) #ifdef PROC - &&(Channel_Flag==0) + &&(Channel_Flag==0) #endif - ) { - write_output ("UEtxsig0.m", "txs0", PHY_vars_UE_g[0]->lte_ue_common_vars.txdata[0], FRAME_LENGTH_COMPLEX_SAMPLES, - 1, 1); - sprintf (fname, "eNBtxsig%d.m", frame); - sprintf (vname, "txs%d", frame); - write_output (fname, vname, PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][0], FRAME_LENGTH_COMPLEX_SAMPLES, 1, - 1); - write_output ( - "eNBtxsigF0.m", "txsF0", PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdataF[0][0], - PHY_vars_eNB_g[0]->lte_frame_parms.symbols_per_tti * PHY_vars_eNB_g[0]->lte_frame_parms.ofdm_symbol_size, 1, - 1); - - write_output ("UErxsig0.m", "rxs0", PHY_vars_UE_g[0]->lte_ue_common_vars.rxdata[0], FRAME_LENGTH_COMPLEX_SAMPLES, - 1, 1); - write_output ("eNBrxsig0.m", "rxs0", PHY_vars_eNB_g[0]->lte_eNB_common_vars.rxdata[0][0], - FRAME_LENGTH_COMPLEX_SAMPLES, 1, 1); - } + ) { + write_output ("UEtxsig0.m", "txs0", PHY_vars_UE_g[0]->lte_ue_common_vars.txdata[0], FRAME_LENGTH_COMPLEX_SAMPLES, + 1, 1); + sprintf (fname, "eNBtxsig%d.m", frame); + sprintf (vname, "txs%d", frame); + write_output (fname, vname, PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdata[0][0], FRAME_LENGTH_COMPLEX_SAMPLES, 1, + 1); + write_output ( + "eNBtxsigF0.m", "txsF0", PHY_vars_eNB_g[0]->lte_eNB_common_vars.txdataF[0][0], + PHY_vars_eNB_g[0]->lte_frame_parms.symbols_per_tti * PHY_vars_eNB_g[0]->lte_frame_parms.ofdm_symbol_size, 1, + 1); + + write_output ("UErxsig0.m", "rxs0", PHY_vars_UE_g[0]->lte_ue_common_vars.rxdata[0], FRAME_LENGTH_COMPLEX_SAMPLES, + 1, 1); + write_output ("eNBrxsig0.m", "rxs0", PHY_vars_eNB_g[0]->lte_eNB_common_vars.rxdata[0][0], + FRAME_LENGTH_COMPLEX_SAMPLES, 1, 1); + } #ifdef XFORMS - eNB_id = 0; - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - phy_scope_UE(form_ue[UE_id], - PHY_vars_UE_g[UE_id], - eNB_id, - UE_id, - 7); - - phy_scope_eNB(form_enb[UE_id], - PHY_vars_eNB_g[eNB_id], - UE_id); + eNB_id = 0; + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + phy_scope_UE(form_ue[UE_id], + PHY_vars_UE_g[UE_id], + eNB_id, + UE_id, + 7); + + phy_scope_eNB(form_enb[UE_id], + PHY_vars_eNB_g[eNB_id], + UE_id); - } + } #endif - // calibrate at the end of each frame if there is some time left - if ((sleep_time_us > 0) && (ethernet_flag == 0)) { - LOG_I(EMU, "[TIMING] Adjust average frame duration, sleep for %d us\n", sleep_time_us); - //usleep (sleep_time_us); - sleep_time_us = 0; // reset the timer, could be done per n SF - } + // calibrate at the end of each frame if there is some time left + if ((sleep_time_us > 0) && (ethernet_flag == 0)) { + LOG_I(EMU, "[TIMING] Adjust average frame duration, sleep for %d us\n", sleep_time_us); + //usleep (sleep_time_us); + sleep_time_us = 0; // reset the timer, could be done per n SF + } #ifdef SMBV - if ((frame == config_frames[0]) || (frame == config_frames[1]) || (frame == config_frames[2]) || (frame == config_frames[3])) { - smbv_frame_cnt++; - } + if ((frame == config_frames[0]) || (frame == config_frames[1]) || (frame == config_frames[2]) || (frame == config_frames[3])) { + smbv_frame_cnt++; + } #endif } //end of frame @@ -967,19 +974,19 @@ void *l2l1_task(void *args_p) { #ifdef PRINT_STATS for (UE_id=0;UE_id<NB_UE_INST;UE_id++) { - if (UE_stats[UE_id]) - fclose (UE_stats[UE_id]); - if(UE_stats_th[UE_id]) - fclose (UE_stats_th[UE_id]); + if (UE_stats[UE_id]) + fclose (UE_stats[UE_id]); + if(UE_stats_th[UE_id]) + fclose (UE_stats_th[UE_id]); } for (eNB_id=0;eNB_id<NB_eNB_INST;eNB_id++) { - if (eNB_stats[eNB_id]) - fclose (eNB_stats[eNB_id]); + if (eNB_stats[eNB_id]) + fclose (eNB_stats[eNB_id]); } if (eNB_avg_thr) - fclose (eNB_avg_thr); + fclose (eNB_avg_thr); if (eNB_l2_stats) - fclose (eNB_l2_stats); + fclose (eNB_l2_stats); #endif @@ -1030,7 +1037,7 @@ int main(int argc, char **argv) { // get command-line options get_simulation_options (argc, argv); //Command-line options - + // Initialize VCD LOG module vcd_signal_dumper_init (oai_emulation.info.vcd_file); @@ -1051,9 +1058,9 @@ int main(int argc, char **argv) { oaisim_config (); // config OMG and OCG, OPT, OTG, OLG if (ue_connection_test == 1) { - snr_direction = -snr_step; - snr_dB = 20; - sinr_dB = -20; + snr_direction = -snr_step; + snr_dB = 20; + sinr_dB = -20; } #ifdef OPENAIR2 @@ -1085,15 +1092,15 @@ int main(int argc, char **argv) { init_slot_isr (); t = clock (); - + LOG_N(EMU, ">>>>>>>>>>>>>>>>>>>>>>>>>>> OAIEMU initialization done <<<<<<<<<<<<<<<<<<<<<<<<<<\n\n"); #if defined(ENABLE_ITTI) // Handle signals until all tasks are terminated if (create_tasks(oai_emulation.info.nb_enb_local, oai_emulation.info.nb_ue_local) >= 0) { - itti_wait_tasks_end(); + itti_wait_tasks_end(); } else { - exit(-1); // need a softer mode + exit(-1); // need a softer mode } #else if (oai_emulation.info.nb_enb_local > 0) { @@ -1111,7 +1118,7 @@ int main(int argc, char **argv) { #ifdef SMBV if (config_smbv) { - smbv_send_config (smbv_fname,smbv_ip); + smbv_send_config (smbv_fname,smbv_ip); } #endif @@ -1121,16 +1128,16 @@ int main(int argc, char **argv) { // relase all rx state if (ethernet_flag == 1) { - emu_transport_release (); + emu_transport_release (); } #ifdef PROC if (abstraction_flag == 0 && Channel_Flag==0 && Process_Flag==0) #else - if (abstraction_flag == 0) + if (abstraction_flag == 0) #endif { - /* + /* #ifdef IFFT_FPGA free(txdataF2[0]); free(txdataF2[1]); @@ -1139,30 +1146,31 @@ int main(int argc, char **argv) { free(txdata[1]); free(txdata); #endif - */ + */ - for (i = 0; i < 2; i++) { - free (s_re[i]); - free (s_im[i]); - free (r_re[i]); - free (r_im[i]); - } - free (s_re); - free (s_im); - free (r_re); - free (r_im); + for (i = 0; i < 2; i++) { + free (s_re[i]); + free (s_im[i]); + free (r_re[i]); + free (r_im[i]); + } + free (s_re); + free (s_im); + free (r_re); + free (r_im); - lte_sync_time_free (); - } + lte_sync_time_free (); + } // pthread_join(sigth, NULL); // added for PHY abstraction if (oai_emulation.info.ocm_enabled == 1) { - for (eNB_id = 0; eNB_id < NUMBER_OF_eNB_MAX; eNB_id++) - free (enb_data[eNB_id]); - - for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) - free (ue_data[UE_id]); + for (eNB_inst = 0; eNB_inst < NUMBER_OF_eNB_MAX; eNB_inst++) { + free (enb_data[eNB_inst]); + } + for (UE_inst = 0; UE_inst < NUMBER_OF_UE_MAX; UE_inst++) { + free (ue_data[UE_inst]); + } } //End of PHY abstraction changes #ifdef OPENAIR2 @@ -1223,8 +1231,8 @@ void terminate(void) { char interfaceName[8]; for (i = 0; i < NUMBER_OF_eNB_MAX + NUMBER_OF_UE_MAX; i++) if (oai_emulation.info.oai_ifup[i] == 1) { - sprintf (interfaceName, "oai%d", i); - bringInterfaceUp (interfaceName, 0); + sprintf (interfaceName, "oai%d", i); + bringInterfaceUp (interfaceName, 0); } } diff --git a/targets/SIMU/USER/oaisim.h b/targets/SIMU/USER/oaisim.h index 8e96153ed3a4e34387ab04b67060196a25e76d6b..86bd4df113d148243d153d7d56ceccf63a1a1904 100644 --- a/targets/SIMU/USER/oaisim.h +++ b/targets/SIMU/USER/oaisim.h @@ -40,7 +40,7 @@ int ulsch_abstraction(double* sinr_dB,u8 TM, u8 mcs,u16 nb_rb, u16 first_rb); void calc_path_loss(node_desc_t* node_tx, node_desc_t* node_rx, channel_desc_t *ch_desc, Environment_System_Config env_desc, double **SF); -void do_OFDM_mod(mod_sym_t **txdataF, s32 **txdata, uint32_t frame, u16 next_slot, LTE_DL_FRAME_PARMS *frame_parms); +void do_OFDM_mod(mod_sym_t **txdataF, s32 **txdata, frame_t frame, u16 next_slot, LTE_DL_FRAME_PARMS *frame_parms); #ifdef OPENAIR2 int omv_write (int pfd, Node_list enb_node_list, Node_list ue_node_list, Data_Flow_Unit omv_data); diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 0b30f7c6fecff35b43c857284531209d42c1f501..2a8575af6ec56cf617feb2502eef17c5c2936309 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -51,39 +51,46 @@ extern char smbv_ip[16]; #define K 2 // averaging coefficient #define TARGET_SF_TIME_NS 1000000 // 1ms = 1000000 ns -int otg_times = 0; -int if_times = 0; -int for_times = 0; - -static char *conf_config_file_name = NULL; -u16 Nid_cell = 0; //needed by init_lte_vars -int nb_antennas_rx=2; // // -u8 target_dl_mcs = 0; -u8 rate_adaptation_flag = 0; -u8 set_sinr=0; -double snr_dB, sinr_dB; -u8 set_seed=0; -u8 cooperation_flag; // for cooperative communication -u8 abstraction_flag = 0, ethernet_flag = 0; -double snr_step=1.0; -u8 ue_connection_test=0; -double forgetting_factor=0.0; -u8 beta_ACK=0,beta_RI=0,beta_CQI=2; -u8 target_ul_mcs = 2; -LTE_DL_FRAME_PARMS *frame_parms; -int map1,map2; -double **ShaF= NULL; +int otg_times = 0; +int if_times = 0; +int for_times = 0; + +static char *conf_config_file_name = NULL; +u16 Nid_cell = 0; //needed by init_lte_vars +int nb_antennas_rx = 2; // // +u8 target_dl_mcs = 0; +u8 rate_adaptation_flag = 0; +u8 set_sinr = 0; +double snr_dB, sinr_dB; +u8 set_seed = 0; +u8 cooperation_flag; // for cooperative communication +u8 abstraction_flag = 0; +u8 ethernet_flag = 0; +double snr_step = 1.0; +u8 ue_connection_test = 0; +double forgetting_factor = 0.0; +u8 beta_ACK = 0; +u8 beta_RI = 0; +u8 beta_CQI = 2; +u8 target_ul_mcs = 2; +LTE_DL_FRAME_PARMS *frame_parms = NULL; +int map1,map2; +double **ShaF = NULL; // pointers signal buffers (s = transmit, r,r0 = receive) -double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; -Node_list ue_node_list = NULL; -Node_list enb_node_list = NULL; -int pdcp_period, omg_period; +double **s_re, **s_im, **r_re, **r_im, **r_re0, **r_im0; +Node_list ue_node_list = NULL; +Node_list enb_node_list = NULL; +int pdcp_period = 0; +int omg_period = 0; // time calibration for soft realtime mode struct timespec time_spec; -unsigned long time_last, time_now; -int td, td_avg, sleep_time_us; +unsigned long time_last = 0; +unsigned long time_now = 0; +int td = 0; +int td_avg = 0; +int sleep_time_us = 0; #ifdef OPENAIR2 // omv related info @@ -103,7 +110,7 @@ char frame_type[10]; char tdd_config[10]; #endif -Packet_OTG_List *otg_pdcp_buffer; +Packet_OTG_List *otg_pdcp_buffer = NULL; extern node_desc_t *enb_data[NUMBER_OF_eNB_MAX]; extern node_desc_t *ue_data[NUMBER_OF_UE_MAX]; @@ -121,488 +128,488 @@ void get_simulation_options(int argc, char *argv[]) { const Enb_properties_array_t *enb_properties; enum long_option_e { - LONG_OPTION_START = 0x100, /* Start after regular single char options */ + LONG_OPTION_START = 0x100, /* Start after regular single char options */ - LONG_OPTION_ENB_CONF, + LONG_OPTION_ENB_CONF, - LONG_OPTION_PDNC_PERIOD, - LONG_OPTION_OMG_PERIOD, + LONG_OPTION_PDNC_PERIOD, + LONG_OPTION_OMG_PERIOD, - LONG_OPTION_ENB_RAL_LISTENING_PORT, - LONG_OPTION_ENB_RAL_IP_ADDRESS, - LONG_OPTION_ENB_RAL_LINK_ID, - LONG_OPTION_ENB_RAL_LINK_ADDRESS, + LONG_OPTION_ENB_RAL_LISTENING_PORT, + LONG_OPTION_ENB_RAL_IP_ADDRESS, + LONG_OPTION_ENB_RAL_LINK_ID, + LONG_OPTION_ENB_RAL_LINK_ADDRESS, - LONG_OPTION_ENB_MIHF_REMOTE_PORT, - LONG_OPTION_ENB_MIHF_IP_ADDRESS, - LONG_OPTION_ENB_MIHF_ID, + LONG_OPTION_ENB_MIHF_REMOTE_PORT, + LONG_OPTION_ENB_MIHF_IP_ADDRESS, + LONG_OPTION_ENB_MIHF_ID, - LONG_OPTION_UE_RAL_LISTENING_PORT, - LONG_OPTION_UE_RAL_IP_ADDRESS, - LONG_OPTION_UE_RAL_LINK_ID, - LONG_OPTION_UE_RAL_LINK_ADDRESS, + LONG_OPTION_UE_RAL_LISTENING_PORT, + LONG_OPTION_UE_RAL_IP_ADDRESS, + LONG_OPTION_UE_RAL_LINK_ID, + LONG_OPTION_UE_RAL_LINK_ADDRESS, - LONG_OPTION_UE_MIHF_REMOTE_PORT, - LONG_OPTION_UE_MIHF_IP_ADDRESS, - LONG_OPTION_UE_MIHF_ID, + LONG_OPTION_UE_MIHF_REMOTE_PORT, + LONG_OPTION_UE_MIHF_IP_ADDRESS, + LONG_OPTION_UE_MIHF_ID, }; static struct option long_options[] = { - {"enb-conf", required_argument, 0, LONG_OPTION_ENB_CONF}, + {"enb-conf", required_argument, 0, LONG_OPTION_ENB_CONF}, - {"pdcp_period", required_argument, 0, LONG_OPTION_PDNC_PERIOD}, - {"omg_period", required_argument, 0, LONG_OPTION_OMG_PERIOD}, + {"pdcp_period", required_argument, 0, LONG_OPTION_PDNC_PERIOD}, + {"omg_period", required_argument, 0, LONG_OPTION_OMG_PERIOD}, - {"enb-ral-listening-port", required_argument, 0, LONG_OPTION_ENB_RAL_LISTENING_PORT}, - {"enb-ral-ip-address", required_argument, 0, LONG_OPTION_ENB_RAL_IP_ADDRESS}, - {"enb-ral-link-id", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ID}, - {"enb-ral-link-address", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ADDRESS}, + {"enb-ral-listening-port", required_argument, 0, LONG_OPTION_ENB_RAL_LISTENING_PORT}, + {"enb-ral-ip-address", required_argument, 0, LONG_OPTION_ENB_RAL_IP_ADDRESS}, + {"enb-ral-link-id", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ID}, + {"enb-ral-link-address", required_argument, 0, LONG_OPTION_ENB_RAL_LINK_ADDRESS}, - {"enb-mihf-remote-port", required_argument, 0, LONG_OPTION_ENB_MIHF_REMOTE_PORT}, - {"enb-mihf-ip-address", required_argument, 0, LONG_OPTION_ENB_MIHF_IP_ADDRESS}, - {"enb-mihf-id", required_argument, 0, LONG_OPTION_ENB_MIHF_ID}, + {"enb-mihf-remote-port", required_argument, 0, LONG_OPTION_ENB_MIHF_REMOTE_PORT}, + {"enb-mihf-ip-address", required_argument, 0, LONG_OPTION_ENB_MIHF_IP_ADDRESS}, + {"enb-mihf-id", required_argument, 0, LONG_OPTION_ENB_MIHF_ID}, - {"ue-ral-listening-port", required_argument, 0, LONG_OPTION_UE_RAL_LISTENING_PORT}, - {"ue-ral-ip-address", required_argument, 0, LONG_OPTION_UE_RAL_IP_ADDRESS}, - {"ue-ral-link-id", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ID}, - {"ue-ral-link-address", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ADDRESS}, + {"ue-ral-listening-port", required_argument, 0, LONG_OPTION_UE_RAL_LISTENING_PORT}, + {"ue-ral-ip-address", required_argument, 0, LONG_OPTION_UE_RAL_IP_ADDRESS}, + {"ue-ral-link-id", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ID}, + {"ue-ral-link-address", required_argument, 0, LONG_OPTION_UE_RAL_LINK_ADDRESS}, - {"ue-mihf-remote-port", required_argument, 0, LONG_OPTION_UE_MIHF_REMOTE_PORT}, - {"ue-mihf-ip-address", required_argument, 0, LONG_OPTION_UE_MIHF_IP_ADDRESS}, - {"ue-mihf-id", required_argument, 0, LONG_OPTION_UE_MIHF_ID}, - {NULL, 0, NULL, 0} + {"ue-mihf-remote-port", required_argument, 0, LONG_OPTION_UE_MIHF_REMOTE_PORT}, + {"ue-mihf-ip-address", required_argument, 0, LONG_OPTION_UE_MIHF_IP_ADDRESS}, + {"ue-mihf-id", required_argument, 0, LONG_OPTION_UE_MIHF_ID}, + {NULL, 0, NULL, 0} }; while ((option = getopt_long (argc, argv, "aA:b:B:c:C:D:d:eE:f:FGg:hHi:IJ:j:k:K:l:L:m:M:n:N:oO:p:P:Q:rR:s:S:t:T:u:U:vV:w:W:x:X:y:Y:z:Z:", long_options, NULL)) != -1) { - switch (option) { - case LONG_OPTION_ENB_CONF: - if (optarg) { - conf_config_file_name = strdup(optarg); - printf("eNB configuration file is %s\n", conf_config_file_name); - } - break; + switch (option) { + case LONG_OPTION_ENB_CONF: + if (optarg) { + conf_config_file_name = strdup(optarg); + printf("eNB configuration file is %s\n", conf_config_file_name); + } + break; - case LONG_OPTION_PDNC_PERIOD: - if (optarg) { - pdcp_period = atoi(optarg); - printf("PDCP period is %d\n", pdcp_period); - } - break; + case LONG_OPTION_PDNC_PERIOD: + if (optarg) { + pdcp_period = atoi(optarg); + printf("PDCP period is %d\n", pdcp_period); + } + break; - case LONG_OPTION_OMG_PERIOD: - if (optarg) { - omg_period = atoi(optarg); - printf("OMG period is %d\n", omg_period); - } - break; + case LONG_OPTION_OMG_PERIOD: + if (optarg) { + omg_period = atoi(optarg); + printf("OMG period is %d\n", omg_period); + } + break; #if defined(ENABLE_RAL) - case LONG_OPTION_ENB_RAL_LISTENING_PORT: - if (optarg) { - g_conf_enb_ral_listening_port = strdup(optarg); - printf("eNB RAL listening port is %s\n", g_conf_enb_ral_listening_port); - } - break; + case LONG_OPTION_ENB_RAL_LISTENING_PORT: + if (optarg) { + g_conf_enb_ral_listening_port = strdup(optarg); + printf("eNB RAL listening port is %s\n", g_conf_enb_ral_listening_port); + } + break; - case LONG_OPTION_ENB_RAL_IP_ADDRESS: - if (optarg) { - g_conf_enb_ral_ip_address = strdup(optarg); - printf("eNB RAL IP address is %s\n", g_conf_enb_ral_ip_address); - } - break; + case LONG_OPTION_ENB_RAL_IP_ADDRESS: + if (optarg) { + g_conf_enb_ral_ip_address = strdup(optarg); + printf("eNB RAL IP address is %s\n", g_conf_enb_ral_ip_address); + } + break; - case LONG_OPTION_ENB_RAL_LINK_ADDRESS: - if (optarg) { - g_conf_enb_ral_link_address = strdup(optarg); - printf("eNB RAL link address is %s\n", g_conf_enb_ral_link_address); - } - break; + case LONG_OPTION_ENB_RAL_LINK_ADDRESS: + if (optarg) { + g_conf_enb_ral_link_address = strdup(optarg); + printf("eNB RAL link address is %s\n", g_conf_enb_ral_link_address); + } + break; - case LONG_OPTION_ENB_RAL_LINK_ID: - if (optarg) { - g_conf_enb_ral_link_id = strdup(optarg); - printf("eNB RAL link id is %s\n", g_conf_enb_ral_link_id); - } - break; + case LONG_OPTION_ENB_RAL_LINK_ID: + if (optarg) { + g_conf_enb_ral_link_id = strdup(optarg); + printf("eNB RAL link id is %s\n", g_conf_enb_ral_link_id); + } + break; - case LONG_OPTION_ENB_MIHF_REMOTE_PORT: - if (optarg) { - g_conf_enb_mihf_remote_port = strdup(optarg); - printf("eNB MIH-F remote port is %s\n", g_conf_enb_mihf_remote_port); - } - break; + case LONG_OPTION_ENB_MIHF_REMOTE_PORT: + if (optarg) { + g_conf_enb_mihf_remote_port = strdup(optarg); + printf("eNB MIH-F remote port is %s\n", g_conf_enb_mihf_remote_port); + } + break; - case LONG_OPTION_ENB_MIHF_IP_ADDRESS: - if (optarg) { - g_conf_enb_mihf_ip_address = strdup(optarg); - printf("eNB MIH-F IP address is %s\n", g_conf_enb_mihf_ip_address); - } - break; + case LONG_OPTION_ENB_MIHF_IP_ADDRESS: + if (optarg) { + g_conf_enb_mihf_ip_address = strdup(optarg); + printf("eNB MIH-F IP address is %s\n", g_conf_enb_mihf_ip_address); + } + break; - case LONG_OPTION_ENB_MIHF_ID: - if (optarg) { - g_conf_enb_mihf_id = strdup(optarg); - printf("eNB MIH-F id is %s\n", g_conf_enb_mihf_id); - } - break; + case LONG_OPTION_ENB_MIHF_ID: + if (optarg) { + g_conf_enb_mihf_id = strdup(optarg); + printf("eNB MIH-F id is %s\n", g_conf_enb_mihf_id); + } + break; - case LONG_OPTION_UE_RAL_LISTENING_PORT: - if (optarg) { - g_conf_ue_ral_listening_port = strdup(optarg); - printf("UE RAL listening port is %s\n", g_conf_ue_ral_listening_port); - } - break; + case LONG_OPTION_UE_RAL_LISTENING_PORT: + if (optarg) { + g_conf_ue_ral_listening_port = strdup(optarg); + printf("UE RAL listening port is %s\n", g_conf_ue_ral_listening_port); + } + break; - case LONG_OPTION_UE_RAL_IP_ADDRESS: - if (optarg) { - g_conf_ue_ral_ip_address = strdup(optarg); - printf("UE RAL IP address is %s\n", g_conf_ue_ral_ip_address); - } - break; + case LONG_OPTION_UE_RAL_IP_ADDRESS: + if (optarg) { + g_conf_ue_ral_ip_address = strdup(optarg); + printf("UE RAL IP address is %s\n", g_conf_ue_ral_ip_address); + } + break; - case LONG_OPTION_UE_RAL_LINK_ID: - if (optarg) { - g_conf_ue_ral_link_id = strdup(optarg); - printf("UE RAL link id is %s\n", g_conf_ue_ral_link_id); - } - break; + case LONG_OPTION_UE_RAL_LINK_ID: + if (optarg) { + g_conf_ue_ral_link_id = strdup(optarg); + printf("UE RAL link id is %s\n", g_conf_ue_ral_link_id); + } + break; - case LONG_OPTION_UE_RAL_LINK_ADDRESS: - if (optarg) { - g_conf_ue_ral_link_address = strdup(optarg); - printf("UE RAL link address is %s\n", g_conf_ue_ral_link_address); - } - break; + case LONG_OPTION_UE_RAL_LINK_ADDRESS: + if (optarg) { + g_conf_ue_ral_link_address = strdup(optarg); + printf("UE RAL link address is %s\n", g_conf_ue_ral_link_address); + } + break; - case LONG_OPTION_UE_MIHF_REMOTE_PORT: - if (optarg) { - g_conf_ue_mihf_remote_port = strdup(optarg); - printf("UE MIH-F remote port is %s\n", g_conf_ue_mihf_remote_port); - } - break; + case LONG_OPTION_UE_MIHF_REMOTE_PORT: + if (optarg) { + g_conf_ue_mihf_remote_port = strdup(optarg); + printf("UE MIH-F remote port is %s\n", g_conf_ue_mihf_remote_port); + } + break; - case LONG_OPTION_UE_MIHF_IP_ADDRESS: - if (optarg) { - g_conf_ue_mihf_ip_address = strdup(optarg); - printf("UE MIH-F IP address is %s\n", g_conf_ue_mihf_ip_address); - } - break; + case LONG_OPTION_UE_MIHF_IP_ADDRESS: + if (optarg) { + g_conf_ue_mihf_ip_address = strdup(optarg); + printf("UE MIH-F IP address is %s\n", g_conf_ue_mihf_ip_address); + } + break; - case LONG_OPTION_UE_MIHF_ID: - if (optarg) { - g_conf_ue_mihf_id = strdup(optarg); - printf("UE MIH-F id is %s\n", g_conf_ue_mihf_id); - } - break; + case LONG_OPTION_UE_MIHF_ID: + if (optarg) { + g_conf_ue_mihf_id = strdup(optarg); + printf("UE MIH-F id is %s\n", g_conf_ue_mihf_id); + } + break; #endif - case 'a': - abstraction_flag = 1; - break; - - case 'A': - //oai_emulation.info.ocm_enabled=1; - if (optarg == NULL) - oai_emulation.environment_system_config.fading.small_scale.selected_option="AWGN"; - else - oai_emulation.environment_system_config.fading.small_scale.selected_option= optarg; - //awgn_flag = 1; - break; - - case 'b': - oai_emulation.info.nb_enb_local = atoi (optarg); - break; - - case 'B': - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option = optarg; - //oai_emulation.info.omg_model_enb = atoi (optarg); - break; - - case 'c': - strcpy(oai_emulation.info.local_server, optarg); - oai_emulation.info.ocg_enabled=1; - break; - - case 'C': - oai_emulation.info.tdd_config = atoi (optarg); - AssertFatal (oai_emulation.info.tdd_config <= TDD_Config__subframeAssignment_sa6, "Illegal tdd_config %d (should be 0-%d)!", - oai_emulation.info.tdd_config, TDD_Config__subframeAssignment_sa6); - break; - - case 'D': - oai_emulation.info.multicast_ifname = strdup(optarg); - break; - - case 'e': - oai_emulation.info.extended_prefix_flag = 1; - break; - - case 'E': - set_seed = 1; - oai_emulation.info.seed = atoi (optarg); - break; - - case 'f': - forgetting_factor = atof (optarg); - break; - - case 'F': // set FDD - printf("Setting Frame to FDD\n"); - oai_emulation.info.frame_type = 0; - break; - - case 'g': - oai_emulation.info.multicast_group = atoi (optarg); - break; - - case 'G' : - oai_emulation.info.otg_bg_traffic_enabled = 1; - break; - - case 'h': - help (); - exit (1); - break; - - case 'H': - oai_emulation.info.handover_active=1; - printf("Activate the handover procedure at RRC\n"); - break; - - case 'i': + case 'a': + abstraction_flag = 1; + break; + + case 'A': + //oai_emulation.info.ocm_enabled=1; + if (optarg == NULL) + oai_emulation.environment_system_config.fading.small_scale.selected_option="AWGN"; + else + oai_emulation.environment_system_config.fading.small_scale.selected_option= optarg; + //awgn_flag = 1; + break; + + case 'b': + oai_emulation.info.nb_enb_local = atoi (optarg); + break; + + case 'B': + oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option = optarg; + //oai_emulation.info.omg_model_enb = atoi (optarg); + break; + + case 'c': + strcpy(oai_emulation.info.local_server, optarg); + oai_emulation.info.ocg_enabled=1; + break; + + case 'C': + oai_emulation.info.tdd_config = atoi (optarg); + AssertFatal (oai_emulation.info.tdd_config <= TDD_Config__subframeAssignment_sa6, "Illegal tdd_config %d (should be 0-%d)!", + oai_emulation.info.tdd_config, TDD_Config__subframeAssignment_sa6); + break; + + case 'D': + oai_emulation.info.multicast_ifname = strdup(optarg); + break; + + case 'e': + oai_emulation.info.extended_prefix_flag = 1; + break; + + case 'E': + set_seed = 1; + oai_emulation.info.seed = atoi (optarg); + break; + + case 'f': + forgetting_factor = atof (optarg); + break; + + case 'F': // set FDD + printf("Setting Frame to FDD\n"); + oai_emulation.info.frame_type = 0; + break; + + case 'g': + oai_emulation.info.multicast_group = atoi (optarg); + break; + + case 'G' : + oai_emulation.info.otg_bg_traffic_enabled = 1; + break; + + case 'h': + help (); + exit (1); + break; + + case 'H': + oai_emulation.info.handover_active=1; + printf("Activate the handover procedure at RRC\n"); + break; + + case 'i': #ifdef PROC - Process_Flag=1; - node_id = wgt+atoi(optarg); - port+=atoi(optarg); + Process_Flag=1; + node_id = wgt+atoi(optarg); + port+=atoi(optarg); #endif - break; - - case 'I': - oai_emulation.info.cli_enabled = 1; - break; - - case 'j' : - // number of relay nodes: currently only applicable to eMBMS - oai_emulation.info.nb_rn_local = atoi (optarg); - break; - - case 'J': - ue_connection_test=1; - oai_emulation.info.ocm_enabled=0; - snr_step = atof(optarg); - break; - - case 'k': - //ricean_factor = atof (optarg); - printf("[SIM] Option k is no longer supported on the command line. Please specify your channel model in the xml template\n"); - exit(-1); - break; - - case 'K': - oai_emulation.info.itti_dump_file = optarg; - break; - - case 'l': - oai_emulation.info.g_log_level = atoi(optarg); - break; - - case 'L': // set FDD - flag_LA = atoi(optarg); - break; - - case 'm': - target_dl_mcs = atoi (optarg); - break; - - case 'M': - abstraction_flag = 1; - ethernet_flag = 1; - oai_emulation.info.ethernet_id = atoi (optarg); - oai_emulation.info.master_id = oai_emulation.info.ethernet_id; - oai_emulation.info.ethernet_flag = 1; - break; - - case 'n': - oai_emulation.info.n_frames = atoi (optarg); - //n_frames = (n_frames >1024) ? 1024: n_frames; // adjust the n_frames if higher that 1024 - oai_emulation.info.n_frames_flag = 1; - break; - - case 'N': - Nid_cell = atoi (optarg); - if (Nid_cell > 503) { - printf("Illegal Nid_cell %d (should be 0 ... 503)\n", Nid_cell); + break; + + case 'I': + oai_emulation.info.cli_enabled = 1; + break; + + case 'j' : + // number of relay nodes: currently only applicable to eMBMS + oai_emulation.info.nb_rn_local = atoi (optarg); + break; + + case 'J': + ue_connection_test=1; + oai_emulation.info.ocm_enabled=0; + snr_step = atof(optarg); + break; + + case 'k': + //ricean_factor = atof (optarg); + printf("[SIM] Option k is no longer supported on the command line. Please specify your channel model in the xml template\n"); exit(-1); - } - break; - - case 'O': - conf_config_file_name = optarg; - break; - - case 'o': - oai_emulation.info.slot_isr = 1; - break; - - case 'p': - oai_emulation.info.nb_master = atoi (optarg); - break; - - case 'P': - oai_emulation.info.opt_enabled = 1; - - if (strcmp(optarg, "wireshark") == 0) { - opt_type = OPT_WIRESHARK; - printf("Enabling OPT for wireshark\n"); - } else if (strcmp(optarg, "pcap") == 0) { - opt_type = OPT_PCAP; - printf("Enabling OPT for pcap\n"); - } else { - printf("Unrecognized option for OPT module. -> Disabling it\n"); - printf("Possible values are either wireshark or pcap\n"); - opt_type = OPT_NONE; - oai_emulation.info.opt_enabled = 0; - } - oai_emulation.info.opt_mode = opt_type; - break; - - case 'Q': - //eMBMS_active=1; - // 0 : not used (default), 1: eMBMS and RRC enabled, 2: eMBMS relaying and RRC enabled, 3: eMBMS enabled, RRC disabled, 4: eMBMS relaying enabled, RRC disabled - oai_emulation.info.eMBMS_active_state = atoi (optarg); - break; - - case 'r': - rate_adaptation_flag = 1; - break; - - case 'R': - oai_emulation.info.N_RB_DL = atoi (optarg); - if ((oai_emulation.info.N_RB_DL != 6) && (oai_emulation.info.N_RB_DL != 15) && (oai_emulation.info.N_RB_DL != 25) - && (oai_emulation.info.N_RB_DL != 50) && (oai_emulation.info.N_RB_DL != 75) && (oai_emulation.info.N_RB_DL != 100)) { - printf("Illegal N_RB_DL %d (should be one of 6,15,25,50,75,100)\n", oai_emulation.info.N_RB_DL); - exit (-1); - } - break; - - case 's': - snr_dB = atoi (optarg); - // set_snr = 1; - oai_emulation.info.ocm_enabled=0; - break; - - case 'S': - sinr_dB = atoi (optarg); - set_sinr = 1; - oai_emulation.info.ocm_enabled=0; - break; - - case 't': - //Td = atof (optarg); - printf("[SIM] Option t is no longer supported on the command line. Please specify your channel model in the xml template\n"); - exit(-1); - break; - - case 'T': - oai_emulation.info.otg_enabled = 1; - oai_emulation.info.otg_traffic = optarg; - break; - - case 'u': - oai_emulation.info.nb_ue_local = atoi (optarg); - break; - - case 'U': - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option = optarg; - break; - - case 'v': - oai_emulation.info.omv_enabled = 1; - break; - - case 'V': - ouput_vcd = 1; - oai_emulation.info.vcd_enabled = 1; - oai_emulation.info.vcd_file = optarg; - break; - - case 'w': - oai_emulation.info.cba_group_active = atoi (optarg); - break; - - case 'W': + break; + + case 'K': + oai_emulation.info.itti_dump_file = optarg; + break; + + case 'l': + oai_emulation.info.g_log_level = atoi(optarg); + break; + + case 'L': // set FDD + flag_LA = atoi(optarg); + break; + + case 'm': + target_dl_mcs = atoi (optarg); + break; + + case 'M': + abstraction_flag = 1; + ethernet_flag = 1; + oai_emulation.info.ethernet_id = atoi (optarg); + oai_emulation.info.master_id = oai_emulation.info.ethernet_id; + oai_emulation.info.ethernet_flag = 1; + break; + + case 'n': + oai_emulation.info.n_frames = atoi (optarg); + //n_frames = (n_frames >1024) ? 1024: n_frames; // adjust the n_frames if higher that 1024 + oai_emulation.info.n_frames_flag = 1; + break; + + case 'N': + Nid_cell = atoi (optarg); + if (Nid_cell > 503) { + printf("Illegal Nid_cell %d (should be 0 ... 503)\n", Nid_cell); + exit(-1); + } + break; + + case 'O': + conf_config_file_name = optarg; + break; + + case 'o': + oai_emulation.info.slot_isr = 1; + break; + + case 'p': + oai_emulation.info.nb_master = atoi (optarg); + break; + + case 'P': + oai_emulation.info.opt_enabled = 1; + + if (strcmp(optarg, "wireshark") == 0) { + opt_type = OPT_WIRESHARK; + printf("Enabling OPT for wireshark\n"); + } else if (strcmp(optarg, "pcap") == 0) { + opt_type = OPT_PCAP; + printf("Enabling OPT for pcap\n"); + } else { + printf("Unrecognized option for OPT module. -> Disabling it\n"); + printf("Possible values are either wireshark or pcap\n"); + opt_type = OPT_NONE; + oai_emulation.info.opt_enabled = 0; + } + oai_emulation.info.opt_mode = opt_type; + break; + + case 'Q': + //eMBMS_active=1; + // 0 : not used (default), 1: eMBMS and RRC enabled, 2: eMBMS relaying and RRC enabled, 3: eMBMS enabled, RRC disabled, 4: eMBMS relaying enabled, RRC disabled + oai_emulation.info.eMBMS_active_state = atoi (optarg); + break; + + case 'r': + rate_adaptation_flag = 1; + break; + + case 'R': + oai_emulation.info.N_RB_DL = atoi (optarg); + if ((oai_emulation.info.N_RB_DL != 6) && (oai_emulation.info.N_RB_DL != 15) && (oai_emulation.info.N_RB_DL != 25) + && (oai_emulation.info.N_RB_DL != 50) && (oai_emulation.info.N_RB_DL != 75) && (oai_emulation.info.N_RB_DL != 100)) { + printf("Illegal N_RB_DL %d (should be one of 6,15,25,50,75,100)\n", oai_emulation.info.N_RB_DL); + exit (-1); + } + break; + + case 's': + snr_dB = atoi (optarg); + // set_snr = 1; + oai_emulation.info.ocm_enabled=0; + break; + + case 'S': + sinr_dB = atoi (optarg); + set_sinr = 1; + oai_emulation.info.ocm_enabled=0; + break; + + case 't': + //Td = atof (optarg); + printf("[SIM] Option t is no longer supported on the command line. Please specify your channel model in the xml template\n"); + exit(-1); + break; + + case 'T': + oai_emulation.info.otg_enabled = 1; + oai_emulation.info.otg_traffic = optarg; + break; + + case 'u': + oai_emulation.info.nb_ue_local = atoi (optarg); + break; + + case 'U': + oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option = optarg; + break; + + case 'v': + oai_emulation.info.omv_enabled = 1; + break; + + case 'V': + ouput_vcd = 1; + oai_emulation.info.vcd_enabled = 1; + oai_emulation.info.vcd_file = optarg; + break; + + case 'w': + oai_emulation.info.cba_group_active = atoi (optarg); + break; + + case 'W': #ifdef SMBV - config_smbv = 1; - if(atoi(optarg)!=0) - strcpy(smbv_ip,optarg); + config_smbv = 1; + if(atoi(optarg)!=0) + strcpy(smbv_ip,optarg); #endif - break; + break; - case 'x': - oai_emulation.info.transmission_mode = atoi (optarg); - if ((oai_emulation.info.transmission_mode != 1) && (oai_emulation.info.transmission_mode != 2) && (oai_emulation.info.transmission_mode != 5) && (oai_emulation.info.transmission_mode != 6)) { - printf("Unsupported transmission mode %d\n",oai_emulation.info.transmission_mode); - exit(-1); - } - break; + case 'x': + oai_emulation.info.transmission_mode = atoi (optarg); + if ((oai_emulation.info.transmission_mode != 1) && (oai_emulation.info.transmission_mode != 2) && (oai_emulation.info.transmission_mode != 5) && (oai_emulation.info.transmission_mode != 6)) { + printf("Unsupported transmission mode %d\n",oai_emulation.info.transmission_mode); + exit(-1); + } + break; - case 'X': + case 'X': #ifdef PROC - temp=atoi(optarg); - if(temp==0){ - port=CHANNEL_PORT; Channel_Flag=1; Process_Flag=0; wgt=0; - } - else if(temp==1){ - port=eNB_PORT; wgt=0; - } - else { - port=UE_PORT; wgt=MAX_eNB; - } + temp=atoi(optarg); + if(temp==0){ + port=CHANNEL_PORT; Channel_Flag=1; Process_Flag=0; wgt=0; + } + else if(temp==1){ + port=eNB_PORT; wgt=0; + } + else { + port=UE_PORT; wgt=MAX_eNB; + } #endif - break; + break; - case 'y': - nb_antennas_rx=atoi(optarg); - if (nb_antennas_rx>4) { - printf("Cannot have more than 4 antennas\n"); - exit(-1); - } - break; + case 'y': + nb_antennas_rx=atoi(optarg); + if (nb_antennas_rx>4) { + printf("Cannot have more than 4 antennas\n"); + exit(-1); + } + break; - case 'Y': - oai_emulation.info.g_log_verbosity_option = strdup(optarg); - break; + case 'Y': + oai_emulation.info.g_log_verbosity_option = strdup(optarg); + break; - case 'z': - cooperation_flag = atoi (optarg); - break; + case 'z': + cooperation_flag = atoi (optarg); + break; - case 'Z': - /* Sebastien ROUX: Reserved for future use (currently used in ltenow branch) */ - break; + case 'Z': + /* Sebastien ROUX: Reserved for future use (currently used in ltenow branch) */ + break; - default: - help (); - exit (-1); - break; - } + default: + help (); + exit (-1); + break; + } } if ((oai_emulation.info.nb_enb_local > 0) && (conf_config_file_name != NULL)) - { + { /* Read eNB configuration file */ enb_properties = enb_config_init(conf_config_file_name); AssertFatal (oai_emulation.info.nb_enb_local <= enb_properties->number, - "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", - conf_config_file_name, oai_emulation.info.nb_enb_local, enb_properties->number); + "Number of eNB is greater than eNB defined in configuration file %s (%d/%d)!", + conf_config_file_name, oai_emulation.info.nb_enb_local, enb_properties->number); /* Update some simulation parameters */ oai_emulation.info.frame_type = enb_properties->properties[0]->frame_type; oai_emulation.info.tdd_config = enb_properties->properties[0]->tdd_config; oai_emulation.info.tdd_config_S = enb_properties->properties[0]->tdd_config_s; oai_emulation.info.extended_prefix_flag = enb_properties->properties[0]->prefix_type; - } + } } void check_and_adjust_params() { @@ -611,18 +618,18 @@ void check_and_adjust_params() { int i,j; if (oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local > NUMBER_OF_UE_MAX) { - LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX); - exit(EXIT_FAILURE); + LOG_E(EMU,"Enter fewer than %d UEs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_UE_MAX); + exit(EXIT_FAILURE); } if (oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local > NUMBER_OF_eNB_MAX) { - LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX); - exit(EXIT_FAILURE); + LOG_E(EMU,"Enter fewer than %d eNBs/RNs for the moment or change the NUMBER_OF_UE_MAX\n", NUMBER_OF_eNB_MAX); + exit(EXIT_FAILURE); } if (oai_emulation.info.nb_rn_local > NUMBER_OF_RN_MAX) { - LOG_E(EMU,"Enter fewer than %d RNs for the moment or change the NUMBER_OF_RN_MAX\n", NUMBER_OF_RN_MAX); - exit(EXIT_FAILURE); + LOG_E(EMU,"Enter fewer than %d RNs for the moment or change the NUMBER_OF_RN_MAX\n", NUMBER_OF_RN_MAX); + exit(EXIT_FAILURE); } // fix ethernet and abstraction with RRC_CELLULAR Flag #ifdef RRC_CELLULAR @@ -640,26 +647,26 @@ void check_and_adjust_params() { LOG_W(EMU,"[INIT] Netlink not available, careful ...\n"); if (ethernet_flag == 1) { - oai_emulation.info.master[oai_emulation.info.master_id].nb_ue = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local; - oai_emulation.info.master[oai_emulation.info.master_id].nb_enb = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local; - if (oai_emulation.info.nb_rn_local>0) - LOG_N(EMU,"Ethernet emulation is not yet tested with the relay nodes\n"); - if (!oai_emulation.info.master_id) - oai_emulation.info.is_primary_master = 1; - j = 1; - for (i = 0; i < oai_emulation.info.nb_master; i++) { - if (i != oai_emulation.info.master_id) - oai_emulation.info.master_list = oai_emulation.info.master_list + j; - LOG_I (EMU, "Index of master id i=%d MASTER_LIST %d\n", i, oai_emulation.info.master_list); - j *= 2; - } - LOG_I (EMU, " Total number of master %d my master id %d\n", oai_emulation.info.nb_master, oai_emulation.info.master_id); - init_bypass (); + oai_emulation.info.master[oai_emulation.info.master_id].nb_ue = oai_emulation.info.nb_ue_local + oai_emulation.info.nb_rn_local; + oai_emulation.info.master[oai_emulation.info.master_id].nb_enb = oai_emulation.info.nb_enb_local + oai_emulation.info.nb_rn_local; + if (oai_emulation.info.nb_rn_local>0) + LOG_N(EMU,"Ethernet emulation is not yet tested with the relay nodes\n"); + if (!oai_emulation.info.master_id) + oai_emulation.info.is_primary_master = 1; + j = 1; + for (i = 0; i < oai_emulation.info.nb_master; i++) { + if (i != oai_emulation.info.master_id) + oai_emulation.info.master_list = oai_emulation.info.master_list + j; + LOG_I (EMU, "Index of master id i=%d MASTER_LIST %d\n", i, oai_emulation.info.master_list); + j *= 2; + } + LOG_I (EMU, " Total number of master %d my master id %d\n", oai_emulation.info.nb_master, oai_emulation.info.master_id); + init_bypass (); - while (emu_tx_status != SYNCED_TRANSPORT) { - LOG_I (EMU, " Waiting for EMU Transport to be synced\n"); - emu_transport_sync (); //emulation_tx_rx(); - } + while (emu_tx_status != SYNCED_TRANSPORT) { + LOG_I (EMU, " Waiting for EMU Transport to be synced\n"); + emu_transport_sync (); //emulation_tx_rx(); + } } // ethernet flag // @@ -672,23 +679,23 @@ void check_and_adjust_params() { #endif if (NB_RN_INST > 0 ) { - LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); + LOG_N(EMU,"Total number of RN %d (local %d, remote %d) mobility (the same as eNB) %s \n", NB_RN_INST,oai_emulation.info.nb_rn_local,oai_emulation.info.nb_rn_remote, oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); - LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", - NB_eNB_INST, NB_eNB_INST+NB_RN_INST, - NB_UE_INST, NB_UE_INST+NB_RN_INST); - NB_eNB_INST+=NB_RN_INST; - NB_UE_INST+=NB_RN_INST; + LOG_N(EMU,"Adjust the number of eNB inst (%d->%d) and UE inst (%d->%d)\n ", + NB_eNB_INST, NB_eNB_INST+NB_RN_INST, + NB_UE_INST, NB_UE_INST+NB_RN_INST); + NB_eNB_INST+=NB_RN_INST; + NB_UE_INST+=NB_RN_INST; } LOG_I(EMU,"Total number of UE %d (first local %d , num local %d, remote %d, relay %d) mobility %s \n", - NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option); + NB_UE_INST,oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local,oai_emulation.info.nb_ue_remote, + NB_RN_INST, + oai_emulation.topology_config.mobility.UE_mobility.UE_mobility_type.selected_option); LOG_I(EMU,"Total number of eNB %d (local %d, remote %d, relay %d) mobility %s \n", - NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, - NB_RN_INST, - oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); + NB_eNB_INST,oai_emulation.info.nb_enb_local,oai_emulation.info.nb_enb_remote, + NB_RN_INST, + oai_emulation.topology_config.mobility.eNB_mobility.eNB_mobility_type.selected_option); } @@ -696,36 +703,36 @@ void check_and_adjust_params() { void init_omv() { if (oai_emulation.info.omv_enabled == 1) { - if(pipe(pfd) == -1) - perror("pipe error \n"); + if(pipe(pfd) == -1) + perror("pipe error \n"); - sprintf(full_name, "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR")); - LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]); + sprintf(full_name, "%s/UTIL/OMV/OMV",getenv("OPENAIR2_DIR")); + LOG_I(EMU,"Stating the OMV path %s pfd[0] %d pfd[1] %d \n", full_name, pfd[0],pfd[1]); - switch(fork()) { - case -1 : - perror("fork failed \n"); - break; + switch(fork()) { + case -1 : + perror("fork failed \n"); + break; case 0 : // child is going to be the omv, it is the reader - if(close(pfd[1]) == -1 ) // we close the write desc. - perror("close on write\n" ); - sprintf(fdstr, "%d", pfd[0] ); - sprintf(num_enb, "%d", NB_eNB_INST); - sprintf(num_ue, "%d", NB_UE_INST); - sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m ); - sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m ); - sprintf(z_area, "%f", 200.0 ); - sprintf(frames, "%d", oai_emulation.info.n_frames); - sprintf(nb_antenna, "%d", 4); - sprintf(frame_type, "%s", (oai_emulation.info.frame_type == 0) ? "FDD" : "TDD"); - sprintf(tdd_config, "%d", oai_emulation.info.tdd_config); -// execl is used to launch the visualisor - execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL ); - perror( "error in execl the OMV" ); - } - //parent -if(close( pfd[0] ) == -1 ) // we close the write desc. - perror("close on read\n" ); + if(close(pfd[1]) == -1 ) // we close the write desc. + perror("close on write\n" ); + sprintf(fdstr, "%d", pfd[0] ); + sprintf(num_enb, "%d", NB_eNB_INST); + sprintf(num_ue, "%d", NB_UE_INST); + sprintf(x_area, "%f", oai_emulation.topology_config.area.x_m ); + sprintf(y_area, "%f", oai_emulation.topology_config.area.y_m ); + sprintf(z_area, "%f", 200.0 ); + sprintf(frames, "%d", oai_emulation.info.n_frames); + sprintf(nb_antenna, "%d", 4); + sprintf(frame_type, "%s", (oai_emulation.info.frame_type == 0) ? "FDD" : "TDD"); + sprintf(tdd_config, "%d", oai_emulation.info.tdd_config); + // execl is used to launch the visualisor + execl(full_name,"OMV", fdstr, frames, num_enb, num_ue, x_area, y_area, z_area, nb_antenna, frame_type, tdd_config,NULL ); + perror( "error in execl the OMV" ); + } + //parent + if(close( pfd[0] ) == -1 ) // we close the write desc. + perror("close on read\n" ); } } #endif @@ -734,12 +741,12 @@ void init_seed(u8 set_seed) { if(set_seed) { - randominit (oai_emulation.info.seed); - set_taus_seed (oai_emulation.info.seed); + randominit (oai_emulation.info.seed); + set_taus_seed (oai_emulation.info.seed); } else { - randominit (0); - set_taus_seed (0); + randominit (0); + set_taus_seed (0); } } @@ -767,8 +774,8 @@ void init_openair1() { printf ("AFTER init: Nid_cell %d\n", PHY_vars_eNB_g[0]->lte_frame_parms.Nid_cell); printf ("AFTER init: frame_type %d,tdd_config %d\n", - PHY_vars_eNB_g[0]->lte_frame_parms.frame_type, - PHY_vars_eNB_g[0]->lte_frame_parms.tdd_config); + PHY_vars_eNB_g[0]->lte_frame_parms.frame_type, + PHY_vars_eNB_g[0]->lte_frame_parms.tdd_config); number_of_cards = 1; @@ -787,26 +794,26 @@ void init_openair1() { // init_ue_status(); for (UE_id=0; UE_id<NB_UE_INST;UE_id++) { - PHY_vars_UE_g[UE_id]->rx_total_gain_dB=130; - // update UE_mode for each eNB_id not just 0 - if (abstraction_flag == 0) - PHY_vars_UE_g[UE_id]->UE_mode[0] = NOT_SYNCHED; - else { - // 0 is the index of the connected eNB - PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH; - } - PHY_vars_UE_g[UE_id]->lte_ue_pdcch_vars[0]->crnti = 0x1235 + UE_id; - PHY_vars_UE_g[UE_id]->current_dlsch_cqi[0] = 10; + PHY_vars_UE_g[UE_id]->rx_total_gain_dB=130; + // update UE_mode for each eNB_id not just 0 + if (abstraction_flag == 0) + PHY_vars_UE_g[UE_id]->UE_mode[0] = NOT_SYNCHED; + else { + // 0 is the index of the connected eNB + PHY_vars_UE_g[UE_id]->UE_mode[0] = PRACH; + } + PHY_vars_UE_g[UE_id]->lte_ue_pdcch_vars[0]->crnti = 0x1235 + UE_id; + PHY_vars_UE_g[UE_id]->current_dlsch_cqi[0] = 10; - LOG_I(EMU, "UE %d mode is initialized to %d\n", UE_id, PHY_vars_UE_g[UE_id]->UE_mode[0] ); + LOG_I(EMU, "UE %d mode is initialized to %d\n", UE_id, PHY_vars_UE_g[UE_id]->UE_mode[0] ); #if defined(ENABLE_RAL) - PHY_vars_UE_g[UE_id]->ral_thresholds_timed = hashtable_create (64, NULL, NULL); - for (list_index = 0; list_index < RAL_LINK_PARAM_GEN_MAX; list_index++) { - SLIST_INIT(&PHY_vars_UE_g[UE_id]->ral_thresholds_gen_polled[list_index]); - } - for (list_index = 0; list_index < RAL_LINK_PARAM_LTE_MAX; list_index++) { - SLIST_INIT(&PHY_vars_UE_g[UE_id]->ral_thresholds_lte_polled[list_index]); - } + PHY_vars_UE_g[UE_id]->ral_thresholds_timed = hashtable_create (64, NULL, NULL); + for (list_index = 0; list_index < RAL_LINK_PARAM_GEN_MAX; list_index++) { + SLIST_INIT(&PHY_vars_UE_g[UE_id]->ral_thresholds_gen_polled[list_index]); + } + for (list_index = 0; list_index < RAL_LINK_PARAM_LTE_MAX; list_index++) { + SLIST_INIT(&PHY_vars_UE_g[UE_id]->ral_thresholds_lte_polled[list_index]); + } #endif } @@ -818,16 +825,16 @@ void init_openair2() { s32 UE_id; l2_init (&PHY_vars_eNB_g[0]->lte_frame_parms, - oai_emulation.info.eMBMS_active_state, - oai_emulation.info.cba_group_active, - oai_emulation.info.handover_active); + oai_emulation.info.eMBMS_active_state, + oai_emulation.info.cba_group_active, + oai_emulation.info.handover_active); - for (i = 0; i < NB_eNB_INST; i++) + for (i = 0; i < NB_eNB_INST; i++) mac_xface->mrbch_phy_sync_failure (i, 0, i); if (abstraction_flag == 1) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) - mac_xface->dl_phy_sync_success (UE_id, 0, 0,1); //UE_id%NB_eNB_INST); + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) + mac_xface->dl_phy_sync_success (UE_id, 0, 0,1); //UE_id%NB_eNB_INST); } mac_xface->macphy_exit = exit_fun; @@ -840,36 +847,36 @@ void init_ocm() { /* Added for PHY abstraction */ LOG_I(OCM,"Running with frame_type %d, Nid_cell %d, N_RB_DL %d, EP %d, mode %d, target dl_mcs %d, rate adaptation %d, nframes %d, abstraction %d, channel %s\n", oai_emulation.info.frame_type, Nid_cell, oai_emulation.info.N_RB_DL, oai_emulation.info.extended_prefix_flag, oai_emulation.info.transmission_mode,target_dl_mcs,rate_adaptation_flag,oai_emulation.info.n_frames,abstraction_flag,oai_emulation.environment_system_config.fading.small_scale.selected_option); - if (abstraction_flag) { + if (abstraction_flag) { - get_beta_map(); + get_beta_map(); #ifdef PHY_ABSTRACTION_UL - get_beta_map_up(); + get_beta_map_up(); #endif - get_MIESM_param(); + get_MIESM_param(); } for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - enb_data[eNB_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_enb(enb_data[eNB_id],oai_emulation.environment_system_config.antenna.eNB_antenna); + enb_data[eNB_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); + init_enb(enb_data[eNB_id],oai_emulation.environment_system_config.antenna.eNB_antenna); } for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); - init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna); + ue_data[UE_id] = (node_desc_t *)malloc(sizeof(node_desc_t)); + init_ue(ue_data[UE_id],oai_emulation.environment_system_config.antenna.UE_antenna); } if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 ) && (oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m>0) && (oai_emulation.environment_system_config.fading.shadowing.variance_dB>0)) { - // init SF map here!!! - map1 =(int)oai_emulation.topology_config.area.x_m; - map2 =(int)oai_emulation.topology_config.area.y_m; - ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB); + // init SF map here!!! + map1 =(int)oai_emulation.topology_config.area.x_m; + map2 =(int)oai_emulation.topology_config.area.y_m; + ShaF = init_SF(map1,map2,oai_emulation.environment_system_config.fading.shadowing.decorrelation_distance_m,oai_emulation.environment_system_config.fading.shadowing.variance_dB); - // size of area to generate shadow fading map - LOG_D(EMU,"Simulation area x=%f, y=%f\n", + // size of area to generate shadow fading map + LOG_D(EMU,"Simulation area x=%f, y=%f\n", oai_emulation.topology_config.area.x_m, oai_emulation.topology_config.area.y_m); } @@ -879,12 +886,12 @@ void init_ocm() { // initialize channel descriptors for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - LOG_D(OCM,"Initializing channel (%s, %d) from eNB %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, - map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), eNB_id, UE_id); + LOG_D(OCM,"Initializing channel (%s, %d) from eNB %d to UE %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, + map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), eNB_id, UE_id); - /* if (oai_emulation.info.transmission_mode == 5) + /* if (oai_emulation.info.transmission_mode == 5) eNB2UE[eNB_id][UE_id] = new_channel_desc_scm(PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_tx, PHY_vars_UE_g[UE_id]->lte_frame_parms.nb_antennas_rx, (UE_id == 0)? Rice1_corr : Rice1_anticorr, @@ -894,29 +901,29 @@ void init_ocm() { 0); else - */ - - eNB2UE[eNB_id][UE_id] = new_channel_desc_scm(PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_tx, - PHY_vars_UE_g[UE_id]->lte_frame_parms.nb_antennas_rx, - map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), - oai_emulation.environment_system_config.system_bandwidth_MB, - forgetting_factor, - 0, - 0); - random_channel(eNB2UE[eNB_id][UE_id]); - LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to eNB %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, - map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, eNB_id); - - UE2eNB[UE_id][eNB_id] = new_channel_desc_scm(PHY_vars_UE_g[UE_id]->lte_frame_parms.nb_antennas_tx, - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_rx, - map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option), - oai_emulation.environment_system_config.system_bandwidth_MB, - forgetting_factor, - 0, - 0); - - random_channel(UE2eNB[UE_id][eNB_id]); - } + */ + + eNB2UE[eNB_id][UE_id] = new_channel_desc_scm(PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_tx, + PHY_vars_UE_g[UE_id]->lte_frame_parms.nb_antennas_rx, + map_str_to_int(small_scale_names,oai_emulation.environment_system_config.fading.small_scale.selected_option), + oai_emulation.environment_system_config.system_bandwidth_MB, + forgetting_factor, + 0, + 0); + random_channel(eNB2UE[eNB_id][UE_id]); + LOG_D(OCM,"[SIM] Initializing channel (%s, %d) from UE %d to eNB %d\n", oai_emulation.environment_system_config.fading.small_scale.selected_option, + map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option),UE_id, eNB_id); + + UE2eNB[UE_id][eNB_id] = new_channel_desc_scm(PHY_vars_UE_g[UE_id]->lte_frame_parms.nb_antennas_tx, + PHY_vars_eNB_g[eNB_id]->lte_frame_parms.nb_antennas_rx, + map_str_to_int(small_scale_names, oai_emulation.environment_system_config.fading.small_scale.selected_option), + oai_emulation.environment_system_config.system_bandwidth_MB, + forgetting_factor, + 0, + 0); + + random_channel(UE2eNB[UE_id][eNB_id]); + } } // Not needed anymore, done automatically in init_freq_channel upon first call to the function @@ -931,8 +938,8 @@ void init_otg_pdcp_buffer() { otg_pdcp_buffer = malloc((NB_UE_INST + NB_eNB_INST) * sizeof(Packet_OTG_List)); for (i = 0; i < NB_UE_INST + NB_eNB_INST; i++) { - pkt_list_init(&(otg_pdcp_buffer[i])); - //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i]))); + pkt_list_init(&(otg_pdcp_buffer[i])); + //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", i, pkt_list_get_head(&(otg_pdcp_buffer[i]))); } } @@ -941,26 +948,26 @@ void update_omg () { int new_omg_model; if ((frame % omg_period) == 0 ) { // call OMG every 10ms - update_nodes(oai_emulation.info.time_s); - display_node_list(enb_node_list); - display_node_list(ue_node_list); - if (oai_emulation.info.omg_model_ue >= MAX_NUM_MOB_TYPES){ // mix mobility model - for(UE_id=oai_emulation.info.first_ue_local; UE_id<(oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local);UE_id++){ - new_omg_model = randomGen(STATIC,RWALK); - LOG_D(OMG, "[UE] Node of ID %d is changing mobility generator ->%d \n", UE_id, new_omg_model); - // reset the mobility model for a specific node - set_new_mob_type (UE_id, UE, new_omg_model, oai_emulation.info.time_s); + update_nodes(oai_emulation.info.time_s); + display_node_list(enb_node_list); + display_node_list(ue_node_list); + if (oai_emulation.info.omg_model_ue >= MAX_NUM_MOB_TYPES){ // mix mobility model + for(UE_id=oai_emulation.info.first_ue_local; UE_id<(oai_emulation.info.first_ue_local+oai_emulation.info.nb_ue_local);UE_id++){ + new_omg_model = randomGen(STATIC,RWALK); + LOG_D(OMG, "[UE] Node of ID %d is changing mobility generator ->%d \n", UE_id, new_omg_model); + // reset the mobility model for a specific node + set_new_mob_type (UE_id, UE, new_omg_model, oai_emulation.info.time_s); + } } - } - if (oai_emulation.info.omg_model_enb >= MAX_NUM_MOB_TYPES) { // mix mobility model - for (eNB_id = oai_emulation.info.first_enb_local; eNB_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); eNB_id++) { - new_omg_model = randomGen (STATIC, RWALK); - LOG_D (OMG,"[eNB] Node of ID %d is changing mobility generator ->%d \n", eNB_id, new_omg_model); - // reset the mobility model for a specific node - set_new_mob_type (eNB_id, eNB, new_omg_model, oai_emulation.info.time_s); + if (oai_emulation.info.omg_model_enb >= MAX_NUM_MOB_TYPES) { // mix mobility model + for (eNB_id = oai_emulation.info.first_enb_local; eNB_id < (oai_emulation.info.first_enb_local + oai_emulation.info.nb_enb_local); eNB_id++) { + new_omg_model = randomGen (STATIC, RWALK); + LOG_D (OMG,"[eNB] Node of ID %d is changing mobility generator ->%d \n", eNB_id, new_omg_model); + // reset the mobility model for a specific node + set_new_mob_type (eNB_id, eNB, new_omg_model, oai_emulation.info.time_s); + } } - } } } @@ -978,125 +985,124 @@ void update_ocm() { /* check if the openair channel model is activated used for PHY abstraction : path loss*/ if ((oai_emulation.info.ocm_enabled == 1)&& (ethernet_flag == 0 )) { - //LOG_D(OMG," extracting position of eNb...\n"); - extract_position(enb_node_list, enb_data, NB_eNB_INST); - //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame); - //LOG_D(OMG," extracting position of UE...\n"); - // if (oai_emulation.info.omg_model_ue == TRACE) - extract_position(ue_node_list, ue_data, NB_UE_INST); - - /* if (frame % 50 == 0) + //LOG_D(OMG," extracting position of eNb...\n"); + extract_position(enb_node_list, enb_data, NB_eNB_INST); + //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame); + //LOG_D(OMG," extracting position of UE...\n"); + // if (oai_emulation.info.omg_model_ue == TRACE) + extract_position(ue_node_list, ue_data, NB_UE_INST); + + /* if (frame % 50 == 0) LOG_N(OCM,"Path loss for TTI %d : \n", frame); - */ - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,ShaF); - //calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,0); - UE2eNB[UE_id][eNB_id]->path_loss_dB = eNB2UE[eNB_id][UE_id]->path_loss_dB; - // if (frame % 50 == 0) - LOG_I(OCM,"Path loss between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", - eNB_id,enb_data[eNB_id]->x,enb_data[eNB_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y, - eNB2UE[eNB_id][UE_id]->path_loss_dB, eNB2UE[eNB_id][UE_id]->aoa); + */ + for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,ShaF); + //calc_path_loss (enb_data[eNB_id], ue_data[UE_id], eNB2UE[eNB_id][UE_id], oai_emulation.environment_system_config,0); + UE2eNB[UE_id][eNB_id]->path_loss_dB = eNB2UE[eNB_id][UE_id]->path_loss_dB; + // if (frame % 50 == 0) + LOG_I(OCM,"Path loss between eNB %d at (%f,%f) and UE %d at (%f,%f) is %f, angle %f\n", + eNB_id,enb_data[eNB_id]->x,enb_data[eNB_id]->y,UE_id,ue_data[UE_id]->x,ue_data[UE_id]->y, + eNB2UE[eNB_id][UE_id]->path_loss_dB, eNB2UE[eNB_id][UE_id]->aoa); + } } - } } else { - for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { - for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { - - //UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + snr_dB; - if (eNB_id == (UE_id % NB_eNB_INST)) { - eNB2UE[eNB_id][UE_id]->path_loss_dB = -105 + snr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; - UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + snr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; //+20 to offset the difference in tx power of the UE wrt eNB - } - else { - eNB2UE[eNB_id][UE_id]->path_loss_dB = -105 + sinr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; - UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + sinr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; - } - LOG_I(OCM,"Path loss from eNB %d to UE %d => %f dB (eNB TX %d)\n",eNB_id,UE_id,eNB2UE[eNB_id][UE_id]->path_loss_dB, - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower); - // printf("[SIM] Path loss from UE %d to eNB %d => %f dB\n",UE_id,eNB_id,UE2eNB[UE_id][eNB_id]->path_loss_dB); + for (eNB_id = 0; eNB_id < NB_eNB_INST; eNB_id++) { + for (UE_id = 0; UE_id < NB_UE_INST; UE_id++) { + + //UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + snr_dB; + if (eNB_id == (UE_id % NB_eNB_INST)) { + eNB2UE[eNB_id][UE_id]->path_loss_dB = -105 + snr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; + UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + snr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; //+20 to offset the difference in tx power of the UE wrt eNB + } + else { + eNB2UE[eNB_id][UE_id]->path_loss_dB = -105 + sinr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; + UE2eNB[UE_id][eNB_id]->path_loss_dB = -105 + sinr_dB - PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower; + } + LOG_I(OCM,"Path loss from eNB %d to UE %d => %f dB (eNB TX %d)\n",eNB_id,UE_id,eNB2UE[eNB_id][UE_id]->path_loss_dB, + PHY_vars_eNB_g[eNB_id]->lte_frame_parms.pdsch_config_common.referenceSignalPower); + // printf("[SIM] Path loss from UE %d to eNB %d => %f dB\n",UE_id,eNB_id,UE2eNB[UE_id][eNB_id]->path_loss_dB); + } } - } } } #ifdef OPENAIR2 -void update_otg_eNB(int module_id, unsigned int ctime) { +void update_otg_eNB(module_id_t module_instP, unsigned int ctime) { #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled ==1 ) { - int dst_id, app_id; - Packet_otg_elt *otg_pkt; - - - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { - for_times += 1; - // generate traffic if the ue is rrc reconfigured state - if (mac_get_rrc_status(module_id, 1/*eNB_flag*/, dst_id) > 2 /*RRC_CONNECTED*/ ) { - - for (app_id=0; app_id<MAX_NUM_APPLICATION; app_id++){ - otg_pkt = malloc (sizeof(Packet_otg_elt)); - if_times += 1; - - (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(module_id, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - otg_times += 1; - (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; // app could be binded to a given DRB - (otg_pkt->otg_pkt).module_id = module_id; - (otg_pkt->otg_pkt).dst_id = dst_id; - (otg_pkt->otg_pkt).is_ue = 0; - (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; - //Adding the packet to the OTG-PDCP buffer - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); - LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n", - (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id); - } else { - //LOG_I(EMU, "OTG returns null \n"); - free(otg_pkt); - otg_pkt=NULL; - } - } - //LOG_T(EMU,"[eNB %d] UE mod id %d is not connected\n", module_id, dst_id); - //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id]))); - + int dst_id, app_id; + Packet_otg_elt *otg_pkt; + + for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + for_times += 1; + // generate traffic if the ue is rrc reconfigured state + if (mac_get_rrc_status(module_instP, 1/*eNB_flag*/, dst_id) > 2 /*RRC_CONNECTED*/ ) { + + for (app_id=0; app_id<MAX_NUM_APPLICATION; app_id++){ + otg_pkt = malloc (sizeof(Packet_otg_elt)); + if_times += 1; + + (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(module_instP, dst_id + NB_eNB_INST, app_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); + + if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { + otg_times += 1; + (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; // app could be binded to a given DRB + (otg_pkt->otg_pkt).module_id = module_instP; + (otg_pkt->otg_pkt).dst_id = dst_id; + (otg_pkt->otg_pkt).is_ue = 0; + (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; + //Adding the packet to the OTG-PDCP buffer + pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP])); + LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d for app id %d \n", + (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id, app_id); + } else { + //LOG_I(EMU, "OTG returns null \n"); + free(otg_pkt); + otg_pkt=NULL; + } + } + //LOG_T(EMU,"[eNB %d] UE mod id %d is not connected\n", module_id, dst_id); + //LOG_I(EMU,"HEAD of otg_pdcp_buffer[%d] is %p\n", module_id, pkt_list_get_head(&(otg_pdcp_buffer[module_id]))); + + } } - } #ifdef Rel10 - int service_id, session_id, rb_id; - // MBSM multicast traffic - // if (frame >= 50) {// only generate when UE can receive MTCH (need to control this value) + int service_id, session_id, rb_id; + // MBSM multicast traffic + // if (frame >= 50) {// only generate when UE can receive MTCH (need to control this value) for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount - for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH - // LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance); - if (pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance == module_id + 1){ // this service/session is configured - - otg_pkt = malloc (sizeof(Packet_otg_elt)); - // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n", service_id, session_id, service_id*maxSessionPerPMCH + session_id); - rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id; - (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen_multicast(module_id, session_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - (otg_pkt->otg_pkt).rb_id = rb_id; - (otg_pkt->otg_pkt).module_id = module_id; - (otg_pkt->otg_pkt).dst_id = session_id; - (otg_pkt->otg_pkt).is_ue = 0; - //Adding the packet to the OTG-PDCP buffer - (otg_pkt->otg_pkt).mode = PDCP_TM; - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); - LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n", - (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - //LOG_I(EMU, "OTG returns null \n"); - free(otg_pkt); - otg_pkt=NULL; - } - - - // old version - /* // MBSM multicast traffic + for (session_id = 0; session_id < 2; session_id++) { // maxSessionPerPMCH + // LOG_I(OTG,"DUY:frame %d, pdcp_mbms_array[module_id][rb_id].instanciated_instance is %d\n",frame,pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].instanciated_instance); + if (pdcp_mbms_array[module_instP][service_id*maxSessionPerPMCH + session_id].instanciated_instance == module_instP + 1){ // this service/session is configured + + otg_pkt = malloc (sizeof(Packet_otg_elt)); + // LOG_T(OTG,"multicast packet gen for (service/mch %d, session/lcid %d, rb_id %d)\n", service_id, session_id, service_id*maxSessionPerPMCH + session_id); + rb_id = pdcp_mbms_array[module_id][service_id*maxSessionPerPMCH + session_id].rb_id; + (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen_multicast(module_instP, session_id, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); + if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { + (otg_pkt->otg_pkt).rb_id = rb_id; + (otg_pkt->otg_pkt).module_id = module_id; + (otg_pkt->otg_pkt).dst_id = session_id; + (otg_pkt->otg_pkt).is_ue = 0; + //Adding the packet to the OTG-PDCP buffer + (otg_pkt->otg_pkt).mode = PDCP_TM; + pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP])); + LOG_I(EMU, "[eNB %d] ADD packet (%p) multicast to OTG buffer for dst %d on rb_id %d\n", + (otg_pkt->otg_pkt).module_id, otg_pkt, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); + } else { + //LOG_I(EMU, "OTG returns null \n"); + free(otg_pkt); + otg_pkt=NULL; + } + + + // old version + /* // MBSM multicast traffic #ifdef Rel10 if (frame >= 46) {// only generate when UE can receive MTCH (need to control this value) for (service_id = 0; service_id < 2 ; service_id++) { //maxServiceCount @@ -1119,88 +1125,88 @@ void update_otg_eNB(int module_id, unsigned int ctime) { } } // end multicast traffic #endif - */ + */ - } - } + } + } } // } // end multicast traffic #endif - //LOG_I(EMU, "[eNB %d] update OTG nb_elts = %d \n", module_id, otg_pdcp_buffer[module_id].nb_elements); + //LOG_I(EMU, "[eNB %d] update OTG nb_elts = %d \n", module_id, otg_pdcp_buffer[module_id].nb_elements); - //free(otg_pkt); - //otg_pkt = NULL; + //free(otg_pkt); + //otg_pkt = NULL; } #else if (otg_enabled==1) { - ctime = frame * 100; - for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { - if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { - otg_pkt = malloc (sizeof(Packet_otg_elt)); - (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_id, dst_id, ctime, &pkt_size); - if (otg_pkt != NULL) { - rb_id = dst_id * NB_RB_MAX + DTCH; - (otg_pkt->otg_pkt).rb_id = rb_id; - (otg_pkt->otg_pkt).module_id = module_id; - (otg_pkt->otg_pkt).is_ue = 0; - (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; - //Adding the packet to the OTG-PDCP buffer - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); - LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - //LOG_I(EMU, "OTG returns null \n"); - free(otg_pkt); - otg_pkt=NULL; - } - /*else { + ctime = frame * 100; + for (dst_id = 0; dst_id < NUMBER_OF_UE_MAX; dst_id++) { + if (mac_get_rrc_status(eNB_index, eNB_flag, dst_id ) > 2) { + otg_pkt = malloc (sizeof(Packet_otg_elt)); + (otg_pkt->otg_pkt).sdu_buffer = packet_gen(module_instP, dst_id, ctime, &pkt_size); + if (otg_pkt != NULL) { + rb_id = dst_id * NB_RB_MAX + DTCH; + (otg_pkt->otg_pkt).rb_id = rb_id; + (otg_pkt->otg_pkt).module_id = module_instP; + (otg_pkt->otg_pkt).is_ue = 0; + (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; + //Adding the packet to the OTG-PDCP buffer + pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_instP])); + LOG_I(EMU, "[eNB %d] ADD pkt to OTG buffer for dst %d on rb_id %d\n", (otg_pkt->otg_pkt).module_id, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); + } else { + //LOG_I(EMU, "OTG returns null \n"); + free(otg_pkt); + otg_pkt=NULL; + } + /*else { LOG_I(OTG,"nothing generated (src %d, dst %d)\n",src_id, dst_id); }*/ - } - /*else { + } + /*else { LOG_I(OTG,"rrc_status (src %d, dst %d) = %d\n",src_id, dst_id, mac_get_rrc_status(src_id, eNB_flag, dst_id )); }*/ - } + } } #endif } -void update_otg_UE(int UE_id, unsigned int ctime) { +void update_otg_UE(module_id_t ue_mod_idP, unsigned int ctime) { #if defined(USER_MODE) && defined(OAI_EMU) if (oai_emulation.info.otg_enabled ==1 ) { - int dst_id, src_id; //dst_id = eNB_index - int module_id = UE_id+NB_eNB_INST; - - src_id = module_id; - - for (dst_id=0;dst_id<NUMBER_OF_eNB_MAX;dst_id++) { - if (mac_get_rrc_status(UE_id, 0, dst_id ) > 2 /*RRC_CONNECTED*/) { - Packet_otg_elt *otg_pkt = malloc (sizeof(Packet_otg_elt)); - if (otg_pkt!=NULL) - memset(otg_pkt,0,sizeof(Packet_otg_elt)); - else { - LOG_E(OTG,"not enough memory\n"); - exit(-1); - }// Manage to add this packet to the tail of your list - (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(src_id, dst_id, 0, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); - - if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { - (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; - (otg_pkt->otg_pkt).module_id = module_id; - (otg_pkt->otg_pkt).dst_id = dst_id; - (otg_pkt->otg_pkt).is_ue = 1; - //Adding the packet to the OTG-PDCP buffer - (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; - pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); - LOG_I(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n", - (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); - } else { - free(otg_pkt); - otg_pkt=NULL; - } + module_id_t dst_id, src_id; //dst_id = eNB_index + module_id_t module_id = ue_mod_idP+NB_eNB_INST; + + src_id = module_id; + + for (dst_id=0;dst_id<NUMBER_OF_eNB_MAX;dst_id++) { + if (mac_get_rrc_status(ue_mod_idP, 0, dst_id ) > 2 /*RRC_CONNECTED*/) { + Packet_otg_elt *otg_pkt = malloc (sizeof(Packet_otg_elt)); + if (otg_pkt!=NULL) + memset(otg_pkt,0,sizeof(Packet_otg_elt)); + else { + LOG_E(OTG,"not enough memory\n"); + exit(-1); + }// Manage to add this packet to the tail of your list + (otg_pkt->otg_pkt).sdu_buffer = (u8*) packet_gen(src_id, dst_id, 0, ctime, &((otg_pkt->otg_pkt).sdu_buffer_size)); + + if ((otg_pkt->otg_pkt).sdu_buffer != NULL) { + (otg_pkt->otg_pkt).rb_id = dst_id * NB_RB_MAX + DTCH; + (otg_pkt->otg_pkt).module_id = module_id; + (otg_pkt->otg_pkt).dst_id = dst_id; + (otg_pkt->otg_pkt).is_ue = 1; + //Adding the packet to the OTG-PDCP buffer + (otg_pkt->otg_pkt).mode = PDCP_DATA_PDU; + pkt_list_add_tail_eurecom(otg_pkt, &(otg_pdcp_buffer[module_id])); + LOG_I(EMU, "[UE %d] ADD pkt to OTG buffer with size %d for dst %d on rb_id %d \n", + (otg_pkt->otg_pkt).module_id, otg_pkt->otg_pkt.sdu_buffer_size, (otg_pkt->otg_pkt).dst_id,(otg_pkt->otg_pkt).rb_id); + } else { + free(otg_pkt); + otg_pkt=NULL; + } + } } - } } #endif } @@ -1208,46 +1214,46 @@ void update_otg_UE(int UE_id, unsigned int ctime) { int init_slot_isr(void) { - if (oai_emulation.info.slot_isr) { - struct itimerspec its; + if (oai_emulation.info.slot_isr) { + struct itimerspec its; - int sfd; + int sfd; - sfd = timerfd_create(CLOCK_REALTIME, 0); - if (sfd == -1) { - LOG_E(EMU, "Failed in timerfd_create (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } + sfd = timerfd_create(CLOCK_REALTIME, 0); + if (sfd == -1) { + LOG_E(EMU, "Failed in timerfd_create (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } - /* Start the timer */ - its.it_value.tv_sec = 0; - its.it_value.tv_nsec = 500 * 1000; - its.it_interval.tv_sec = its.it_value.tv_sec; - its.it_interval.tv_nsec = its.it_value.tv_nsec; + /* Start the timer */ + its.it_value.tv_sec = 0; + its.it_value.tv_nsec = 500 * 1000; + its.it_interval.tv_sec = its.it_value.tv_sec; + its.it_interval.tv_nsec = its.it_value.tv_nsec; - if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) { - LOG_E(EMU, "Failed in timer_settime (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } + if (timerfd_settime(sfd, TFD_TIMER_ABSTIME, &its, NULL) == -1) { + LOG_E(EMU, "Failed in timer_settime (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } - oai_emulation.info.slot_sfd = sfd; - } - return 0; + oai_emulation.info.slot_sfd = sfd; + } + return 0; } void wait_for_slot_isr(void) { - uint64_t exp; - ssize_t res; + uint64_t exp; + ssize_t res; - if (oai_emulation.info.slot_sfd > 0) { - res = read(oai_emulation.info.slot_sfd, &exp, sizeof(exp)); + if (oai_emulation.info.slot_sfd > 0) { + res = read(oai_emulation.info.slot_sfd, &exp, sizeof(exp)); - if ((res < 0) || (res != sizeof(exp))) { - LOG_E(EMU, "Failed in read (%d:%s)\n", errno, strerror(errno)); - exit(EXIT_FAILURE); - } - } + if ((res < 0) || (res != sizeof(exp))) { + LOG_E(EMU, "Failed in read (%d:%s)\n", errno, strerror(errno)); + exit(EXIT_FAILURE); + } + } } void exit_fun(const char* s) @@ -1264,9 +1270,9 @@ void exit_fun(const char* s) void init_time() { clock_gettime (CLOCK_REALTIME, &time_spec); - time_now = (unsigned long) time_spec.tv_nsec; - td_avg = 0; + time_now = (unsigned long) time_spec.tv_nsec; + td_avg = 0; sleep_time_us = SLEEP_STEP_US; - td_avg = TARGET_SF_TIME_NS; + td_avg = TARGET_SF_TIME_NS; } diff --git a/targets/SIMU/USER/oaisim_functions.h b/targets/SIMU/USER/oaisim_functions.h index f12b64d59070e7753a0f9ed5cac37150f82ee5ac..42641d1c8c33d933530168b61aad68d2db283c24 100644 --- a/targets/SIMU/USER/oaisim_functions.h +++ b/targets/SIMU/USER/oaisim_functions.h @@ -30,9 +30,9 @@ void update_omg_ocm(); void update_ocm(); -void update_otg_eNB(int module_id, unsigned int ctime); +void update_otg_eNB(module_id_t module_idP, unsigned int ctime); -void update_otg_UE(int module_id, unsigned int ctime); +void update_otg_UE(module_id_t module_idP, unsigned int ctime); void exit_fun(const char* s);