Commit 07da84ed authored by Guido Casati's avatar Guido Casati

Use F1 gNB-DU Configuration Update lib in stack

parent 2cc50832
......@@ -411,8 +411,6 @@ typedef struct f1ap_cudu_inst_s {
instance_t gtpInst;
} f1ap_cudu_inst_t;
static const int nrb_lut[29] = {11, 18, 24, 25, 31, 32, 38, 51, 52, 65, 66, 78, 79, 93, 106, 107, 121, 132, 133, 135, 160, 162, 189, 216, 217, 245, 264, 270, 273};
uint8_t F1AP_get_next_transaction_identifier(instance_t mod_idP, instance_t cu_mod_idP);
f1ap_cudu_inst_t *getCxt(instance_t instanceP);
......
......@@ -48,32 +48,6 @@ int CU_send_RESET_ACKNOWLEDGE(sctp_assoc_t assoc_id, const f1ap_reset_ack_t *ack
AssertFatal(1 == 0, "Not implemented yet\n");
}
static int read_slice_info(const F1AP_ServedPLMNs_Item_t *plmn, nssai_t *nssai, int max_nssai)
{
if (plmn->iE_Extensions == NULL)
return 0;
const F1AP_ProtocolExtensionContainer_10696P34_t *p = (F1AP_ProtocolExtensionContainer_10696P34_t *)plmn->iE_Extensions;
if (p->list.count == 0)
return 0;
const F1AP_ServedPLMNs_ItemExtIEs_t *splmn = p->list.array[0];
DevAssert(splmn->id == F1AP_ProtocolIE_ID_id_TAISliceSupportList);
DevAssert(splmn->extensionValue.present == F1AP_ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList);
const F1AP_SliceSupportList_t *ssl = &splmn->extensionValue.choice.SliceSupportList;
AssertFatal(ssl->list.count <= max_nssai, "cannot handle more than 16 slices\n");
for (int s = 0; s < ssl->list.count; ++s) {
const F1AP_SliceSupportItem_t *sl = ssl->list.array[s];
nssai_t *n = &nssai[s];
OCTET_STRING_TO_INT8(&sl->sNSSAI.sST, n->sst);
n->sd = 0xffffff;
if (sl->sNSSAI.sD != NULL)
OCTET_STRING_TO_INT24(sl->sNSSAI.sD, n->sd);
}
return ssl->list.count;
}
/**
* @brief F1AP Setup Request decoding (9.2.1.4 of 3GPP TS 38.473) and transfer to RRC
*/
......@@ -146,324 +120,30 @@ int CU_send_F1_SETUP_FAILURE(sctp_assoc_t assoc_id, const f1ap_setup_failure_t *
return 0;
}
/*
gNB-DU Configuration Update
*/
/**
* @brief Decode and send F1 gNB-DU Configuration Update message to RRC
*/
int CU_handle_gNB_DU_CONFIGURATION_UPDATE(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)
{
LOG_D(F1AP, "CU_handle_gNB_DU_CONFIGURATION_UPDATE\n");
F1AP_GNBDUConfigurationUpdate_t *container;
F1AP_GNBDUConfigurationUpdateIEs_t *ie;
int i = 0;
LOG_D(F1AP, "[SCTP %d] CU_handle_gNB_DU_CONFIGURATION_UPDATE\n", assoc_id);
DevAssert(pdu != NULL);
container = &pdu->choice.initiatingMessage->value.choice.GNBDUConfigurationUpdate;
/* gNB DU Configuration Update == Non UE-related procedure -> stream 0 */
if (stream != 0) {
LOG_W(F1AP, "[SCTP %d] Received f1 setup request on stream != 0 (%d)\n", assoc_id, stream);
}
/* Decode */
f1ap_gnb_du_configuration_update_t msg = {0};
if (!decode_f1ap_du_configuration_update(pdu, &msg)) {
LOG_E(F1AP, "cannot decode F1AP gNB-DU Configuration Update\n");
free_f1ap_du_configuration_update(&msg);
return -1;
}
/* Send to RRC */
MessageDef *message_p = itti_alloc_new_message(TASK_CU_F1, 0, F1AP_GNB_DU_CONFIGURATION_UPDATE);
message_p->ittiMsgHeader.originInstance = assoc_id;
f1ap_gnb_du_configuration_update_t *req = &F1AP_GNB_DU_CONFIGURATION_UPDATE(message_p);
/* 3GPP TS 38.473 Transaction ID*/
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t, ie, container, F1AP_ProtocolIE_ID_id_TransactionID, true);
req->transaction_id = ie->value.choice.TransactionID;
LOG_D(F1AP, "req->transaction_id %lu \n", req->transaction_id);
/* 3GPP TS 38.473 Served Cells To Add List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t,
ie,
container,
F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_List,
false);
if (ie != NULL) {
req->num_cells_to_add = ie->value.choice.Served_Cells_To_Add_List.list.count;
LOG_D(F1AP, "req->num_cells_to_add %d \n", req->num_cells_to_add);
for (i = 0; i < req->num_cells_to_add; i++) {
F1AP_Served_Cells_To_Add_Item_t *served_cells_item =
&((F1AP_Served_Cells_To_Add_ItemIEs_t *)ie->value.choice.Served_Cells_To_Add_List.list.array[i])
->value.choice.Served_Cells_To_Add_Item;
F1AP_Served_Cell_Information_t *servedCellInformation = &served_cells_item->served_Cell_Information;
/* tac */
if (servedCellInformation->fiveGS_TAC) {
req->cell_to_add[i].info.tac = malloc(sizeof(*req->cell_to_add[i].info.tac));
AssertFatal(req->cell_to_add[i].info.tac != NULL, "out of memory\n");
OCTET_STRING_TO_INT24(servedCellInformation->fiveGS_TAC, *req->cell_to_add[i].info.tac);
LOG_D(F1AP, "req->tac[%d] %d \n", i, *req->cell_to_add[i].info.tac);
}
/* - nRCGI */
TBCD_TO_MCC_MNC(&(servedCellInformation->nRCGI.pLMN_Identity),
req->cell_to_add[i].info.plmn.mcc,
req->cell_to_add[i].info.plmn.mnc,
req->cell_to_add[i].info.plmn.mnc_digit_length);
// NR cellID
BIT_STRING_TO_NR_CELL_IDENTITY(&servedCellInformation->nRCGI.nRCellIdentity, req->cell_to_add[i].info.nr_cellid);
LOG_D(F1AP,
"[SCTP %d] Received nRCGI: MCC %d, MNC %d, CELL_ID %llu\n",
assoc_id,
req->cell_to_add[i].info.plmn.mcc,
req->cell_to_add[i].info.plmn.mnc,
(long long unsigned int)req->cell_to_add[i].info.nr_cellid);
/* - nRPCI */
req->cell_to_add[i].info.nr_pci = servedCellInformation->nRPCI;
LOG_D(F1AP, "req->nr_pci[%d] %d \n", i, req->cell_to_add[i].info.nr_pci);
AssertFatal(servedCellInformation->servedPLMNs.list.count == 1, "only one PLMN handled\n");
req->cell_to_add[i].info.num_ssi =
read_slice_info(servedCellInformation->servedPLMNs.list.array[0], req->cell_to_add[i].info.nssai, 16);
// FDD Cells
if (servedCellInformation->nR_Mode_Info.present == F1AP_NR_Mode_Info_PR_fDD) {
req->cell_to_add[i].info.mode = F1AP_MODE_FDD;
f1ap_fdd_info_t *FDDs = &req->cell_to_add[i].info.fdd;
F1AP_FDD_Info_t *fDD_Info = servedCellInformation->nR_Mode_Info.choice.fDD;
FDDs->ul_freqinfo.arfcn = fDD_Info->uL_NRFreqInfo.nRARFCN;
AssertFatal(fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count == 1, "cannot handle more than one frequency band\n");
for (int f = 0; f < fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count; f++) {
F1AP_FreqBandNrItem_t *FreqItem = fDD_Info->uL_NRFreqInfo.freqBandListNr.list.array[f];
FDDs->ul_freqinfo.band = FreqItem->freqBandIndicatorNr;
AssertFatal(FreqItem->supportedSULBandList.list.count == 0, "cannot handle SUL bands!\n");
}
FDDs->dl_freqinfo.arfcn = fDD_Info->dL_NRFreqInfo.nRARFCN;
int dlBands = fDD_Info->dL_NRFreqInfo.freqBandListNr.list.count;
AssertFatal(dlBands == 0, "cannot handled more than one frequency band\n");
for (int dlB = 0; dlB < dlBands; dlB++) {
F1AP_FreqBandNrItem_t *FreqItem = fDD_Info->dL_NRFreqInfo.freqBandListNr.list.array[dlB];
FDDs->dl_freqinfo.band = FreqItem->freqBandIndicatorNr;
int num_available_supported_SULBands = FreqItem->supportedSULBandList.list.count;
AssertFatal(num_available_supported_SULBands == 0, "cannot handle SUL bands!\n");
}
FDDs->ul_tbw.scs = fDD_Info->uL_Transmission_Bandwidth.nRSCS;
FDDs->ul_tbw.nrb = nrb_lut[fDD_Info->uL_Transmission_Bandwidth.nRNRB];
FDDs->dl_tbw.scs = fDD_Info->dL_Transmission_Bandwidth.nRSCS;
FDDs->dl_tbw.nrb = nrb_lut[fDD_Info->dL_Transmission_Bandwidth.nRNRB];
} else if (servedCellInformation->nR_Mode_Info.present == F1AP_NR_Mode_Info_PR_tDD) {
req->cell_to_add[i].info.mode = F1AP_MODE_TDD;
f1ap_tdd_info_t *TDDs = &req->cell_to_add[i].info.tdd;
F1AP_TDD_Info_t *tDD_Info = servedCellInformation->nR_Mode_Info.choice.tDD;
TDDs->freqinfo.arfcn = tDD_Info->nRFreqInfo.nRARFCN;
AssertFatal(tDD_Info->nRFreqInfo.freqBandListNr.list.count == 1, "cannot handle more than one frequency band\n");
for (int f = 0; f < tDD_Info->nRFreqInfo.freqBandListNr.list.count; f++) {
struct F1AP_FreqBandNrItem *FreqItem = tDD_Info->nRFreqInfo.freqBandListNr.list.array[f];
TDDs->freqinfo.band = FreqItem->freqBandIndicatorNr;
int num_available_supported_SULBands = FreqItem->supportedSULBandList.list.count;
AssertFatal(num_available_supported_SULBands == 0, "cannot hanlde SUL bands!\n");
}
TDDs->tbw.scs = tDD_Info->transmission_Bandwidth.nRSCS;
TDDs->tbw.nrb = nrb_lut[tDD_Info->transmission_Bandwidth.nRNRB];
} else {
AssertFatal(false, "unknown NR Mode info %d\n", servedCellInformation->nR_Mode_Info.present);
}
/* MeasurementConfig */
if (servedCellInformation->measurementTimingConfiguration.size > 0)
req->cell_to_add[i].info.measurement_timing_config =
cp_octet_string(&servedCellInformation->measurementTimingConfiguration,
&req->cell_to_add[i].info.measurement_timing_config_len);
struct F1AP_GNB_DU_System_Information *DUsi = served_cells_item->gNB_DU_System_Information;
// System Information
req->cell_to_add[i].sys_info = calloc(1, sizeof(*req->cell_to_add[i].sys_info));
AssertFatal(req->cell_to_add[i].sys_info != NULL, "out of memory\n");
f1ap_gnb_du_system_info_t *sys_info = req->cell_to_add[i].sys_info;
/* mib */
sys_info->mib = calloc(DUsi->mIB_message.size, sizeof(char));
memcpy(sys_info->mib, DUsi->mIB_message.buf, DUsi->mIB_message.size);
sys_info->mib_length = DUsi->mIB_message.size;
/* sib1 */
sys_info->sib1 = calloc(DUsi->sIB1_message.size, sizeof(char));
memcpy(sys_info->sib1, DUsi->sIB1_message.buf, DUsi->sIB1_message.size);
sys_info->sib1_length = DUsi->sIB1_message.size;
}
} else {
req->num_cells_to_add = 0;
}
/* 3GPP TS 38.473 Served Cells To Modify List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t,
ie,
container,
F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_List,
false);
if (ie) {
req->num_cells_to_modify = ie->value.choice.Served_Cells_To_Modify_List.list.count;
LOG_D(F1AP, "req->num_cells_to_modify %d \n", req->num_cells_to_modify);
for (i = 0; i < req->num_cells_to_modify; i++) {
F1AP_Served_Cells_To_Modify_Item_t *served_cells_item =
&((F1AP_Served_Cells_To_Modify_ItemIEs_t *)ie->value.choice.Served_Cells_To_Modify_List.list.array[i])
->value.choice.Served_Cells_To_Modify_Item;
/* OLD NRCGI */
TBCD_TO_MCC_MNC(&(served_cells_item->oldNRCGI.pLMN_Identity),
req->cell_to_modify[i].old_plmn.mcc,
req->cell_to_modify[i].old_plmn.mnc,
req->cell_to_modify[i].old_plmn.mnc_digit_length);
BIT_STRING_TO_NR_CELL_IDENTITY(&served_cells_item->oldNRCGI.nRCellIdentity, req->cell_to_modify[i].old_nr_cellid);
F1AP_Served_Cell_Information_t *servedCellInformation = &served_cells_item->served_Cell_Information;
/* SERVED CELL INFORMATION*/
/* tac */
if (servedCellInformation->fiveGS_TAC) {
req->cell_to_modify[i].info.tac = malloc(sizeof(*req->cell_to_modify[i].info.tac));
AssertFatal(req->cell_to_modify[i].info.tac != NULL, "out of memory\n");
OCTET_STRING_TO_INT24(servedCellInformation->fiveGS_TAC, *req->cell_to_modify[i].info.tac);
LOG_D(F1AP, "req->tac[%d] %d \n", i, *req->cell_to_modify[i].info.tac);
}
/* - nRCGI */
TBCD_TO_MCC_MNC(&(servedCellInformation->nRCGI.pLMN_Identity),
req->cell_to_modify[i].info.plmn.mcc,
req->cell_to_modify[i].info.plmn.mnc,
req->cell_to_modify[i].info.plmn.mnc_digit_length);
// NR cellID
BIT_STRING_TO_NR_CELL_IDENTITY(&servedCellInformation->nRCGI.nRCellIdentity, req->cell_to_modify[i].info.nr_cellid);
LOG_D(F1AP,
"[SCTP %d] Received nRCGI: MCC %d, MNC %d, CELL_ID %llu\n",
assoc_id,
req->cell_to_modify[i].info.plmn.mcc,
req->cell_to_modify[i].info.plmn.mnc,
(long long unsigned int)req->cell_to_modify[i].info.nr_cellid);
/* - nRPCI */
req->cell_to_modify[i].info.nr_pci = servedCellInformation->nRPCI;
LOG_D(F1AP, "req->nr_pci[%d] %d \n", i, req->cell_to_modify[i].info.nr_pci);
// FDD Cells
if (servedCellInformation->nR_Mode_Info.present == F1AP_NR_Mode_Info_PR_fDD) {
req->cell_to_modify[i].info.mode = F1AP_MODE_FDD;
f1ap_fdd_info_t *FDDs = &req->cell_to_modify[i].info.fdd;
F1AP_FDD_Info_t *fDD_Info = servedCellInformation->nR_Mode_Info.choice.fDD;
FDDs->ul_freqinfo.arfcn = fDD_Info->uL_NRFreqInfo.nRARFCN;
AssertFatal(fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count == 1, "cannot handle more than one frequency band\n");
for (int f = 0; f < fDD_Info->uL_NRFreqInfo.freqBandListNr.list.count; f++) {
F1AP_FreqBandNrItem_t *FreqItem = fDD_Info->uL_NRFreqInfo.freqBandListNr.list.array[f];
FDDs->ul_freqinfo.band = FreqItem->freqBandIndicatorNr;
AssertFatal(FreqItem->supportedSULBandList.list.count == 0, "cannot handle SUL bands!\n");
}
FDDs->dl_freqinfo.arfcn = fDD_Info->dL_NRFreqInfo.nRARFCN;
int dlBands = fDD_Info->dL_NRFreqInfo.freqBandListNr.list.count;
AssertFatal(dlBands == 0, "cannot handled more than one frequency band\n");
for (int dlB = 0; dlB < dlBands; dlB++) {
F1AP_FreqBandNrItem_t *FreqItem = fDD_Info->dL_NRFreqInfo.freqBandListNr.list.array[dlB];
FDDs->dl_freqinfo.band = FreqItem->freqBandIndicatorNr;
int num_available_supported_SULBands = FreqItem->supportedSULBandList.list.count;
AssertFatal(num_available_supported_SULBands == 0, "cannot handle SUL bands!\n");
}
FDDs->ul_tbw.scs = fDD_Info->uL_Transmission_Bandwidth.nRSCS;
FDDs->ul_tbw.nrb = nrb_lut[fDD_Info->uL_Transmission_Bandwidth.nRNRB];
FDDs->dl_tbw.scs = fDD_Info->dL_Transmission_Bandwidth.nRSCS;
FDDs->dl_tbw.nrb = nrb_lut[fDD_Info->dL_Transmission_Bandwidth.nRNRB];
} else if (servedCellInformation->nR_Mode_Info.present == F1AP_NR_Mode_Info_PR_tDD) {
req->cell_to_modify[i].info.mode = F1AP_MODE_TDD;
f1ap_tdd_info_t *TDDs = &req->cell_to_modify[i].info.tdd;
F1AP_TDD_Info_t *tDD_Info = servedCellInformation->nR_Mode_Info.choice.tDD;
TDDs->freqinfo.arfcn = tDD_Info->nRFreqInfo.nRARFCN;
AssertFatal(tDD_Info->nRFreqInfo.freqBandListNr.list.count == 1, "cannot handle more than one frequency band\n");
for (int f = 0; f < tDD_Info->nRFreqInfo.freqBandListNr.list.count; f++) {
struct F1AP_FreqBandNrItem *FreqItem = tDD_Info->nRFreqInfo.freqBandListNr.list.array[f];
TDDs->freqinfo.band = FreqItem->freqBandIndicatorNr;
int num_available_supported_SULBands = FreqItem->supportedSULBandList.list.count;
AssertFatal(num_available_supported_SULBands == 0, "cannot hanlde SUL bands!\n");
}
TDDs->tbw.scs = tDD_Info->transmission_Bandwidth.nRSCS;
TDDs->tbw.nrb = nrb_lut[tDD_Info->transmission_Bandwidth.nRNRB];
} else {
AssertFatal(false, "unknown NR Mode info %d\n", servedCellInformation->nR_Mode_Info.present);
}
/* MeasurementConfig */
if (servedCellInformation->measurementTimingConfiguration.size > 0)
req->cell_to_modify[i].info.measurement_timing_config =
cp_octet_string(&servedCellInformation->measurementTimingConfiguration,
&req->cell_to_modify[i].info.measurement_timing_config_len);
/*gNB DU SYSTEM INFORMATION */
struct F1AP_GNB_DU_System_Information *DUsi = served_cells_item->gNB_DU_System_Information;
if (DUsi != NULL) {
// System Information
req->cell_to_modify[i].sys_info = calloc(1, sizeof(*req->cell_to_modify[i].sys_info));
AssertFatal(req->cell_to_modify[i].sys_info != NULL, "out of memory\n");
f1ap_gnb_du_system_info_t *sys_info = req->cell_to_modify[i].sys_info;
/* mib */
sys_info->mib = calloc(DUsi->mIB_message.size, sizeof(char));
AssertFatal(req->cell_to_modify[i].sys_info->mib != NULL, "out of memory\n");
memcpy(sys_info->mib, DUsi->mIB_message.buf, DUsi->mIB_message.size);
sys_info->mib_length = DUsi->mIB_message.size;
/* sib1 */
sys_info->sib1 = calloc(DUsi->sIB1_message.size, sizeof(char));
AssertFatal(req->cell_to_modify[i].sys_info->sib1 != NULL, "out of memory\n");
memcpy(sys_info->sib1, DUsi->sIB1_message.buf, DUsi->sIB1_message.size);
sys_info->sib1_length = DUsi->sIB1_message.size;
}
}
} else {
req->num_cells_to_modify = 0;
}
/* 3GPP TS 38.473 Served Cells To Delete List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t,
ie,
container,
F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_List,
false);
if (ie) {
req->num_cells_to_delete = ie->value.choice.Served_Cells_To_Delete_List.list.count;
LOG_D(F1AP, "req->num_cells_to_delete %d \n", req->num_cells_to_delete);
for (i = 0; i < req->num_cells_to_delete; i++) {
F1AP_Served_Cells_To_Delete_Item_t *served_cells_item =
&((F1AP_Served_Cells_To_Delete_ItemIEs_t *)ie->value.choice.Served_Cells_To_Delete_List.list.array[i])
->value.choice.Served_Cells_To_Delete_Item;
/* - Old nRCGI */
TBCD_TO_MCC_MNC(&(served_cells_item->oldNRCGI.pLMN_Identity),
req->cell_to_delete[i].plmn.mcc,
req->cell_to_delete[i].plmn.mnc,
req->cell_to_delete[i].plmn.mnc_digit_length);
// NR cellID
BIT_STRING_TO_NR_CELL_IDENTITY(&served_cells_item->oldNRCGI.nRCellIdentity, req->cell_to_delete[i].nr_cellid);
LOG_D(F1AP,
"[SCTP %d] Received nRCGI to delete: MCC %d, MNC %d, CELL_ID %llu\n",
assoc_id,
req->cell_to_delete[i].plmn.mcc,
req->cell_to_delete[i].plmn.mnc,
(long long unsigned int)req->cell_to_delete[i].nr_cellid);
}
} else {
req->num_cells_to_delete = 0;
}
/* 3GPP TS 38.473 Cells Status List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t, ie, container, F1AP_ProtocolIE_ID_id_Cells_Status_List, false);
/* 3GPP TS 38.473 Dedicated SI Delivery Needed UE List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t,
ie,
container,
F1AP_ProtocolIE_ID_id_Dedicated_SIDelivery_NeededUE_List,
false);
/* 3GPP TS 38.473 gNB-DU ID */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t, ie, container, F1AP_ProtocolIE_ID_id_gNB_DU_ID, false);
if (ie != NULL)
asn_INTEGER2ulong(&ie->value.choice.GNB_DU_ID, req->gNB_DU_ID);
/* 3GPP TS 38.473 gNB-DU TNL Association To Remove List */
F1AP_FIND_PROTOCOLIE_BY_ID(F1AP_GNBDUConfigurationUpdateIEs_t,
ie,
container,
F1AP_ProtocolIE_ID_id_GNB_DU_TNL_Association_To_Remove_List,
false);
f1ap_gnb_du_configuration_update_t *req = &F1AP_GNB_DU_CONFIGURATION_UPDATE(message_p); // RRC thread will free it
*req = msg; // copy F1 message to ITTI
free_f1ap_du_configuration_update(&msg);
LOG_D(F1AP, "Sending F1AP_GNB_DU_CONFIGURATION_UPDATE ITTI message \n");
itti_send_msg_to_task(TASK_RRC_GNB, GNB_MODULE_ID_TO_INSTANCE(instance), message_p);
return 0;
......
......@@ -41,17 +41,6 @@
#include "GNB_APP/gnb_paramdef.h"
int to_NRNRB(int nrb) {
for (int i=0; i<sizeofArray(nrb_lut); i++)
if (nrb_lut[i] == nrb)
return i;
if(!RC.nrrrc)
return 0;
AssertFatal(1==0,"nrb %d is not in the list of possible NRNRB\n",nrb);
}
int DU_handle_RESET(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)
{
LOG_D(F1AP, "DU_handle_RESET\n");\
......@@ -162,143 +151,6 @@ int DU_send_RESET_ACKNOWLEDGE(sctp_assoc_t assoc_id, const f1ap_reset_ack_t *ack
return 0;
}
static F1AP_Served_Cell_Information_t encode_served_cell_info(const f1ap_served_cell_info_t *c)
{
/* 4.1.1 served cell Information */
F1AP_Served_Cell_Information_t scell_info = {0};
addnRCGI(scell_info.nRCGI, c);
/* - nRPCI */
scell_info.nRPCI = c->nr_pci; // int 0..1007
/* - fiveGS_TAC */
if (c->tac != NULL) {
uint32_t tac = htonl(*c->tac);
asn1cCalloc(scell_info.fiveGS_TAC, netOrder);
OCTET_STRING_fromBuf(netOrder, ((char *)&tac) + 1, 3);
}
/* - Configured_EPS_TAC */
if (0) {
scell_info.configured_EPS_TAC = (F1AP_Configured_EPS_TAC_t *)calloc(1, sizeof(F1AP_Configured_EPS_TAC_t));
OCTET_STRING_fromBuf(scell_info.configured_EPS_TAC, "2", 2);
}
/* servedPLMN information */
asn1cSequenceAdd(scell_info.servedPLMNs.list, F1AP_ServedPLMNs_Item_t, servedPLMN_item);
MCC_MNC_TO_PLMNID(c->plmn.mcc, c->plmn.mnc, c->plmn.mnc_digit_length, &servedPLMN_item->pLMN_Identity);
F1AP_NR_Mode_Info_t *nR_Mode_Info = &scell_info.nR_Mode_Info;
if (c->num_ssi > 0) {
F1AP_ProtocolExtensionContainer_10696P34_t *p = calloc(1, sizeof(*p));
servedPLMN_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *)p;
asn1cSequenceAdd(p->list, F1AP_ServedPLMNs_ItemExtIEs_t, served_plmns_itemExtIEs);
served_plmns_itemExtIEs->criticality = F1AP_Criticality_ignore;
served_plmns_itemExtIEs->id = F1AP_ProtocolIE_ID_id_TAISliceSupportList;
served_plmns_itemExtIEs->extensionValue.present = F1AP_ServedPLMNs_ItemExtIEs__extensionValue_PR_SliceSupportList;
F1AP_SliceSupportList_t *slice_support_list = &served_plmns_itemExtIEs->extensionValue.choice.SliceSupportList;
for (int s = 0; s < c->num_ssi; s++) {
asn1cSequenceAdd(slice_support_list->list, F1AP_SliceSupportItem_t, slice);
const nssai_t *nssai = &c->nssai[s];
INT8_TO_OCTET_STRING(nssai->sst, &slice->sNSSAI.sST);
if (nssai->sd != 0xffffff) {
asn1cCalloc(slice->sNSSAI.sD, tmp);
INT24_TO_OCTET_STRING(nssai->sd, tmp);
}
}
}
if (c->mode == F1AP_MODE_FDD) { // FDD
const f1ap_fdd_info_t *fdd = &c->fdd;
nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_fDD;
asn1cCalloc(nR_Mode_Info->choice.fDD, fDD_Info);
/* FDD.1.1 UL NRFreqInfo ARFCN */
fDD_Info->uL_NRFreqInfo.nRARFCN = fdd->ul_freqinfo.arfcn; // Integer
/* FDD.1.2 F1AP_SUL_Information */
/* FDD.1.3 freqBandListNr */
int ul_band = 1;
for (int j = 0; j < ul_band; j++) {
asn1cSequenceAdd(fDD_Info->uL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem);
/* FDD.1.3.1 freqBandIndicatorNr*/
nr_freqBandNrItem->freqBandIndicatorNr = fdd->ul_freqinfo.band;
/* FDD.1.3.2 supportedSULBandList*/
}
/* FDD.2.1 DL NRFreqInfo ARFCN */
fDD_Info->dL_NRFreqInfo.nRARFCN = fdd->dl_freqinfo.arfcn; // Integer
/* FDD.2.2 F1AP_SUL_Information */
/* FDD.2.3 freqBandListNr */
int dl_bands = 1;
for (int j = 0; j < dl_bands; j++) {
asn1cSequenceAdd(fDD_Info->dL_NRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem);
/* FDD.2.3.1 freqBandIndicatorNr*/
nr_freqBandNrItem->freqBandIndicatorNr = fdd->dl_freqinfo.band;
/* FDD.2.3.2 supportedSULBandList*/
} // for FDD : DL freq_Bands
/* FDD.3 UL Transmission Bandwidth */
fDD_Info->uL_Transmission_Bandwidth.nRSCS = fdd->ul_tbw.scs;
fDD_Info->uL_Transmission_Bandwidth.nRNRB = to_NRNRB(fdd->ul_tbw.nrb);
/* FDD.4 DL Transmission Bandwidth */
fDD_Info->dL_Transmission_Bandwidth.nRSCS = fdd->dl_tbw.scs;
fDD_Info->dL_Transmission_Bandwidth.nRNRB = to_NRNRB(fdd->dl_tbw.nrb);
} else if (c->mode == F1AP_MODE_TDD) {
const f1ap_tdd_info_t *tdd = &c->tdd;
nR_Mode_Info->present = F1AP_NR_Mode_Info_PR_tDD;
asn1cCalloc(nR_Mode_Info->choice.tDD, tDD_Info);
/* TDD.1.1 nRFreqInfo ARFCN */
tDD_Info->nRFreqInfo.nRARFCN = tdd->freqinfo.arfcn;
/* TDD.1.2 F1AP_SUL_Information */
/* TDD.1.3 freqBandListNr */
int bands = 1;
for (int j = 0; j < bands; j++) {
asn1cSequenceAdd(tDD_Info->nRFreqInfo.freqBandListNr.list, F1AP_FreqBandNrItem_t, nr_freqBandNrItem);
/* TDD.1.3.1 freqBandIndicatorNr*/
nr_freqBandNrItem->freqBandIndicatorNr = tdd->freqinfo.band;
/* TDD.1.3.2 supportedSULBandList*/
}
/* TDD.2 transmission_Bandwidth */
tDD_Info->transmission_Bandwidth.nRSCS = tdd->tbw.scs;
tDD_Info->transmission_Bandwidth.nRNRB = to_NRNRB(tdd->tbw.nrb);
} else {
AssertFatal(false, "unknown mode %d\n", c->mode);
}
/* - measurementTimingConfiguration */
OCTET_STRING_fromBuf(&scell_info.measurementTimingConfiguration,
(const char *)c->measurement_timing_config,
c->measurement_timing_config_len);
return scell_info;
}
static F1AP_GNB_DU_System_Information_t *encode_system_info(const f1ap_gnb_du_system_info_t *sys_info)
{
if (sys_info == NULL)
return NULL; /* optional: can be NULL */
F1AP_GNB_DU_System_Information_t *enc_sys_info = calloc(1, sizeof(*enc_sys_info));
AssertFatal(enc_sys_info != NULL, "out of memory\n");
AssertFatal(sys_info->mib != NULL, "MIB must be present in DU sys info\n");
OCTET_STRING_fromBuf(&enc_sys_info->mIB_message, (const char *)sys_info->mib, sys_info->mib_length);
AssertFatal(sys_info->sib1 != NULL, "SIB1 must be present in DU sys info\n");
OCTET_STRING_fromBuf(&enc_sys_info->sIB1_message, (const char *)sys_info->sib1, sys_info->sib1_length);
return enc_sys_info;
}
/**
* @brief F1AP Setup Request
*/
......@@ -351,115 +203,24 @@ int DU_handle_F1_SETUP_FAILURE(instance_t instance, sctp_assoc_t assoc_id, uint3
return 0;
}
/*
gNB-DU Configuration Update
*/
int DU_send_gNB_DU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, const f1ap_gnb_du_configuration_update_t *upd)
/**
* @brief F1 gNB-DU Configuration Update: encoding and ITTI transmission
*/
int DU_send_gNB_DU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, f1ap_gnb_du_configuration_update_t *msg)
{
F1AP_F1AP_PDU_t pdu= {0};
uint8_t *buffer=NULL;
uint32_t len=0;
/* Create */
/* 0. Message Type */
pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
asn1cCalloc(pdu.choice.initiatingMessage, initMsg);
initMsg->procedureCode = F1AP_ProcedureCode_id_gNBDUConfigurationUpdate;
initMsg->criticality = F1AP_Criticality_reject;
initMsg->value.present = F1AP_InitiatingMessage__value_PR_GNBDUConfigurationUpdate;
F1AP_GNBDUConfigurationUpdate_t *out = &initMsg->value.choice.GNBDUConfigurationUpdate;
/* mandatory */
/* c1. Transaction ID (integer value) */
asn1cSequenceAdd(out->protocolIEs.list, F1AP_GNBDUConfigurationUpdateIEs_t, ie1);
ie1->id = F1AP_ProtocolIE_ID_id_TransactionID;
ie1->criticality = F1AP_Criticality_reject;
ie1->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_TransactionID;
ie1->value.choice.TransactionID = upd->transaction_id;
/* mandatory */
/* c2. Served_Cells_To_Add */
if (upd->num_cells_to_add > 0) {
AssertFatal(false, "code for adding cells not tested\n");
asn1cSequenceAdd(out->protocolIEs.list, F1AP_GNBDUConfigurationUpdateIEs_t, ie2);
ie2->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_List;
ie2->criticality = F1AP_Criticality_reject;
ie2->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Add_List;
for (int j = 0; j < upd->num_cells_to_add; j++) {
const f1ap_served_cell_info_t *cell = &upd->cell_to_add[j].info;
const f1ap_gnb_du_system_info_t *sys_info = upd->cell_to_add[j].sys_info;
asn1cSequenceAdd(ie2->value.choice.Served_Cells_To_Add_List.list,
F1AP_Served_Cells_To_Add_ItemIEs_t,
served_cells_to_add_item_ies);
served_cells_to_add_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Add_Item;
served_cells_to_add_item_ies->criticality = F1AP_Criticality_reject;
served_cells_to_add_item_ies->value.present = F1AP_Served_Cells_To_Add_ItemIEs__value_PR_Served_Cells_To_Add_Item;
F1AP_Served_Cells_To_Add_Item_t *served_cells_to_add_item =
&served_cells_to_add_item_ies->value.choice.Served_Cells_To_Add_Item;
served_cells_to_add_item->served_Cell_Information = encode_served_cell_info(cell);
served_cells_to_add_item->gNB_DU_System_Information = encode_system_info(sys_info);
}
}
/* mandatory */
/* c3. Served_Cells_To_Modify */
if (upd->num_cells_to_modify > 0) {
asn1cSequenceAdd(out->protocolIEs.list, F1AP_GNBDUConfigurationUpdateIEs_t, ie3);
ie3->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_List;
ie3->criticality = F1AP_Criticality_reject;
ie3->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Modify_List;
for (int i = 0; i < upd->num_cells_to_modify; i++) {
const f1ap_served_cell_info_t *cell = &upd->cell_to_modify[i].info;
const f1ap_gnb_du_system_info_t *sys_info = upd->cell_to_modify[i].sys_info;
asn1cSequenceAdd(ie3->value.choice.Served_Cells_To_Modify_List.list,
F1AP_Served_Cells_To_Modify_ItemIEs_t,
served_cells_to_modify_item_ies);
served_cells_to_modify_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Modify_Item;
served_cells_to_modify_item_ies->criticality = F1AP_Criticality_reject;
served_cells_to_modify_item_ies->value.present = F1AP_Served_Cells_To_Modify_ItemIEs__value_PR_Served_Cells_To_Modify_Item;
F1AP_Served_Cells_To_Modify_Item_t *served_cells_to_modify_item =
&served_cells_to_modify_item_ies->value.choice.Served_Cells_To_Modify_Item;
F1AP_NRCGI_t *oldNRCGI = &served_cells_to_modify_item->oldNRCGI;
const f1ap_plmn_t *old_plmn = &upd->cell_to_modify[i].old_plmn;
MCC_MNC_TO_PLMNID(old_plmn->mcc, old_plmn->mnc, old_plmn->mnc_digit_length, &oldNRCGI->pLMN_Identity);
NR_CELL_ID_TO_BIT_STRING(upd->cell_to_modify[i].old_nr_cellid, &oldNRCGI->nRCellIdentity);
served_cells_to_modify_item->served_Cell_Information = encode_served_cell_info(cell);
served_cells_to_modify_item->gNB_DU_System_Information = encode_system_info(sys_info);
}
}
/* mandatory */
/* c4. Served_Cells_To_Delete */
if (upd->num_cells_to_delete > 0) {
asn1cSequenceAdd(out->protocolIEs.list, F1AP_GNBDUConfigurationUpdateIEs_t, ie4);
ie4->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_List;
ie4->criticality = F1AP_Criticality_reject;
ie4->value.present = F1AP_GNBDUConfigurationUpdateIEs__value_PR_Served_Cells_To_Delete_List;
AssertFatal(upd->num_cells_to_delete == 0, "code for deleting cells not tested\n");
for (int i = 0; i < upd->num_cells_to_delete; i++) {
asn1cSequenceAdd(ie4->value.choice.Served_Cells_To_Delete_List.list,
F1AP_Served_Cells_To_Delete_ItemIEs_t,
served_cells_to_delete_item_ies);
served_cells_to_delete_item_ies->id = F1AP_ProtocolIE_ID_id_Served_Cells_To_Delete_Item;
served_cells_to_delete_item_ies->criticality = F1AP_Criticality_reject;
served_cells_to_delete_item_ies->value.present = F1AP_Served_Cells_To_Delete_ItemIEs__value_PR_Served_Cells_To_Delete_Item;
F1AP_Served_Cells_To_Delete_Item_t *served_cells_to_delete_item =
&served_cells_to_delete_item_ies->value.choice.Served_Cells_To_Delete_Item;
addnRCGI(served_cells_to_delete_item->oldNRCGI, &upd->cell_to_delete[i]);
}
}
AssertFatal(upd->gNB_DU_ID == 0, "encoding of gNB-DU Id not handled yet\n");
if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
/* encode F1AP message */
F1AP_F1AP_PDU_t *pdu = encode_f1ap_du_configuration_update(msg);
/* free anfter encoding */
free_f1ap_du_configuration_update(msg);
/* encode F1AP pdu */
if (f1ap_encode_pdu(pdu, &buffer, &len) < 0) {
LOG_E(F1AP, "Failed to encode F1 gNB-DU CONFIGURATION UPDATE\n");
return -1;
}
ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
/* transfer the message */
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
f1ap_itti_send_sctp_data_req(assoc_id, buffer, len);
return 0;
}
......
......@@ -51,7 +51,7 @@ int DU_handle_F1_SETUP_FAILURE(instance_t instance, sctp_assoc_t assoc_id, uint3
/*
* gNB-DU Configuration Update
*/
int DU_send_gNB_DU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, const f1ap_gnb_du_configuration_update_t *upd);
int DU_send_gNB_DU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, f1ap_gnb_du_configuration_update_t *msg);
/*
* gNB-CU Configuration Update
......
......@@ -51,51 +51,8 @@ static void gnb_du_configuration_update_direct(const f1ap_gnb_du_configuration_u
{
MessageDef *msg = itti_alloc_new_message(TASK_MAC_GNB, 0, F1AP_GNB_DU_CONFIGURATION_UPDATE);
msg->ittiMsgHeader.originInstance = -1; // means monolithic
f1ap_gnb_du_configuration_update_t *f1ap_msg = &F1AP_GNB_DU_CONFIGURATION_UPDATE(msg);
DevAssert(upd->gNB_DU_ID == NULL);
f1ap_msg->transaction_id = upd->transaction_id;
DevAssert(upd->num_cells_to_add == 0);
DevAssert(upd->num_cells_to_delete == 0);
f1ap_msg->num_cells_to_modify = upd->num_cells_to_modify;
for (int n = 0; n < upd->num_cells_to_modify; ++n) {
f1ap_msg->cell_to_modify[n].old_nr_cellid = upd->cell_to_modify[n].old_nr_cellid;
f1ap_msg->cell_to_modify[n].info = upd->cell_to_modify[n].info; // copy most fields
if (upd->cell_to_modify[n].info.tac) {
f1ap_msg->cell_to_modify[n].info.tac = malloc(sizeof(*f1ap_msg->cell_to_modify[n].info.tac));
AssertFatal(f1ap_msg->cell_to_modify[n].info.tac != NULL, "out of memory\n");
*f1ap_msg->cell_to_modify[n].info.tac = *upd->cell_to_modify[n].info.tac;
}
if (upd->cell_to_modify[n].info.measurement_timing_config_len > 0) {
f1ap_msg->cell_to_modify[n].info.measurement_timing_config =
calloc(upd->cell_to_modify[n].info.measurement_timing_config_len, sizeof(uint8_t));
AssertFatal(f1ap_msg->cell_to_modify[n].info.measurement_timing_config != NULL, "out of memory\n");
memcpy(f1ap_msg->cell_to_modify[n].info.measurement_timing_config,
upd->cell_to_modify[n].info.measurement_timing_config,
upd->cell_to_modify[n].info.measurement_timing_config_len);
f1ap_msg->cell_to_modify[n].info.measurement_timing_config_len = upd->cell_to_modify[n].info.measurement_timing_config_len;
}
if (upd->cell_to_modify[n].sys_info) {
f1ap_gnb_du_system_info_t *orig_sys_info = upd->cell_to_modify[n].sys_info;
f1ap_gnb_du_system_info_t *copy_sys_info = calloc(1, sizeof(*copy_sys_info));
AssertFatal(copy_sys_info != NULL, "out of memory\n");
f1ap_msg->cell_to_modify[n].sys_info = copy_sys_info;
copy_sys_info->mib = calloc(orig_sys_info->mib_length, sizeof(uint8_t));
AssertFatal(copy_sys_info->mib != NULL, "out of memory\n");
memcpy(copy_sys_info->mib, orig_sys_info->mib, orig_sys_info->mib_length);
copy_sys_info->mib_length = orig_sys_info->mib_length;
if (orig_sys_info->sib1_length > 0) {
copy_sys_info->sib1 = calloc(orig_sys_info->sib1_length, sizeof(uint8_t));
AssertFatal(copy_sys_info->sib1 != NULL, "out of memory\n");
memcpy(copy_sys_info->sib1, orig_sys_info->sib1, orig_sys_info->sib1_length);
copy_sys_info->sib1_length = orig_sys_info->sib1_length;
}
}
}
/* transfer to RRC via ITTI */
F1AP_GNB_DU_CONFIGURATION_UPDATE(msg) = cp_f1ap_du_configuration_update(upd);
itti_send_msg_to_task(TASK_RRC_GNB, 0, msg);
}
......
......@@ -78,34 +78,14 @@ static void f1_setup_request_f1ap(const f1ap_setup_req_t *req)
static void gnb_du_configuration_update_f1ap(const f1ap_gnb_du_configuration_update_t *upd)
{
MessageDef *msg = itti_alloc_new_message(TASK_MAC_GNB, 0, F1AP_GNB_DU_CONFIGURATION_UPDATE);
f1ap_gnb_du_configuration_update_t *f1_upd = &F1AP_GNB_DU_CONFIGURATION_UPDATE(msg);
f1_upd->transaction_id = upd->transaction_id;
AssertFatal(upd->num_cells_to_add == 0, "gNB-DU config update: cells to add not supported\n");
f1_upd->num_cells_to_modify = upd->num_cells_to_modify;
for (int n = 0; n < upd->num_cells_to_modify; ++n) {
f1_upd->cell_to_modify[n].old_plmn = upd->cell_to_modify[n].old_plmn;
f1_upd->cell_to_modify[n].old_nr_cellid = upd->cell_to_modify[n].old_nr_cellid;
f1_upd->cell_to_modify[n].info = upd->cell_to_modify[n].info;
if (upd->cell_to_modify[n].sys_info) {
f1ap_gnb_du_system_info_t *orig_sys_info = upd->cell_to_modify[n].sys_info;
f1ap_gnb_du_system_info_t *copy_sys_info = calloc(1, sizeof(*copy_sys_info));
f1_upd->cell_to_modify[n].sys_info = copy_sys_info;
copy_sys_info->mib = calloc(orig_sys_info->mib_length, sizeof(uint8_t));
AssertFatal(copy_sys_info->mib != NULL, "out of memory\n");
memcpy(copy_sys_info->mib, orig_sys_info->mib, orig_sys_info->mib_length);
copy_sys_info->mib_length = orig_sys_info->mib_length;
if (orig_sys_info->sib1_length > 0) {
copy_sys_info->sib1 = calloc(orig_sys_info->sib1_length, sizeof(uint8_t));
AssertFatal(copy_sys_info->sib1 != NULL, "out of memory\n");
memcpy(copy_sys_info->sib1, orig_sys_info->sib1, orig_sys_info->sib1_length);
copy_sys_info->sib1_length = orig_sys_info->sib1_length;
}
}
}
AssertFatal(upd->num_cells_to_delete == 0, "gNB-DU config update: cells to add not supported\n");
itti_send_msg_to_task(TASK_DU_F1, 0, msg);
/* copy F1AP message */
f1ap_gnb_du_configuration_update_t cp = cp_f1ap_du_configuration_update(upd);
/* transfer to ITTI message */
F1AP_GNB_DU_CONFIGURATION_UPDATE(msg) = cp;
/* free after copy */
free_f1ap_du_configuration_update(upd);
/* send to RRC task */
itti_send_msg_to_task(TASK_RRC_GNB, 0, msg);
}
static void ue_context_setup_response_f1ap(const f1ap_ue_context_setup_t *req, const f1ap_ue_context_setup_t *resp)
......
......@@ -516,8 +516,9 @@ void rrc_gNB_process_f1_du_configuration_update(f1ap_gnb_du_configuration_update
/* Send DU Configuration Acknowledgement */
f1ap_gnb_du_configuration_update_acknowledge_t ack = {.transaction_id = conf_up->transaction_id};
rrc->mac_rrc.gnb_du_configuration_update_acknowledge(assoc_id, &ack);
/* free F1AP message after use */
free_f1ap_du_configuration_update(conf_up);
}
void rrc_CU_process_f1_lost_connection(gNB_RRC_INST *rrc, f1ap_lost_connection_t *lc, sctp_assoc_t assoc_id)
......
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