Commit 80a05271 authored by Guido Casati's avatar Guido Casati

Use F1AP gNB-CU Configuration Update lib in stack

parent 36263662
......@@ -189,99 +189,27 @@ int CU_send_gNB_DU_CONFIGURATION_UPDATE_ACKNOWLEDGE(
return 0;
}
/*
gNB-CU Configuration Update
*/
int CU_send_gNB_CU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, f1ap_gnb_cu_configuration_update_t *f1ap_gnb_cu_configuration_update)
/**
* @brief F1 gNB-CU Configuration Update message encoding and transfer
*/
int CU_send_gNB_CU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, f1ap_gnb_cu_configuration_update_t *msg)
{
F1AP_F1AP_PDU_t pdu= {0};
/* complete F1AP message */
msg->transaction_id = F1AP_get_next_transaction_identifier(0, 0); // note: has to be done in the caller
uint8_t *buffer;
uint32_t len;
/* Create */
/* 0. Message Type */
pdu.present = F1AP_F1AP_PDU_PR_initiatingMessage;
asn1cCalloc(pdu.choice.initiatingMessage, initMsg);
initMsg->procedureCode = F1AP_ProcedureCode_id_gNBCUConfigurationUpdate;
initMsg->criticality = F1AP_Criticality_reject;
initMsg->value.present = F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate;
F1AP_GNBCUConfigurationUpdate_t *cfgUpdate = &pdu.choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate;
/* mandatory */
/* c1. Transaction ID (integer value) */
asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC1);
ieC1->id = F1AP_ProtocolIE_ID_id_TransactionID;
ieC1->criticality = F1AP_Criticality_reject;
ieC1->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID;
ieC1->value.choice.TransactionID = F1AP_get_next_transaction_identifier(0, 0);
// mandatory
// c2. Cells_to_be_Activated_List
if (f1ap_gnb_cu_configuration_update->num_cells_to_activate > 0) {
asn1cSequenceAdd(cfgUpdate->protocolIEs.list, F1AP_GNBCUConfigurationUpdateIEs_t, ieC3);
ieC3->id = F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List;
ieC3->criticality = F1AP_Criticality_reject;
ieC3->value.present = F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List;
for (int i=0; i<f1ap_gnb_cu_configuration_update->num_cells_to_activate; i++) {
asn1cSequenceAdd(ieC3->value.choice.Cells_to_be_Activated_List.list,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;
// 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;
// - nRCGI
addnRCGI(cells_to_be_activated_list_item->nRCGI, f1ap_gnb_cu_configuration_update->cells_to_activate+i);
// optional
// -nRPCI
asn1cCalloc(cells_to_be_activated_list_item->nRPCI, tmp);
*tmp = f1ap_gnb_cu_configuration_update->cells_to_activate[i].nrpci; // int 0..1007
// optional
// 3.1.2 gNB-CUSystem Information
F1AP_ProtocolExtensionContainer_10696P112_t *p = calloc(1,sizeof(*p));
cells_to_be_activated_list_item->iE_Extensions = (struct F1AP_ProtocolExtensionContainer *) p;
//F1AP_ProtocolExtensionContainer_154P112_t
asn1cSequenceAdd(p->list, F1AP_Cells_to_be_Activated_List_ItemExtIEs_t, cells_to_be_activated_itemExtIEs);
cells_to_be_activated_itemExtIEs->id = F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation;
cells_to_be_activated_itemExtIEs->criticality = F1AP_Criticality_reject;
cells_to_be_activated_itemExtIEs->extensionValue.present = F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation;
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;
//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]);
//printf("\n");
// for (int sIBtype=2;sIBtype<33;sIBtype++) { //21 ? 33 ?
for (int j = 0; j < sizeofArray(f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_msg); j++) {
f1ap_sib_msg_t *SI_msg = &f1ap_gnb_cu_configuration_update->cells_to_activate[i].SI_msg[j];
if (SI_msg->SI_container != NULL) {
asn1cSequenceAdd(gNB_CUSystemInformation->sibtypetobeupdatedlist.list, F1AP_SibtypetobeupdatedListItem_t, sib_item);
sib_item->sIBtype = SI_msg->SI_type;
AssertFatal(sib_item->sIBtype < 6 || sib_item->sIBtype == 9, "Illegal SI type %ld\n", sib_item->sIBtype);
OCTET_STRING_fromBuf(&sib_item->sIBmessage, (const char *)SI_msg->SI_container, SI_msg->SI_container_length);
LOG_D(F1AP,
"f1ap_gnb_cu_configuration_update->SI_container_length[%d][sIBtype %ld] = %d \n",
i,
sib_item->sIBtype,
SI_msg->SI_container_length);
}
}
}
}
}
/* encode */
if (f1ap_encode_pdu(&pdu, &buffer, &len) < 0) {
LOG_E(F1AP, "Failed to encode F1 gNB-CU CONFIGURATION UPDATE\n");
/* Encode F1 gNB-CU Configuration Update message */
F1AP_F1AP_PDU_t *pdu = encode_f1ap_cu_configuration_update(msg);
/* Free after encoding */
free_f1ap_cu_configuration_update(msg);
/* Encode F1AP PDU */
if (f1ap_encode_pdu(pdu, &buffer, &len) < 0) {
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
LOG_E(F1AP, "Failed to encode F1 gNB-CU Configuration Update\n");
return -1;
}
LOG_DUMPMSG(F1AP, LOG_DUMP_CHAR, buffer, len, "F1AP gNB-CU CONFIGURATION UPDATE : ");
ASN_STRUCT_RESET(asn_DEF_F1AP_F1AP_PDU, &pdu);
ASN_STRUCT_FREE(asn_DEF_F1AP_F1AP_PDU, pdu);
f1ap_itti_send_sctp_data_req(assoc_id, buffer, len);
return 0;
}
......
......@@ -225,148 +225,21 @@ int DU_send_gNB_DU_CONFIGURATION_UPDATE(sctp_assoc_t assoc_id, f1ap_gnb_du_confi
return 0;
}
/**
* @brief F1 gNB-CU Configuration Update decoding and message transfer
*/
int DU_handle_gNB_CU_CONFIGURATION_UPDATE(instance_t instance, sctp_assoc_t assoc_id, uint32_t stream, F1AP_F1AP_PDU_t *pdu)
{
LOG_D(F1AP, "DU_handle_gNB_CU_CONFIGURATION_UPDATE\n");
AssertFatal(pdu->present == F1AP_F1AP_PDU_PR_initiatingMessage,
"pdu->present != F1AP_F1AP_PDU_PR_initiatingMessage\n");
AssertFatal(pdu->choice.initiatingMessage->procedureCode == F1AP_ProcedureCode_id_gNBCUConfigurationUpdate,
"pdu->choice.initiatingMessage->procedureCode != F1AP_ProcedureCode_id_gNBCUConfigurationUpdate\n");
AssertFatal(pdu->choice.initiatingMessage->criticality == F1AP_Criticality_reject,
"pdu->choice.initiatingMessage->criticality != F1AP_Criticality_reject\n");
AssertFatal(pdu->choice.initiatingMessage->value.present == F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate,
"pdu->choice.initiatingMessage->value.present != F1AP_InitiatingMessage__value_PR_GNBCUConfigurationUpdate\n");
F1AP_GNBCUConfigurationUpdate_t *in = &pdu->choice.initiatingMessage->value.choice.GNBCUConfigurationUpdate;
F1AP_GNBCUConfigurationUpdateIEs_t *ie;
int TransactionId = -1;
int num_cells_to_activate = 0;
F1AP_Cells_to_be_Activated_List_Item_t *cell;
f1ap_gnb_cu_configuration_update_t in = {0};
if (!decode_f1ap_cu_configuration_update(pdu, &in)) {
LOG_E(F1AP, "Failed to decode F1AP Setup Failure\n");
free_f1ap_cu_configuration_update(&in);
return -1;
}
MessageDef *msg_p = itti_alloc_new_message (TASK_DU_F1, 0, F1AP_GNB_CU_CONFIGURATION_UPDATE);
LOG_D(F1AP, "F1AP: gNB_CU_Configuration_Update: protocolIEs.list.count %d\n",
in->protocolIEs.list.count);
for (int i=0; i < in->protocolIEs.list.count; i++) {
ie = in->protocolIEs.list.array[i];
switch (ie->id) {
case F1AP_ProtocolIE_ID_id_TransactionID:
AssertFatal(ie->criticality == F1AP_Criticality_reject,
"ie->criticality != F1AP_Criticality_reject\n");
AssertFatal(ie->value.present == F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID,
"ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_TransactionID\n");
TransactionId=ie->value.choice.TransactionID;
LOG_D(F1AP, "F1AP: GNB-CU-ConfigurationUpdate: TransactionId %d\n",
TransactionId);
break;
case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List: {
AssertFatal(ie->criticality == F1AP_Criticality_reject,
"ie->criticality != F1AP_Criticality_reject\n");
AssertFatal(ie->value.present == F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List,
"ie->value.present != F1AP_GNBCUConfigurationUpdateIEs__value_PR_Cells_to_be_Activated_List\n");
num_cells_to_activate = ie->value.choice.Cells_to_be_Activated_List.list.count;
LOG_D(F1AP, "F1AP: Activating %d cells\n",num_cells_to_activate);
for (int i=0; i<num_cells_to_activate; i++) {
F1AP_Cells_to_be_Activated_List_ItemIEs_t *cells_to_be_activated_list_item_ies = (F1AP_Cells_to_be_Activated_List_ItemIEs_t *) ie->value.choice.Cells_to_be_Activated_List.list.array[i];
AssertFatal(cells_to_be_activated_list_item_ies->id == F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item,
"cells_to_be_activated_list_item_ies->id != F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List_Item");
AssertFatal(cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject,
"cells_to_be_activated_list_item_ies->criticality == F1AP_Criticality_reject");
AssertFatal(cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item,
"cells_to_be_activated_list_item_ies->value.present == F1AP_Cells_to_be_Activated_List_ItemIEs__value_PR_Cells_to_be_Activated_List_Item");
cell = &cells_to_be_activated_list_item_ies->value.choice.Cells_to_be_Activated_List_Item;
TBCD_TO_MCC_MNC(&cell->nRCGI.pLMN_Identity,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].plmn.mcc,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].plmn.mnc,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].plmn.mnc_digit_length);
LOG_D(F1AP, "nr_cellId : %x %x %x %x %x\n",
cell->nRCGI.nRCellIdentity.buf[0],
cell->nRCGI.nRCellIdentity.buf[1],
cell->nRCGI.nRCellIdentity.buf[2],
cell->nRCGI.nRCellIdentity.buf[3],
cell->nRCGI.nRCellIdentity.buf[4]);
BIT_STRING_TO_NR_CELL_IDENTITY(&cell->nRCGI.nRCellIdentity,
F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nr_cellid);
F1AP_ProtocolExtensionContainer_10696P112_t *ext = (F1AP_ProtocolExtensionContainer_10696P112_t *)cell->iE_Extensions;
if (ext==NULL)
continue;
for (int cnt=0; cnt<ext->list.count; cnt++) {
F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *cells_to_be_activated_list_itemExtIEs=(F1AP_Cells_to_be_Activated_List_ItemExtIEs_t *)ext->list.array[cnt];
switch (cells_to_be_activated_list_itemExtIEs->id) {
/*
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_NOTHING:
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_GNB_CUSystemInformation,
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailablePLMNList,
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_ExtendedAvailablePLMN_List,
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_IAB_Info_IAB_donor_CU,
case F1AP_Cells_to_be_Activated_List_ItemExtIEs__extensionValue_PR_AvailableSNPN_ID_List
*/
case F1AP_ProtocolIE_ID_id_gNB_CUSystemInformation: {
F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].nrpci = (cell->nRPCI != NULL) ? *cell->nRPCI : 0;
F1AP_GNB_CUSystemInformation_t *gNB_CUSystemInformation = (F1AP_GNB_CUSystemInformation_t *)&cells_to_be_activated_list_itemExtIEs->extensionValue.choice.GNB_CUSystemInformation;
F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).cells_to_activate[i].num_SI = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count;
AssertFatal(ext->list.count==1,"At least one SI message should be there, and only 1 for now!\n");
LOG_D(F1AP,
"F1AP: Cell %d MCC %d MNC %d NRCellid %lx num_si %d\n",
i,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].plmn.mcc,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].plmn.mnc,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].nr_cellid,
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].num_SI);
for (int si = 0; si < gNB_CUSystemInformation->sibtypetobeupdatedlist.list.count; si++) {
F1AP_SibtypetobeupdatedListItem_t *sib_item = gNB_CUSystemInformation->sibtypetobeupdatedlist.list.array[si];
size_t size = sib_item->sIBmessage.size;
f1ap_sib_msg_t *SI_msg = &F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).cells_to_activate[i].SI_msg[si];
SI_msg->SI_container_length = size;
LOG_D(F1AP, "F1AP: SI_container_length[%d][%ld] %ld bytes\n", i, sib_item->sIBtype, size);
SI_msg->SI_container = malloc(SI_msg->SI_container_length);
memcpy((void *)SI_msg->SI_container, (void *)sib_item->sIBmessage.buf, size);
SI_msg->SI_type = sib_item->sIBtype;
}
break;
}
case F1AP_ProtocolIE_ID_id_AvailablePLMNList:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n");
break;
case F1AP_ProtocolIE_ID_id_ExtendedAvailablePLMN_List:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n");
break;
case F1AP_ProtocolIE_ID_id_IAB_Info_IAB_donor_CU:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n");
break;
case F1AP_ProtocolIE_ID_id_AvailableSNPN_ID_List:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id_AvailablePLMNList not supported yet\n");
break;
default:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id %d unknown\n",(int)cells_to_be_activated_list_itemExtIEs->id);
break;
}
} // for (cnt=...
} // for (cells_to_activate...
break;
} // case F1AP_ProtocolIE_ID_id_Cells_to_be_Activated_List
default:
AssertFatal(1==0,"F1AP_ProtocolIE_ID_id %d unknown\n", (int)ie->id);
break;
} // switch ie
} // for IE
AssertFatal(TransactionId!=-1,"TransactionId was not sent\n");
LOG_D(F1AP,"F1AP: num_cells_to_activate %d\n",num_cells_to_activate);
F1AP_GNB_CU_CONFIGURATION_UPDATE (msg_p).num_cells_to_activate = num_cells_to_activate;
f1ap_gnb_cu_configuration_update_t *msg = &F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p); // RRC thread will free it
*msg = in; // copy F1 message to ITTI
LOG_D(F1AP, "Sending F1AP_GNB_CU_CONFIGURATION_UPDATE ITTI message \n");
itti_send_msg_to_task(TASK_GNB_APP, GNB_MODULE_ID_TO_INSTANCE(assoc_id), msg_p);
return 0;
......
......@@ -236,6 +236,10 @@ void *gNB_app_task(void *args_p)
case F1AP_GNB_CU_CONFIGURATION_UPDATE:
AssertFatal(NODE_IS_DU(node_type), "Should not have received F1AP_GNB_CU_CONFIGURATION_UPDATE in CU/gNB\n");
LOG_I(GNB_APP,
"Received %s: associated with %d cells to activate\n",
ITTI_MSG_NAME(msg_p),
F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).num_cells_to_activate);
cell_to_activate += F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p).num_cells_to_activate;
gNB_app_handle_f1ap_gnb_cu_configuration_update(&F1AP_GNB_CU_CONFIGURATION_UPDATE(msg_p));
......
......@@ -94,6 +94,7 @@
#ifdef ENABLE_AERIAL
#include "nfapi/oai_integration/aerial/fapi_vnf_p5.h"
#endif
#include "lib/f1ap_interface_management.h"
extern uint16_t sf_ahead;
......@@ -2375,6 +2376,8 @@ int gNB_app_handle_f1ap_gnb_cu_configuration_update(f1ap_gnb_cu_configuration_up
}
}
NR_SCHED_UNLOCK(&mac->sched_lock);
/* Free F1AP struct after use */
free_f1ap_cu_configuration_update(gnb_cu_cfg_update);
MessageDef *msg_ack_p = NULL;
if (ret > 0) {
// generate gNB_CU_CONFIGURATION_UPDATE_ACKNOWLEDGE
......
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