Commit afcbf7b6 authored by Laurent THOMAS's avatar Laurent THOMAS

remove most of globale variables, remain data model inconsistency and race conditions

parent 6ce958f7
......@@ -85,7 +85,6 @@ char * split73_config;
int split73;
AGENT_RRC_xface *agent_rrc_xface[NUM_MAX_ENB]= {0};
AGENT_MAC_xface *agent_mac_xface[NUM_MAX_ENB]= {0};
uint8_t proto_agent_flag = 0;
void flexran_agent_slice_update(mid_t module_idP) {
}
int proto_agent_start(mod_id_t mod_id, const cudu_params_t *p){
......
......@@ -303,7 +303,7 @@ typedef struct f1ap_initial_ul_rrc_message_s {
uint16_t crnti;
uint8_t *rrc_container;
int rrc_container_length;
int8_t *du2cu_rrc_container;
char *du2cu_rrc_container;
int du2cu_rrc_container_length;
} f1ap_initial_ul_rrc_message_t;
......
......@@ -1910,6 +1910,7 @@ int RCconfig_DU_F1(MessageDef *msg_p, uint32_t i) {
AssertFatal(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr != NULL,
"eNB id %u is not defined in configuration file\n",i);
F1AP_SETUP_REQ (msg_p).num_cells_available = 0;
F1AP_SETUP_REQ (msg_p).cell_type = CELL_MACRO_ENB;
for (k=0; k <num_enbs ; k++) {
if (strcmp(ENBSParams[ENB_ACTIVE_ENBS_IDX].strlistptr[k], *(ENBParamList.paramarray[i][ENB_ENB_NAME_IDX].strptr) )== 0) {
......
......@@ -32,6 +32,9 @@
#include "f1ap_common.h"
static f1ap_cudu_inst_t *f1_du_inst[NUMBER_OF_eNB_MAX]= {0};
static f1ap_cudu_inst_t *f1_cu_inst[NUMBER_OF_eNB_MAX]= {0};
#if defined(EMIT_ASN_DEBUG_EXTERN)
int asn_debug = 0;
int asn1_xer_print = 0;
......@@ -61,11 +64,30 @@ uint8_t F1AP_get_next_transaction_identifier(module_id_t enb_mod_idP, module_id_
return transaction_identifier[enb_mod_idP+cu_mod_idP];
}
int f1ap_add_ue(f1ap_cudu_inst_t *f1_inst,
f1ap_cudu_inst_t *getCxt(bool isCU, module_id_t module_idP) {
AssertFatal( module_idP < sizeofArray(f1_cu_inst), "");
return isCU? f1_cu_inst[ module_idP]: f1_du_inst[ module_idP];
}
void createF1inst(bool isCU, module_id_t module_idP, f1ap_setup_req_t *req) {
if (isCU) {
AssertFatal(f1_cu_inst[module_idP] == NULL, "Double call to F1 CU init\n");
f1_cu_inst[module_idP]=( f1ap_cudu_inst_t *) calloc(1, sizeof( f1ap_cudu_inst_t));
//memcpy(f1_cu_inst[module_idP]->setupReq, req, sizeof(f1ap_setup_req_t) );
} else {
AssertFatal(f1_du_inst[module_idP] == NULL, "Double call to F1 DU init\n");
f1_du_inst[module_idP]=( f1ap_cudu_inst_t *) calloc(1, sizeof(f1ap_cudu_inst_t));
memcpy(&f1_du_inst[module_idP]->setupReq, req, sizeof(f1ap_setup_req_t) );
}
}
int f1ap_add_ue(bool isCu,
module_id_t module_idP,
int CC_idP,
int UE_id,
rnti_t rntiP) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].rnti == rntiP) {
f1_inst->f1ap_ue[i].f1ap_uid = i;
......@@ -92,8 +114,10 @@ int f1ap_add_ue(f1ap_cudu_inst_t *f1_inst,
}
int f1ap_remove_ue(f1ap_cudu_inst_t *f1_inst,
int f1ap_remove_ue(bool isCu, module_id_t module_idP,
rnti_t rntiP) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].rnti == rntiP) {
f1_inst->f1ap_ue[i].rnti = 0;
......@@ -105,8 +129,10 @@ int f1ap_remove_ue(f1ap_cudu_inst_t *f1_inst,
return 0;
}
int f1ap_get_du_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_du_ue_f1ap_id(bool isCu, module_id_t module_idP,
rnti_t rntiP) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].rnti == rntiP) {
return f1_inst->f1ap_ue[i].du_ue_f1ap_id;
......@@ -116,8 +142,10 @@ int f1ap_get_du_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_cu_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_cu_ue_f1ap_id(bool isCu, module_id_t module_idP,
rnti_t rntiP) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].rnti == rntiP) {
return f1_inst->f1ap_ue[i].cu_ue_f1ap_id;
......@@ -127,8 +155,10 @@ int f1ap_get_cu_ue_f1ap_id(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_rnti_by_du_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_rnti_by_du_id(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id ) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].du_ue_f1ap_id == du_ue_f1ap_id) {
return f1_inst->f1ap_ue[i].rnti;
......@@ -138,8 +168,10 @@ int f1ap_get_rnti_by_du_id(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_rnti_by_cu_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_rnti_by_cu_id(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id ) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].cu_ue_f1ap_id == cu_ue_f1ap_id) {
return f1_inst->f1ap_ue[i].rnti;
......@@ -149,8 +181,10 @@ int f1ap_get_rnti_by_cu_id(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_du_uid(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_du_uid(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id ) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].du_ue_f1ap_id == du_ue_f1ap_id) {
return i;
......@@ -160,8 +194,10 @@ int f1ap_get_du_uid(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_cu_uid(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_cu_uid(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id ) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].cu_ue_f1ap_id == cu_ue_f1ap_id) {
return i;
......@@ -171,8 +207,10 @@ int f1ap_get_cu_uid(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_get_uid_by_rnti(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_uid_by_rnti(bool isCu, module_id_t module_idP,
rnti_t rntiP ) {
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (f1_inst->f1ap_ue[i].rnti == rntiP) {
return i;
......@@ -182,10 +220,11 @@ int f1ap_get_uid_by_rnti(f1ap_cudu_inst_t *f1_inst,
return -1;
}
int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_du_add_cu_ue_id(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id,
module_id_t cu_ue_f1ap_id) {
module_id_t f1ap_uid = f1ap_get_du_uid(f1_inst,du_ue_f1ap_id);
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
module_id_t f1ap_uid = f1ap_get_du_uid(isCu, module_idP,du_ue_f1ap_id);
if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB)
return -1;
......@@ -195,10 +234,11 @@ int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst,
return 0;
}
int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_cu_add_du_ue_id(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id,
module_id_t du_ue_f1ap_id) {
module_id_t f1ap_uid = f1ap_get_cu_uid(f1_inst,cu_ue_f1ap_id);
f1ap_cudu_inst_t *f1_inst=getCxt(isCu, module_idP);
module_id_t f1ap_uid = f1ap_get_cu_uid(isCu,module_idP,cu_ue_f1ap_id);
if (f1ap_uid < 0 || f1ap_uid >= MAX_MOBILES_PER_ENB)
return -1;
......@@ -207,3 +247,8 @@ int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst,
LOG_I(F1AP, "Adding du_ue_f1ap_id %d for UE with RNTI %x\n", du_ue_f1ap_id, f1_inst->f1ap_ue[f1ap_uid].rnti);
return 0;
}
int f1ap_assoc_id(bool isCu, module_id_t module_idP) {
f1ap_setup_req_t *f1_inst=f1ap_req(isCu, module_idP);
return f1_inst->assoc_id;
}
......@@ -426,6 +426,12 @@ typedef struct f1ap_cudu_ue_inst_s {
} f1ap_cudu_ue_t;
typedef struct f1ap_cudu_inst_s {
f1ap_setup_req_t setupReq;
instance_t du_ue_f1ap_id;
uint16_t sctp_in_streams;
uint16_t sctp_out_streams;
uint16_t default_sctp_stream_id;
uint64_t gNB_DU_id;
uint16_t num_ues;
f1ap_cudu_ue_t f1ap_ue[MAX_MOBILES_PER_ENB];
} f1ap_cudu_inst_t;
......@@ -434,59 +440,67 @@ typedef struct f1ap_cudu_inst_s {
uint8_t F1AP_get_next_transaction_identifier(module_id_t enb_mod_idP, module_id_t cu_mod_idP);
f1ap_cudu_inst_t *getCxt(bool isCU, module_id_t module_idP);
int f1ap_add_ue(f1ap_cudu_inst_t *f1_inst,
void createF1inst(bool isCU, module_id_t module_idP, f1ap_setup_req_t *req);
int f1ap_add_ue(bool isCu,
module_id_t module_idP,
int CC_idP,
int UE_id,
rnti_t rntiP);
int f1ap_remove_ue(f1ap_cudu_inst_t *f1_inst,
int f1ap_remove_ue(bool isCu, module_id_t module_idP,
rnti_t rntiP);
int f1ap_get_du_ue_f1ap_id (f1ap_cudu_inst_t *f1_inst,
int f1ap_get_du_ue_f1ap_id (bool isCu, module_id_t module_idP,
rnti_t rntiP);
int f1ap_get_cu_ue_f1ap_id (f1ap_cudu_inst_t *f1_inst,
int f1ap_get_cu_ue_f1ap_id (bool isCu, module_id_t module_idP,
rnti_t rntiP);
int f1ap_get_rnti_by_du_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_rnti_by_du_id(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id );
int f1ap_get_rnti_by_cu_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_rnti_by_cu_id(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id );
int f1ap_get_du_uid(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_du_uid(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id );
int f1ap_get_cu_uid(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_cu_uid(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id );
int f1ap_get_uid_by_rnti(f1ap_cudu_inst_t *f1_inst,
int f1ap_get_uid_by_rnti(bool isCu, module_id_t module_idP,
rnti_t rntiP );
int f1ap_du_add_cu_ue_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_du_add_cu_ue_id(bool isCu, module_id_t module_idP,
module_id_t du_ue_f1ap_id,
module_id_t cu_ue_f1ap_id);
int f1ap_cu_add_du_ue_id(f1ap_cudu_inst_t *f1_inst,
int f1ap_cu_add_du_ue_id(bool isCu, module_id_t module_idP,
module_id_t cu_ue_f1ap_id,
module_id_t du_ue_f1ap_id);
int f1ap_assoc_id(bool isCu, module_id_t module_idP);
static inline f1ap_setup_req_t *f1ap_req(bool isCu, module_id_t module_idP) {
return &getCxt(isCu, module_idP)->setupReq;
}
#define asn1cCalloc(VaR, TyPe, lOcPtr) TyPe *lOcPtr=VaR=(TyPe*) calloc(1,sizeof(TyPe));
#define asn1cCallocOne(VaR, TyPe, VaLue) VaR=(TyPe*) calloc(1,sizeof(TyPe)); *VaR=VaLue;
#define asn1cSequenceAdd(VaR, TyPe, lOcPtr) TyPe *lOcPtr=(TyPe*) calloc(1,sizeof(TyPe)); ASN_SEQUENCE_ADD(&VaR,lOcPtr);
#define TASK_F1APP f1ap_req(false, instance)->cell_type==CELL_MACRO_GNB?TASK_GNB_APP:TASK_ENB_APP
//lts: C struct type is not homogeneous, so we need macros instead of functions
#define addnRCGI(nRCGi, servedCelL) \
MCC_MNC_TO_PLMNID((servedCelL)->mcc,(servedCelL)-> mnc,(servedCelL)->mnc_digit_length, \
&((nRCGi).pLMN_Identity)); \
&((nRCGi).pLMN_Identity)); \
NR_CELL_ID_TO_BIT_STRING((servedCelL)->nr_cellid, &((nRCGi).nRCellIdentity));
extern f1ap_setup_req_t *f1ap_du_data_from_du;
extern RAN_CONTEXT_t RC;
#endif /* F1AP_COMMON_H_ */
......@@ -133,8 +133,11 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance,
}
/* - nRCGI */
addnRCGI(served_cells_item_p->served_Cell_Information.nRCGI, req->cell+i);
TBCD_TO_MCC_MNC(&(served_cells_item_p->served_Cell_Information.nRCGI.pLMN_Identity), req->cell[i].mcc,
req->cell[i].mnc,req->cell[i].mnc_digit_length);
// NR cellID
BIT_STRING_TO_NR_CELL_IDENTITY(&served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity,
req->cell[i].nr_cellid);
LOG_D(F1AP, "[SCTP %d] Received nRCGI: MCC %d, MNC %d, CELL_ID %llu\n", assoc_id,
req->cell[i].mcc,
req->cell[i].mnc,
......@@ -147,6 +150,12 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance,
served_cells_item_p->served_Cell_Information.nRCGI.nRCellIdentity.buf[4]);
/* - nRPCI */
req->cell[i].nr_pci = served_cells_item_p->served_Cell_Information.nRPCI;
// LTS: FIXME data model failure: we don't KNOW if we receive a 4G or a 5G cell
// Furthermore, cell_type is not a attribute of a cell in the data structure !!!!!!!!!!
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU)
f1ap_req(true, instance)->cell_type=CELL_MACRO_GNB;
LOG_D(F1AP, "req->nr_pci[%d] %d \n",
i, req->cell[i].nr_pci);
// System Information
......@@ -170,7 +179,6 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance,
i, req->sib1[i], req->sib1_length[i]);
}
*f1ap_du_data_from_du = F1AP_SETUP_REQ(message_p);
// char *measurement_timing_information[F1AP_MAX_NB_CELLS];
// uint8_t ranac[F1AP_MAX_NB_CELLS];
// int fdd_flag = f1ap_setup_req->fdd_flag;
......@@ -222,13 +230,7 @@ int CU_handle_F1_SETUP_REQUEST(instance_t instance,
}
} else {
CU_send_F1_SETUP_FAILURE(instance);
if (RC.nrrrc[0]->node_type == ngran_gNB_CU) {
itti_free(TASK_RRC_GNB,message_p);
} else {
itti_free(TASK_RRC_ENB,message_p);
}
itti_free(TASK_RRC_GNB,message_p);
return -1;
}
......@@ -287,7 +289,7 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance,
i<num_cells_to_activate;
i++) {
asn1cSequenceAdd(ie3->value.choice.Cells_to_be_Activated_List.list,
F1AP_Cells_to_be_Activated_List_ItemIEs_t, cells_to_be_activated_ies);
F1AP_Cells_to_be_Activated_List_ItemIEs_t, cells_to_be_activated_ies);
cells_to_be_activated_ies->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item;
cells_to_be_activated_ies->criticality = F1AP_Criticality_reject;
cells_to_be_activated_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item;
......@@ -340,7 +342,7 @@ int CU_send_F1_SETUP_RESPONSE(instance_t instance,
}
ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0);
f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0);
return 0;
}
......@@ -394,13 +396,13 @@ int CU_send_F1_SETUP_FAILURE(instance_t instance) {
ie4->criticality = F1AP_Criticality_ignore;
ie4->value.present = F1AP_F1SetupFailureIEs__value_PR_CriticalityDiagnostics;
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCode,
F1AP_ProcedureCode_t, F1AP_ProcedureCode_id_UEContextSetup);
F1AP_ProcedureCode_t, F1AP_ProcedureCode_id_UEContextSetup);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.triggeringMessage,
F1AP_TriggeringMessage_t, F1AP_TriggeringMessage_initiating_message);
F1AP_TriggeringMessage_t, F1AP_TriggeringMessage_initiating_message);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.procedureCriticality,
F1AP_Criticality_t, F1AP_Criticality_reject);
F1AP_Criticality_t, F1AP_Criticality_reject);
asn1cCallocOne(ie4->value.choice.CriticalityDiagnostics.transactionID,
F1AP_TransactionID_t, 0);
F1AP_TransactionID_t, 0);
}
/* encode */
......@@ -410,7 +412,7 @@ int CU_send_F1_SETUP_FAILURE(instance_t instance) {
}
ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0);
f1ap_itti_send_sctp_data_req(true,instance, buffer, len, 0);
return 0;
}
......@@ -480,7 +482,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu
cells_to_be_activated_ies->value.present = F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item;
// 2.1 cells to be Activated list item
F1AP_Cells_to_be_Activated_List_Item_t *cells_to_be_activated_list_item=
&cells_to_be_activated_ies->value.choice.Cells_to_be_Activated_List_Item;
&cells_to_be_activated_ies->value.choice.Cells_to_be_Activated_List_Item;
// - nRCGI
addnRCGI(cells_to_be_activated_list_item->nRCGI, f1ap_gnb_cu_configuration_update->cells_to_activate+i);
// optional
......@@ -499,7 +501,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu
if (f1ap_gnb_cu_configuration_update->cells_to_activate[i].num_SI > 0) {
F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation =
&cells_to_be_activated_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation;
&cells_to_be_activated_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation;
//LOG_I(F1AP, "%s() SI %d size %d: ", __func__, i, f1ap_setup_resp->SI_container_length[i][0]);
//for (int n = 0; n < f1ap_setup_resp->SI_container_length[i][0]; n++)
// printf("%02x ", f1ap_setup_resp->SI_container[i][0][n]);
......@@ -811,7 +813,7 @@ int CU_send_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, f1ap_gnb_cu_configu
LOG_DUMPMSG(F1AP, LOG_DUMP_CHAR, buffer, len, "F1AP gNB-CU CONFIGURATION UPDATE : ");
ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
cu_f1ap_itti_send_sctp_data_req(instance, f1ap_du_data_from_du->assoc_id, buffer, len, 0);
f1ap_itti_send_sctp_data_req(true,instance, buffer, len, 0);
return 0;
}
......
......@@ -38,20 +38,10 @@
#include "common/ran_context.h"
#include "openair3/UTILS/conversions.h"
// Bing Kai: create CU and DU context, and put all the information there.
uint64_t du_ue_f1ap_id = 0;
uint32_t f1ap_assoc_id = 0;
uint32_t f1ap_stream = 0;
extern f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB];
/*
Initial UL RRC Message Transfer
*/
extern RAN_CONTEXT_t RC;
int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
uint32_t assoc_id,
uint32_t stream,
......@@ -74,15 +64,11 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
return -1;
}
// TODO: use context
f1ap_stream = stream;
f1ap_assoc_id = assoc_id;
container = &pdu->choice.initiatingMessage->value.choice.InitialULRRCMessageTransfer;
/* GNB_DU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_InitialULRRCMessageTransferIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
LOG_D(F1AP, "du_ue_f1ap_id %lu \n", du_ue_f1ap_id);
getCxt(true, instance)->du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
/* NRCGI
* TODO: process NRCGI
*/
......@@ -100,7 +86,7 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
AssertFatal(ie!=NULL,"RRCContainer is missing\n");
// create an ITTI message and copy SDU
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) {
message_p = itti_alloc_new_message (TASK_CU_F1, 0, NR_RRC_MAC_CCCH_DATA_IND);
memset (NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu, 0, CCCH_SDU_SIZE);
ccch_sdu_len = ie->value.choice.RRCContainer.size;
......@@ -137,7 +123,7 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
// Find instance from nr_cellid
int rrc_inst = -1;
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
if (f1ap_req(true, instance)->cell_type==CELL_MACRO_GNB) {
for (int i=0; i<RC.nb_nr_inst; i++) {
// first get RRC instance (note, no the ITTI instance)
gNB_RRC_INST *rrc = RC.nrrrc[i];
......@@ -160,7 +146,7 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
}
AssertFatal(rrc_inst>=0,"couldn't find an RRC instance for nr_cell %llu\n",(unsigned long long int)nr_cellid);
int f1ap_uid = f1ap_add_ue(&f1ap_cu_inst[rrc_inst], rrc_inst, CC_id, 0, rnti);
int f1ap_uid = f1ap_add_ue(true, rrc_inst, CC_id, 0, rnti);
if (f1ap_uid < 0 ) {
LOG_E(F1AP, "Failed to add UE \n");
......@@ -168,26 +154,14 @@ int CU_handle_INITIAL_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
return -1;
}
f1ap_cu_inst[rrc_inst].f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id;
if (RC.nrrrc[GNB_INSTANCE_TO_MODULE_ID(instance)]->node_type == ngran_gNB_CU) {
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
itti_send_msg_to_task (TASK_RRC_GNB, instance, message_p);
} else {
RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
RRC_MAC_CCCH_DATA_IND (message_p).enb_index = rrc_inst; // CU instance
RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
itti_send_msg_to_task (TASK_RRC_ENB, instance, message_p);
}
//getCxt(true,ITTI_MSG_DESTINATION_ID(message_p))->f1ap_ue[f1ap_uid].du_ue_f1ap_id = du_ue_f1ap_id;
NR_RRC_MAC_CCCH_DATA_IND (message_p).frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sub_frame = 0;
NR_RRC_MAC_CCCH_DATA_IND (message_p).sdu_size = ccch_sdu_len;
NR_RRC_MAC_CCCH_DATA_IND (message_p).gnb_index = rrc_inst; // CU instance
NR_RRC_MAC_CCCH_DATA_IND (message_p).rnti = rnti;
NR_RRC_MAC_CCCH_DATA_IND (message_p).CC_id = CC_id;
itti_send_msg_to_task (f1ap_req(true,ITTI_MSG_DESTINATION_ID(message_p))->cell_type==CELL_MACRO_GNB?TASK_RRC_GNB:TASK_RRC_ENB, instance, message_p);
return 0;
}
......@@ -218,7 +192,7 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
ie1->id = F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_CU_UE_F1AP_ID;
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti);
ie1->value.choice.GNB_CU_UE_F1AP_ID = f1ap_get_cu_ue_f1ap_id(true, instance, f1ap_dl_rrc->rnti);
LOG_I(F1AP, "Setting GNB_CU_UE_F1AP_ID %llu associated with UE RNTI %x (instance %ld)\n",
(unsigned long long int)ie1->value.choice.GNB_CU_UE_F1AP_ID, f1ap_dl_rrc->rnti, instance);
/* mandatory */
......@@ -227,7 +201,7 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
ie2->id = F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_GNB_DU_UE_F1AP_ID;
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(&f1ap_cu_inst[instance], f1ap_dl_rrc->rnti);
ie2->value.choice.GNB_DU_UE_F1AP_ID = f1ap_get_du_ue_f1ap_id(true, instance, f1ap_dl_rrc->rnti);
LOG_I(F1AP, "GNB_DU_UE_F1AP_ID %llu associated with UE RNTI %x \n", (unsigned long long int)ie2->value.choice.GNB_DU_UE_F1AP_ID, f1ap_dl_rrc->rnti);
/* optional */
/* c3. oldgNB_DU_UE_F1AP_ID */
......@@ -264,7 +238,7 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
ie6->criticality = F1AP_Criticality_reject;
ie6->value.present = F1AP_DLRRCMessageTransferIEs__value_PR_RRCContainer;
OCTET_STRING_fromBuf(&ie6->value.choice.RRCContainer,
(const char *)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length);
(const char *)f1ap_dl_rrc->rrc_container, f1ap_dl_rrc->rrc_container_length);
/* optional */
/* c7. RAT_FrequencyPriorityInformation */
......@@ -294,7 +268,7 @@ int CU_send_DL_RRC_MESSAGE_TRANSFER(instance_t instance,
return -1;
}
cu_f1ap_itti_send_sctp_data_req(instance, f1ap_assoc_id /* BK: fix me*/, buffer, len, 0 /* BK: fix me*/);
f1ap_itti_send_sctp_data_req(true, instance, buffer, len, 0 /* BK: fix me*/);
return 0;
}
......@@ -326,13 +300,13 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
F1AP_ProtocolIE_ID_id_gNB_CU_UE_F1AP_ID, true);
cu_ue_f1ap_id = ie->value.choice.GNB_CU_UE_F1AP_ID;
LOG_D(F1AP, "cu_ue_f1ap_id %lu associated with RNTI %x\n",
cu_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id));
cu_ue_f1ap_id, f1ap_get_rnti_by_cu_id(true, instance, cu_ue_f1ap_id));
/* GNB_DU_UE_F1AP_ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
F1AP_ProtocolIE_ID_id_gNB_DU_UE_F1AP_ID, true);
du_ue_f1ap_id = ie->value.choice.GNB_DU_UE_F1AP_ID;
LOG_D(F1AP, "du_ue_f1ap_id %lu associated with RNTI %x\n",
du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], du_ue_f1ap_id));
du_ue_f1ap_id, f1ap_get_rnti_by_cu_id(true, instance, du_ue_f1ap_id));
/* mandatory */
/* SRBID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_ULRRCMessageTransferIEs_t, ie, container,
......@@ -362,7 +336,7 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
ie->value.choice.RRCContainer.size);
RRC_DCCH_DATA_IND (message_p).dcch_index = srb_id;
RRC_DCCH_DATA_IND (message_p).rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id);
RRC_DCCH_DATA_IND (message_p).rnti = f1ap_get_rnti_by_cu_id(true, instance, cu_ue_f1ap_id);
RRC_DCCH_DATA_IND (message_p).module_id = instance;
RRC_DCCH_DATA_IND (message_p).eNB_index = instance; // not needed for CU
......@@ -371,7 +345,7 @@ int CU_handle_UL_RRC_MESSAGE_TRANSFER(instance_t instance,
protocol_ctxt_t ctxt;
ctxt.module_id = instance;
ctxt.instance = instance;
ctxt.rnti = f1ap_get_rnti_by_cu_id(&f1ap_cu_inst[instance], cu_ue_f1ap_id);
ctxt.rnti = f1ap_get_rnti_by_cu_id(true, instance, cu_ue_f1ap_id);
ctxt.enb_flag = 1;
ctxt.eNB_index = 0;
ctxt.configured = 1;
......
......@@ -38,13 +38,14 @@
#include "f1ap_cu_task.h"
#include "proto_agent.h"
extern RAN_CONTEXT_t RC;
extern uint8_t proto_agent_flag;
f1ap_setup_req_t *f1ap_du_data_from_du;
f1ap_cudu_inst_t f1ap_cu_inst[MAX_eNB];
void cu_task_handle_sctp_association_ind(instance_t instance, sctp_new_association_ind_t *sctp_new_association_ind) {
createF1inst(true, instance, NULL);
// save the assoc id
f1ap_setup_req_t *f1ap_du_data=f1ap_req(true, instance);
f1ap_du_data->assoc_id = sctp_new_association_ind->assoc_id;
f1ap_du_data->sctp_in_streams = sctp_new_association_ind->in_streams;
f1ap_du_data->sctp_out_streams = sctp_new_association_ind->out_streams;
f1ap_du_data->default_sctp_stream_id = 0;
// Nothing
}
......@@ -56,20 +57,12 @@ void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat
sctp_new_association_resp->sctp_state,
instance,
sctp_new_association_resp->ulp_cnx_id);
if (sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN)
proto_agent_stop(instance);
//if (sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN)
//proto_agent_stop(instance);
//f1ap_handle_setup_message(instance, sctp_new_association_resp->sctp_state == SCTP_STATE_SHUTDOWN);
return; // exit -1 for debugging
}
// go to an init func
f1ap_du_data_from_du = (f1ap_setup_req_t *)calloc(1, sizeof(f1ap_setup_req_t));
// save the assoc id
f1ap_du_data_from_du->assoc_id = sctp_new_association_resp->assoc_id;
f1ap_du_data_from_du->sctp_in_streams = sctp_new_association_resp->in_streams;
f1ap_du_data_from_du->sctp_out_streams = sctp_new_association_resp->out_streams;
/* setup parameters for F1U and start the server */
const cudu_params_t params = {
.local_ipv4_address = RC.nrrrc[instance]->eth_params_s.my_addr,
......@@ -77,9 +70,8 @@ void cu_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat
.remote_ipv4_address = RC.nrrrc[instance]->eth_params_s.remote_addr,
.remote_port = RC.nrrrc[instance]->eth_params_s.remote_portd
};
AssertFatal(proto_agent_start(instance, &params) == 0,
"could not start PROTO_AGENT for F1U on instance %ld!\n", instance);
proto_agent_flag = 1;
//AssertFatal(proto_agent_start(instance, &params) == 0,
// "could not start PROTO_AGENT for F1U on instance %ld!\n", instance);
}
void cu_task_handle_sctp_data_ind(instance_t instance, sctp_data_ind_t *sctp_data_ind) {
......@@ -120,7 +112,10 @@ void cu_task_send_sctp_init_req(instance_t enb_id) {
}
void *F1AP_CU_task(void *arg) {
void *
F1AP_CU_task(void *arg) {
MessageDef *received_msg = NULL;
int result;
LOG_I(F1AP, "Starting F1AP at CU\n");
......@@ -136,7 +131,7 @@ void *F1AP_CU_task(void *arg) {
case SCTP_NEW_ASSOCIATION_IND:
LOG_I(F1AP, "CU Task Received SCTP_NEW_ASSOCIATION_IND for instance %ld\n",
ITTI_MSG_DESTINATION_INSTANCE(received_msg));
cu_task_handle_sctp_association_ind(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
cu_task_handle_sctp_association_ind(ITTI_MSG_ORIGIN_INSTANCE(received_msg),
&received_msg->ittiMsg.sctp_new_association_ind);
break;
......
......@@ -38,11 +38,6 @@
#include "f1ap_du_task.h"
#include "proto_agent.h"
extern RAN_CONTEXT_t RC;
f1ap_setup_req_t *f1ap_du_data;
f1ap_cudu_inst_t f1ap_du_inst[MAX_eNB];
void du_task_send_sctp_association_req(instance_t instance, f1ap_setup_req_t *f1ap_setup_req) {
DevAssert(f1ap_setup_req != NULL);
MessageDef *message_p = NULL;
......@@ -62,9 +57,6 @@ void du_task_send_sctp_association_req(instance_t instance, f1ap_setup_req_t *f1
memcpy(&sctp_new_association_req_p->local_address,
&f1ap_setup_req->DU_f1_ip_address,
sizeof(f1ap_setup_req->DU_f1_ip_address));
// store data
f1ap_du_data = (f1ap_setup_req_t *)calloc(1, sizeof(f1ap_setup_req_t));
*f1ap_du_data = *f1ap_setup_req;
//printf("sib itti message %s\n", f1ap_setup_req_t->sib1[0]);
//printf("nr_cellid : %llx (%lld)",f1ap_setup_req->nr_cellid[0],f1ap_setup_req->nr_cellid[0]);
//du_f1ap_register_to_sctp
......@@ -84,6 +76,7 @@ void du_task_handle_sctp_association_resp(instance_t instance, sctp_new_associat
}
// save the assoc id
f1ap_setup_req_t *f1ap_du_data=f1ap_req(false, instance);
f1ap_du_data->assoc_id = sctp_new_association_resp->assoc_id;
f1ap_du_data->sctp_in_streams = sctp_new_association_resp->in_streams;
f1ap_du_data->sctp_out_streams = sctp_new_association_resp->out_streams;
......@@ -131,13 +124,14 @@ void *F1AP_DU_task(void *arg) {
// 1. save the itti msg so that you can use it to sen f1ap_setup_req, fill the f1ap_setup_req message,
// 2. store the message in f1ap context, that is also stored in RC
// 2. send a sctp_association req
createF1inst(false, ITTI_MSG_DESTINATION_INSTANCE(received_msg), &F1AP_SETUP_REQ(received_msg));
LOG_I(F1AP, "DU Task Received F1AP_SETUP_REQ\n");
du_task_send_sctp_association_req(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
&F1AP_SETUP_REQ(received_msg));
break;
case F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE:
DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_DESTINATION_INSTANCE(received_msg),
DU_send_gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(ITTI_MSG_ORIGIN_INSTANCE(received_msg),
&F1AP_GNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE(received_msg));
break;
......
......@@ -40,8 +40,6 @@
#include "f1ap_cu_ue_context_management.h"
#include "f1ap_du_ue_context_management.h"
extern f1ap_setup_req_t *f1ap_du_data_from_du;
/* Handlers matrix. Only f1 related procedure present here */
f1ap_message_decoded_callback f1ap_messages_callback[][3] = {
......
......@@ -22,26 +22,13 @@
#include "f1ap_common.h"
#include "f1ap_itti_messaging.h"
void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream) {
void f1ap_itti_send_sctp_data_req(bool isCu, instance_t instance, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream) {
MessageDef *message_p;
sctp_data_req_t *sctp_data_req;
message_p = itti_alloc_new_message(TASK_CU_F1, 0, SCTP_DATA_REQ);
message_p = itti_alloc_new_message(isCu?TASK_CU_F1:TASK_DU_F1, 0, SCTP_DATA_REQ);
sctp_data_req = &message_p->ittiMsg.sctp_data_req;
sctp_data_req->assoc_id = assoc_id;
sctp_data_req->buffer = buffer;
sctp_data_req->buffer_length = buffer_length;
sctp_data_req->stream = stream;
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
}
void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream) {
MessageDef *message_p;
sctp_data_req_t *sctp_data_req;
message_p = itti_alloc_new_message(TASK_DU_F1, 0, SCTP_DATA_REQ);
sctp_data_req = &message_p->ittiMsg.sctp_data_req;
sctp_data_req->assoc_id = assoc_id;
sctp_data_req->assoc_id = f1ap_assoc_id(isCu,instance);
sctp_data_req->buffer = buffer;
sctp_data_req->buffer_length = buffer_length;
sctp_data_req->stream = stream;
......@@ -49,12 +36,12 @@ void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
}
void f1ap_itti_send_sctp_close_association(instance_t instance, int32_t assoc_id) {
void f1ap_itti_send_sctp_close_association(bool isCu, instance_t instance) {
MessageDef *message_p = NULL;
sctp_close_association_t *sctp_close_association_p = NULL;
message_p = itti_alloc_new_message(TASK_S1AP, 0, SCTP_CLOSE_ASSOCIATION);
sctp_close_association_p = &message_p->ittiMsg.sctp_close_association;
sctp_close_association_p->assoc_id = assoc_id;
sctp_close_association_p->assoc_id = f1ap_assoc_id(isCu,instance);
itti_send_msg_to_task(TASK_SCTP, instance, message_p);
}
......@@ -22,14 +22,10 @@
#ifndef F1AP_ITTI_MESSAGING_H_
#define F1AP_ITTI_MESSAGING_H_
void cu_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream);
void f1ap_itti_send_sctp_data_req(bool isCu,instance_t instance, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream);
void du_f1ap_itti_send_sctp_data_req(instance_t instance, int32_t assoc_id, uint8_t *buffer,
uint32_t buffer_length, uint16_t stream);
void f1ap_eNB_itti_send_sctp_close_association(instance_t instance,
int32_t assoc_id);
void f1ap_eNB_itti_send_sctp_close_association(bool isCu,instance_t instance);
#endif /* F1AP_ITTI_MESSAGING_H_ */
......@@ -1646,6 +1646,7 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) {
AssertFatal(GNBParamList.paramarray[i][GNB_GNB_ID_IDX].uptr != NULL,
"gNB id %u is not defined in configuration file\n",i);
F1AP_SETUP_REQ (msg_p).num_cells_available = 0;
F1AP_SETUP_REQ (msg_p).cell_type=CELL_MACRO_GNB;
for (k=0; k <num_gnbs ; k++) {
if (strcmp(GNBSParams[GNB_ACTIVE_GNBS_IDX].strlistptr[k], *(GNBParamList.paramarray[i][GNB_GNB_NAME_IDX].strptr)) == 0) {
......
......@@ -55,7 +55,6 @@ static uint64_t pdcp_optmask;
ngran_node_t node_type = ngran_gNB;
uint8_t first_dcch = 0;
uint8_t proto_agent_flag = 0;
/****************************************************************************/
/* rlc_data_req queue - begin */
......
......@@ -183,7 +183,6 @@ eth_params_t *eth_params;
double cpuf;
int oaisim_flag=0;
uint8_t proto_agent_flag = 0;
/* forward declarations */
......
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