Commit 3a156e01 authored by Matthieu Kanj's avatar Matthieu Kanj

code separation + renaming + creation of two new files:

openair2/RRC/LITE/rrc_eNB_UE_context_NB_IoT.c
openair2/RRC/LITE/rrc_eNB_UE_context_NB_IoT.h
parent 037eb931
......@@ -1151,6 +1151,7 @@ set(L2_SRC
${RRC_DIR}/rrc_eNB_NB_IoT.c
${RRC_DIR}/rrc_eNB_S1AP.c
${RRC_DIR}/rrc_eNB_UE_context.c
${RRC_DIR}/rrc_eNB_UE_context_NB_IoT.c
${RRC_DIR}/rrc_common.c
${RRC_DIR}/rrc_common_NB_IoT.c
${RRC_DIR}/L2_interface.c
......
......@@ -1071,7 +1071,7 @@ int8_t find_ue(uint16_t rnti, PHY_VARS_eNB *eNB)
uint8_t i;
for (i=0; i<NUMBER_OF_UE_MAX; i++) {
for (i=0; i<NUMBER_OF_UE_MAX_NB_IoT; i++) {
if ((eNB->dlsch[i]) &&
(eNB->dlsch[i][0]) &&
(eNB->dlsch[i][0]->rnti==rnti)) {
......
......@@ -66,6 +66,40 @@
/*!\brief Maximum number of logical chanels */
#define MAX_NUM_LCID_NB_IoT 11
/*!\brief UE ULSCH scheduling states*/
typedef enum {
S_UL_NONE_NB_IoT =0,
S_UL_WAITING_NB_IoT,
S_UL_SCHEDULED_NB_IoT,
S_UL_BUFFERED_NB_IoT,
S_UL_NUM_STATUS_NB_IoT
} UE_ULSCH_STATUS_NB_IoT;
/*!\brief UE DLSCH scheduling states*/
typedef enum {
S_DL_NONE_NB_IoT =0,
S_DL_WAITING_NB_IoT,
S_DL_SCHEDULED_NB_IoT,
S_DL_BUFFERED_NB_IoT,
S_DL_NUM_STATUS_NB_IoT
} UE_DLSCH_STATUS_NB_IoT;
/*! \brief temporary struct for ULSCH sched */
typedef struct {
rnti_t rnti;
uint16_t subframe;
uint16_t serving_num;
UE_ULSCH_STATUS_NB_IoT status;
} eNB_ULSCH_INFO_NB_IoT;
/*! \brief temp struct for DLSCH sched */
typedef struct {
rnti_t rnti;
uint16_t weight;
uint16_t subframe;
uint16_t serving_num;
UE_DLSCH_STATUS_NB_IoT status;
} eNB_DLSCH_INFO_NB_IoT;
/*! \brief Downlink SCH PDU Structure */
typedef struct {
int8_t payload[8][SCH_PAYLOAD_SIZE_MAX_NB_IoT];
......
......@@ -53,6 +53,8 @@
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "LAYER2/MAC/vars_NB_IoT.h" //////////////////// to comment during test
//#include "openair2/COMMON/platform_types.h"
//#include "LAYER2/MAC/pre_processor.c"
//#include "pdcp.h"
......@@ -139,12 +141,14 @@ printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
UE_list->UE_template[pCC_id][UE_id].bsr_info[LCGID3] = 0;*/
//UE_list->UE_template[pCC_id][UE_id].ul_SR = 0;
UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI;
UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE;
eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info[mod_idP][pCC_id][UE_id].status = S_UL_NONE;
eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_UL_NONE_NB_IoT;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_DL_NONE_NB_IoT;
//NB_mac_phy_remove_ue(mod_idP,rntiP);
......
......@@ -265,7 +265,7 @@ void rx_sdu_NB_IoT(const module_id_t enb_mod_idP,
// kill RA procedure
}
if (Is_rrc_nb_iot_registered == 1)
if (Is_rrc_registered_NB_IoT == 1)
//MP: send directly the information to the RRC in case of CCCH (SRB0)
mac_rrc_data_ind_eNB_NB_IoT(
......
......@@ -45,13 +45,13 @@
#include "PHY_INTERFACE/defs.h" // should be replaced by PHY_INTERFACE/defs_NB_IoT.h (create MAC_xface for NB_IoT)
//#include "RRC/LITE/defs_NB_IoT.h"
#ifdef NB_IOT
//#ifdef NB_IOT
#include "LAYER2/MAC/defs_NB_IoT.h"
//NB-IoT
extern IF_Module_t *if_inst;
extern eNB_MAC_INST_NB_IoT *eNB_mac_inst_NB_IoT;
#endif
//#endif
extern const uint32_t BSR_TABLE_NB_IoT[BSR_TABLE_SIZE_NB_IoT];
// //extern uint32_t EBSR_Level[63];
......@@ -73,8 +73,8 @@ extern const uint32_t BSR_TABLE_NB_IoT[BSR_TABLE_SIZE_NB_IoT];
// extern uint8_t Is_rrc_registered;
extern eNB_ULSCH_INFO eNB_ulsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8
extern eNB_DLSCH_INFO eNB_dlsch_info[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX]; // eNBxUE = 8x8
extern eNB_ULSCH_INFO_NB_IoT eNB_ulsch_info_NB_IoT[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT]; // eNBxUE = 8x8
extern eNB_DLSCH_INFO_NB_IoT eNB_dlsch_info_NB_IoT[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT]; // eNBxUE = 8x8
......@@ -132,7 +132,7 @@ extern EMULATION_VARS *Emul_vars;
//NB-IoT---------------------------------
extern eNB_MAC_INST_NB_IoT *eNB_mac_inst_NB_IoT;
extern uint8_t Is_rrc_nb_iot_registered;
extern uint8_t Is_rrc_registered_NB_IoT;
......
......@@ -30,10 +30,10 @@
*/
#include "asn1_constants.h"
#include "defs_NB_IoT.h"
#include "proto_NB_IoT.h"
//#include "extern.h"
//#include "asn1_constants.h"
#include "LAYER2/MAC/defs_NB_IoT.h"
#include "LAYER2/MAC/proto_NB_IoT.h"
#include "LAYER2/MAC/extern_NB_IoT.h"
#include "RRC/LITE/proto_NB_IoT.h"
......@@ -134,7 +134,7 @@ int mac_top_init_NB_IoT()
}
if (Is_rrc_nb_iot_registered == 1) {
if (Is_rrc_registered_NB_IoT == 1) {
LOG_I(MAC,"[MAIN] calling RRC NB-IoT\n");
#ifndef CELLULAR //nothing to be done yet for cellular
openair_rrc_top_init_eNB_NB_IoT();
......@@ -198,9 +198,9 @@ int l2_init_eNB_NB_IoT()
LOG_I(MAC,"[MAIN] MAC_INIT_GLOBAL_PARAM NB-IoT IN...\n");
Is_rrc_nb_iot_registered=0;
Is_rrc_registered_NB_IoT=0;
mac_init_global_param_NB_IoT();
Is_rrc_nb_iot_registered=1;
Is_rrc_registered_NB_IoT=1;
LOG_D(MAC,"[MAIN][NB-IoT] ALL INIT OK\n");
......
......@@ -53,6 +53,9 @@ const uint32_t BSR_TABLE_NB_IoT[BSR_TABLE_SIZE_NB_IoT]= {0,10,12,14,17,19,22,26,
16507,19325,22624,26487,31009,36304,42502,49759,58255,68201,79846,93479,109439, 128125,150000, 300000
};
eNB_ULSCH_INFO_NB_IoT eNB_ulsch_info_NB_IoT[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT]; // eNBxUE = 8x8
eNB_DLSCH_INFO_NB_IoT eNB_dlsch_info_NB_IoT[NUMBER_OF_eNB_MAX][MAX_NUM_CCs][NUMBER_OF_UE_MAX_NB_IoT]; // eNBxUE = 8x8
#endif
......
......@@ -376,7 +376,7 @@ protected_pdcp_fifo(void pdcp_fifo_read_input_sdus_from_otg (
const protocol_ctxt_t* const ctxt_pP);)
//NB-IoT
public_pdcp(void pdcp_layer_init_NB(void);)
public_pdcp(void pdcp_layer_init_NB_IoT(void);)
......
......@@ -39,7 +39,7 @@
#include "LAYER2/MAC/extern.h"
#include "UTIL/LOG/log.h"
#include "UTIL/OCG/OCG_vars.h"
#include "rrc_eNB_UE_context.h"
#include "RRC/LITE/rrc_eNB_UE_context_NB_IoT.h"
#include "pdcp_primitives.h"
#include "pdcp.h"
#include "pdcp_util.h"
......@@ -83,7 +83,7 @@ typedef boolean_t mib_flag_t;
//XXX access of protected variables in pdcp.h
extern unsigned int pdcp_eNB_UE_instance_to_rnti_index;
extern rnti_t pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX];
extern rnti_t pdcp_eNB_UE_instance_to_rnti[NUMBER_OF_UE_MAX_NB_IoT];
extern list_t pdcp_sdu_list;
//extern struct mac_data_req rlc_am_mac_data_request (const protocol_ctxt_t* const ctxtP,void * const rlc_pP);
//extern eNB_MAC_INST_NB_IoT *eNB;
......@@ -147,18 +147,18 @@ typedef struct eutra_bandentry_NB_s {
uint32_t dl_min;
uint32_t dl_max;
uint32_t N_OFFs_DL;
} eutra_bandentry_NB_t;
} eutra_bandentry_NB_IoT_t;
typedef struct band_info_s {
int nbands;
eutra_bandentry_NB_t band_info[100];
eutra_bandentry_NB_IoT_t band_info[100];
} band_info_t;
//TS 36.101 Table 7.7.3-1 for the EARFCN values (Last column of the table Noff_DL = lowest defined EARFCN value for the corresponding band)
//TS 36.101 Table 5.5-1 for the Operating bands + 5.5F for the operating bands of category NB1 and NB2
//frequency are in 100KHz in order to consider all unsigned int
static const eutra_bandentry_NB_t eutra_bandtable[] = {
static const eutra_bandentry_NB_IoT_t eutra_bandtable[] = {
//[BAND] [FUL_low] [FUL_hi] [FDL_low] [FDL_hig] [NOFF_DL]
{ 1, 19200, 19800, 21100, 21700, 0},
{ 2, 18500, 19100, 19300, 19900, 6000},
......@@ -338,7 +338,7 @@ void config_mib_fapi_NB_IoT(
}
void config_sib2_NB_fapi(
void config_sib2_fapi_NB_IoT(
int physCellId,
RadioResourceConfigCommonSIB_NB_r13_t *radioResourceConfigCommon
)
......@@ -678,7 +678,7 @@ int rrc_mac_config_req_eNB_NB_IoT(
if (ul_CarrierFreq>0) eNB_mac_inst_NB_IoT[Mod_idP].common_channels[CC_idP].ul_CarrierFreq = ul_CarrierFreq;
config_sib2_NB_fapi(physCellId,radioResourceConfigCommon);
config_sib2_fapi_NB_IoT(physCellId,radioResourceConfigCommon);
}
......@@ -710,7 +710,7 @@ int rrc_mac_config_req_eNB_NB_IoT(
//XXX this parameters seems to be not defined by FAPi specs
//this are UE specific information that should be transmitted to the PHY layer
//use UE-specific structure at phy layer where to store this information (NPDCCH structure) this structure will be scrambled based on the rnti
config_INFO->rnti = UE_RNTI(Mod_idP, UE_id);
config_INFO->rnti = UE_RNTI_NB_IoT(Mod_idP, UE_id);
config_INFO->extra_phy_parms.npdcch_NumRepetitions = physicalConfigDedicated->npdcch_ConfigDedicated_r13->npdcch_NumRepetitions_r13; //Rmax
config_INFO->extra_phy_parms.npdcch_Offset_USS = physicalConfigDedicated->npdcch_ConfigDedicated_r13->npdcch_Offset_USS_r13;
config_INFO->extra_phy_parms.npdcch_StartSF_USS = physicalConfigDedicated->npdcch_ConfigDedicated_r13->npdcch_StartSF_USS_r13;
......@@ -748,7 +748,7 @@ uint32_t is_SIB1_NB_IoT(
{
uint8_t nb_rep=0; // number of sib1-nb repetitions within the 256 radio frames
uint32_t sib1_startFrame;
uint32_t sib1_NB_period = 256;//from specs TS 36.331 (rf)
uint32_t sib1_period_NB_IoT = 256;//from specs TS 36.331 (rf)
uint8_t index;
int offset;
int period_nb; // the number of the actual period over the 1024 frames
......@@ -787,7 +787,7 @@ uint32_t is_SIB1_NB_IoT(
//SIB1-NB period number
period_nb = (int) frameP/sib1_NB_period;
period_nb = (int) frameP/sib1_period_NB_IoT;
//number of repetitions
......@@ -824,7 +824,7 @@ uint32_t is_SIB1_NB_IoT(
//calculate offset between SIB1-NB repetitions (repetitions are equally spaced)
offset = (sib1_NB_period-(16*nb_rep))/nb_rep;
offset = (sib1_period_NB_IoT-(16*nb_rep))/nb_rep;
/*
* possible offset results (even numbers):
* nb_rep= 4 ---> offset = 48
......@@ -909,7 +909,7 @@ uint8_t is_SIB1_start_NB_IoT(
{
uint8_t nb_rep=0; // number of sib1-nb repetitions within the 256 radio frames
uint32_t sib1_startFrame;
// uint32_t sib1_NB_period = 256;//from specs TS 36.331 (rf)
// uint32_t sib1_period_NB_IoT = 256;//from specs TS 36.331 (rf)
// uint8_t index;
// int offset;
// int period_nb; // the number of the actual period over the 1024 frames
......@@ -1267,7 +1267,7 @@ int8_t mac_rrc_data_req_eNB_NB_IoT(
//defined in L2_interface
//called by rx_sdu only in case of CCCH message (e.g RRCConnectionRequest-NB - SRB0) --> is used for a direct communication between MAC and RRC
int8_t NB_mac_rrc_data_ind_eNB(
int8_t mac_rrc_data_ind_eNB_NB_IoT(
const module_id_t module_idP,
const int CC_id,
const frame_t frameP,
......@@ -1406,10 +1406,10 @@ printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
UE_list->UE_template[pCC_id][UE_id].rnti = NOT_A_RNTI;
UE_list->UE_template[pCC_id][UE_id].ul_active = FALSE;
eNB_ulsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info[mod_idP][pCC_id][UE_id].status = S_UL_NONE;
eNB_dlsch_info[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info[mod_idP][pCC_id][UE_id].status = S_DL_NONE;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_ulsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_UL_NONE;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].rnti = NOT_A_RNTI;
eNB_dlsch_info_NB_IoT[mod_idP][pCC_id][UE_id].status = S_DL_NONE;
mac_phy_remove_ue(mod_idP,rntiP); //PHY/defs.h
......@@ -1480,11 +1480,11 @@ int mac_eNB_get_rrc_status_NB_IoT(
//defined in pdcp_security.c
static
uint32_t pdcp_get_next_count_tx_NB(pdcp_t *const pdcp_pP, const srb_flag_t srb_flagP, const uint16_t pdcp_sn);
uint32_t pdcp_get_next_count_tx_NB_IoT(pdcp_t *const pdcp_pP, const srb_flag_t srb_flagP, const uint16_t pdcp_sn);
//-----------------------------------------------------------------------------
static
uint32_t pdcp_get_next_count_tx_NB(
uint32_t pdcp_get_next_count_tx_NB_IoT(
pdcp_t * const pdcp_pP,
const srb_flag_t srb_flagP,
const uint16_t pdcp_sn
......@@ -1533,7 +1533,7 @@ int pdcp_apply_security_NB_IoT(
encrypt_params.direction = (pdcp_pP->is_ue == 1) ? SECU_DIRECTION_UPLINK : SECU_DIRECTION_DOWNLINK;
encrypt_params.bearer = rb_id - 1;
encrypt_params.count = pdcp_get_next_count_tx_NB(pdcp_pP, srb_flagP, current_sn); //XXX (warning) because static defined in pdcp_security.c
encrypt_params.count = pdcp_get_next_count_tx_NB_IoT(pdcp_pP, srb_flagP, current_sn); //XXX (warning) because static defined in pdcp_security.c
encrypt_params.key_length = 16;
if (srb_flagP) {
......
......@@ -155,8 +155,8 @@ uint8_t do_RRCConnectionSetup_NB_IoT(
uint8_t* const buffer, //carrier[CC_id].Srb0.Tx_buffer.Payload
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed but not deleted
SRB_ToAddModList_NB_r13_t** SRB_configList_NB, //in order to be configured--> stanno puntando alla SRB_configlist dell ue_context
struct PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB //in order to be configured--> stanno puntando alla physicalConfigDedicated dell ue_context
SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT, //in order to be configured--> stanno puntando alla SRB_configlist dell ue_context
struct PhysicalConfigDedicated_NB_r13** physicalConfigDedicated_NB_IoT //in order to be configured--> stanno puntando alla physicalConfigDedicated dell ue_context
);
......@@ -182,12 +182,12 @@ do_RRCConnectionReconfiguration_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
uint8_t *buffer,
uint8_t Transaction_id,
SRB_ToAddModList_NB_r13_t *SRB_list_NB,
DRB_ToAddModList_NB_r13_t *DRB_list_NB,
DRB_ToReleaseList_NB_r13_t *DRB_list2_NB,
SRB_ToAddModList_NB_r13_t *SRB_list_NB_IoT,
DRB_ToAddModList_NB_r13_t *DRB_list_NB_IoT,
DRB_ToReleaseList_NB_r13_t *DRB_list2_NB_IoT,
struct PhysicalConfigDedicated_NB_r13 *physicalConfigDedicated,
MAC_MainConfig_t *mac_MainConfig,
struct RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13* dedicatedInfoNASList_NB);
struct RRCConnectionReconfiguration_NB_r13_IEs__dedicatedInfoNASList_r13* dedicatedInfoNASList_NB_IoT);
/**
* E-UTRAN applies the procedure as follows: when only for NB-IoT SRB1 and SRB1bis is established
......@@ -279,7 +279,7 @@ uint8_t do_RRCConnectionReestablishment_NB_IoT(
uint8_t* const buffer,
const uint8_t Transaction_id,
const NB_IoT_DL_FRAME_PARMS* const frame_parms, //to be changed
SRB_ToAddModList_NB_r13_t** SRB_configList_NB
SRB_ToAddModList_NB_r13_t** SRB_configList_NB_IoT
);
/**
......
......@@ -197,10 +197,10 @@
/*I will change the name of the structure for compile purposes--> hope not to undo this process*/
typedef unsigned int uid_NB_IoT_t;
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE (((NUMBER_OF_UE_MAX/8)/sizeof(unsigned int)) + 1)
#define UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT (((NUMBER_OF_UE_MAX_NB_IoT/8)/sizeof(unsigned int)) + 1)
typedef struct uid_linear_allocator_NB_IoT_s {
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE];
unsigned int bitmap[UID_LINEAR_ALLOCATOR_BITMAP_SIZE_NB_IoT];
} uid_allocator_NB_IoT_t;
......@@ -369,7 +369,7 @@ typedef struct eNB_RRC_UE_NB_IoT_s {
DRB_ToAddModList_NB_r13_t* DRB_configList2[RRC_TRANSACTION_IDENTIFIER_NUMBER]; //for the configured DRBs of a xid
uint8_t DRB_active[2];//in LTE was 8 --> at most 2 for NB-IoT
struct PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB;
struct PhysicalConfigDedicated_NB_r13* physicalConfigDedicated_NB_IoT;
MAC_MainConfig_NB_r13_t* mac_MainConfig_NB;
//No SPS(semi-persistent scheduling) in NB-IoT
......
This diff is collapsed.
......@@ -190,161 +190,3 @@ void rrc_eNB_remove_ue_context(
}
//--------------------NB-IoT version----------------------------
//------------------------------------------------------------------------------
void
uid_linear_allocator_init_NB_IoT(
uid_allocator_NB_IoT_t* const uid_pP
)
//------------------------------------------------------------------------------
{
memset(uid_pP, 0, sizeof(uid_allocator_NB_IoT_t));
}
//------------------------------------------------------------------------------
uid_t
uid_linear_allocator_new_NB_IoT(
eNB_RRC_INST_NB_IoT* const rrc_instance_pP
)
//------------------------------------------------------------------------------
{
unsigned int i;
unsigned int bit_index = 1;
uid_t uid = 0;
uid_allocator_NB_IoT_t* uia_p = &rrc_instance_pP->uid_allocator;
for (i=0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) {
if (uia_p->bitmap[i] != UINT_MAX) {
bit_index = 1;
uid = 0;
while ((uia_p->bitmap[i] & bit_index) == bit_index) {
bit_index = bit_index << 1;
uid += 1;
}
uia_p->bitmap[i] |= bit_index;
return uid + (i*sizeof(unsigned int)*8);
}
}
return UINT_MAX;
}
//------------------------------------------------------------------------------
void
uid_linear_allocator_free_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
uid_t uidP
)
//------------------------------------------------------------------------------
{
unsigned int i = uidP/sizeof(unsigned int)/8;
unsigned int bit = uidP % (sizeof(unsigned int) * 8);
unsigned int value = ~(0x00000001 << bit);
if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) {
rrc_instance_pP->uid_allocator.bitmap[i] &= value;
}
}
int rrc_eNB_compare_ue_rnti_id_NB_IoT(
struct rrc_eNB_ue_context_NB_IoT_s* c1_pP, struct rrc_eNB_ue_context_NB_IoT_s* c2_pP)
//------------------------------------------------------------------------------
{
if (c1_pP->ue_id_rnti > c2_pP->ue_id_rnti) {
return 1;
}
if (c1_pP->ue_id_rnti < c2_pP->ue_id_rnti) {
return -1;
}
return 0;
}
/* Generate the tree management functions for NB-IoT structures */
RB_GENERATE(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s, entries,
rrc_eNB_compare_ue_rnti_id_NB_IoT);
//------------------------------------------------------------------------------
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_allocate_new_UE_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP
)
//------------------------------------------------------------------------------
{
struct rrc_eNB_ue_context_NB_IoT_s* new_p;
new_p = malloc(sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
if (new_p == NULL) {
LOG_E(RRC, "Cannot allocate new ue context\n");
return NULL;
}
memset(new_p, 0, sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
new_p->local_uid = uid_linear_allocator_new_NB_IoT(rrc_instance_pP);
return new_p;
}
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_get_ue_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
rnti_t rntiP)
//------------------------------------------------------------------------------
{
rrc_eNB_ue_context_NB_IoT_t temp;
memset(&temp, 0, sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
/* eNB ue rrc id = 24 bits wide */
temp.ue_id_rnti = rntiP;
return RB_FIND(rrc_ue_tree_NB_IoT_s, &rrc_instance_pP->rrc_ue_head, &temp);
}
//------------------------------------------------------------------------------
void rrc_eNB_remove_ue_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
struct rrc_eNB_ue_context_NB_IoT_s* ue_context_pP)
//------------------------------------------------------------------------------
{
if (rrc_instance_pP == NULL) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Bad RRC instance\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
return;
}
if (ue_context_pP == NULL) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
return;
}
RB_REMOVE(rrc_ue_tree_NB_IoT_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP);
MSC_LOG_EVENT(
MSC_RRC_ENB,
"0 Removed UE %"PRIx16" ",
ue_context_pP->ue_context.rnti);
rrc_eNB_free_mem_UE_context_NB_IoT(ctxt_pP, ue_context_pP);
uid_linear_allocator_free_NB_IoT(rrc_instance_pP, ue_context_pP->local_uid);
free(ue_context_pP);
LOG_I(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" Removed UE context\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
}
......@@ -31,7 +31,7 @@
#include "collection/tree.h"
#include "COMMON/platform_types.h"
#include "defs.h"
#include "defs_NB_IoT.h"
//#include "defs_NB_IoT.h"
void
......@@ -80,46 +80,4 @@ void rrc_eNB_remove_ue_context(
struct rrc_eNB_ue_context_s* ue_context_pP
);
//-----NB-IoT-----------------------
void
uid_linear_allocator_init_NB_IoT(
uid_allocator_NB_IoT_t* const uid_pP
);
uid_t
uid_linear_allocator_new_NB_IoT(
eNB_RRC_INST_NB_IoT* const rrc_instance_pP
);
void
uid_linear_allocator_free_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
uid_t uidP
);
int rrc_eNB_compare_ue_rnti_id_NB_IoT(
struct rrc_eNB_ue_context_NB_IoT_s* c1_pP, struct rrc_eNB_ue_context_NB_IoT_s* c2_pP);
RB_PROTOTYPE(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s, entries, rrc_eNB_compare_ue_rnti_id_NB_IoT);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_allocate_new_UE_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP
);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_get_ue_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
rnti_t rntiP);
void rrc_eNB_remove_ue_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
struct rrc_eNB_ue_context_NB_IoT_s* ue_context_pP);
#endif
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_eNB_UE_context.h
* \brief rrc procedures for UE context
* \author Lionel GAUTHIER
* \date 2015
* \version 1.0
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "UTIL/LOG/log.h"
#include "rrc_eNB_UE_context_NB_IoT.h"
#include "msc.h"
//------------------------------------------------------------------------------
void
uid_linear_allocator_init_NB_IoT(
uid_allocator_NB_IoT_t* const uid_pP
)
//------------------------------------------------------------------------------
{
memset(uid_pP, 0, sizeof(uid_allocator_NB_IoT_t));
}
//------------------------------------------------------------------------------
uid_t
uid_linear_allocator_new_NB_IoT(
eNB_RRC_INST_NB_IoT* const rrc_instance_pP
)
//------------------------------------------------------------------------------
{
unsigned int i;
unsigned int bit_index = 1;
uid_t uid = 0;
uid_allocator_NB_IoT_t* uia_p = &rrc_instance_pP->uid_allocator;
for (i=0; i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE; i++) {
if (uia_p->bitmap[i] != UINT_MAX) {
bit_index = 1;
uid = 0;
while ((uia_p->bitmap[i] & bit_index) == bit_index) {
bit_index = bit_index << 1;
uid += 1;
}
uia_p->bitmap[i] |= bit_index;
return uid + (i*sizeof(unsigned int)*8);
}
}
return UINT_MAX;
}
//------------------------------------------------------------------------------
void
uid_linear_allocator_free_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
uid_t uidP
)
//------------------------------------------------------------------------------
{
unsigned int i = uidP/sizeof(unsigned int)/8;
unsigned int bit = uidP % (sizeof(unsigned int) * 8);
unsigned int value = ~(0x00000001 << bit);
if (i < UID_LINEAR_ALLOCATOR_BITMAP_SIZE) {
rrc_instance_pP->uid_allocator.bitmap[i] &= value;
}
}
int rrc_eNB_compare_ue_rnti_id_NB_IoT(
struct rrc_eNB_ue_context_NB_IoT_s* c1_pP, struct rrc_eNB_ue_context_NB_IoT_s* c2_pP)
//------------------------------------------------------------------------------
{
if (c1_pP->ue_id_rnti > c2_pP->ue_id_rnti) {
return 1;
}
if (c1_pP->ue_id_rnti < c2_pP->ue_id_rnti) {
return -1;
}
return 0;
}
/* Generate the tree management functions for NB-IoT structures */
RB_GENERATE(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s, entries,
rrc_eNB_compare_ue_rnti_id_NB_IoT);
//------------------------------------------------------------------------------
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_allocate_new_UE_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP
)
//------------------------------------------------------------------------------
{
struct rrc_eNB_ue_context_NB_IoT_s* new_p;
new_p = malloc(sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
if (new_p == NULL) {
LOG_E(RRC, "Cannot allocate new ue context\n");
return NULL;
}
memset(new_p, 0, sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
new_p->local_uid = uid_linear_allocator_new_NB_IoT(rrc_instance_pP);
return new_p;
}
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_get_ue_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
rnti_t rntiP)
//------------------------------------------------------------------------------
{
rrc_eNB_ue_context_NB_IoT_t temp;
memset(&temp, 0, sizeof(struct rrc_eNB_ue_context_NB_IoT_s));
/* eNB ue rrc id = 24 bits wide */
temp.ue_id_rnti = rntiP;
return RB_FIND(rrc_ue_tree_NB_IoT_s, &rrc_instance_pP->rrc_ue_head, &temp);
}
//------------------------------------------------------------------------------
void rrc_eNB_remove_ue_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
struct rrc_eNB_ue_context_NB_IoT_s* ue_context_pP)
//------------------------------------------------------------------------------
{
if (rrc_instance_pP == NULL) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Bad RRC instance\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
return;
}
if (ue_context_pP == NULL) {
LOG_E(RRC, PROTOCOL_RRC_CTXT_UE_FMT" Trying to free a NULL UE context\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
return;
}
RB_REMOVE(rrc_ue_tree_NB_IoT_s, &rrc_instance_pP->rrc_ue_head, ue_context_pP);
MSC_LOG_EVENT(
MSC_RRC_ENB,
"0 Removed UE %"PRIx16" ",
ue_context_pP->ue_context.rnti);
rrc_eNB_free_mem_UE_context_NB_IoT(ctxt_pP, ue_context_pP);
uid_linear_allocator_free_NB_IoT(rrc_instance_pP, ue_context_pP->local_uid);
free(ue_context_pP);
LOG_I(RRC,
PROTOCOL_RRC_CTXT_UE_FMT" Removed UE context\n",
PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP));
}
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.0 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
/*! \file rrc_eNB_UE_context.h
* \brief rrc procedures for UE context
* \author Lionel GAUTHIER
* \date 2015
* \version 1.0
* \company Eurecom
* \email: lionel.gauthier@eurecom.fr
*/
#ifndef __RRC_ENB_UE_CONTEXT_NB_IoT_H__
#define __RRC_ENB_UE_CONTEXT_NB_IoT_H__
#include "collection/tree.h"
#include "COMMON/platform_types.h"
//#include "defs.h"
#include "defs_NB_IoT.h"
void
uid_linear_allocator_init_NB_IoT(
uid_allocator_NB_IoT_t* const uid_pP
);
uid_t
uid_linear_allocator_new_NB_IoT(
eNB_RRC_INST_NB_IoT* const rrc_instance_pP
);
void
uid_linear_allocator_free_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
uid_t uidP
);
int rrc_eNB_compare_ue_rnti_id_NB_IoT(
struct rrc_eNB_ue_context_NB_IoT_s* c1_pP, struct rrc_eNB_ue_context_NB_IoT_s* c2_pP);
RB_PROTOTYPE(rrc_ue_tree_NB_IoT_s, rrc_eNB_ue_context_NB_IoT_s, entries, rrc_eNB_compare_ue_rnti_id_NB_IoT);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_allocate_new_UE_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP
);
struct rrc_eNB_ue_context_NB_IoT_s*
rrc_eNB_get_ue_context_NB_IoT(
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
rnti_t rntiP);
void rrc_eNB_remove_ue_context_NB_IoT(
const protocol_ctxt_t* const ctxt_pP,
eNB_RRC_INST_NB_IoT* rrc_instance_pP,
struct rrc_eNB_ue_context_NB_IoT_s* ue_context_pP);
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment