Commit be5c3d7a authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/refactor-nr-rrc-du' into integration_2023_w15

parents 04451c70 8aa0aa4d
......@@ -340,8 +340,6 @@ At Rx side, pdcp_data_ind() is the entry point that receives the data from RLC.
nr_pdcp_config_set_security(): sets the keys for AS security of a UE
nr_DRB_preconfiguration(): the mac layer calls this for configuration in phy-test/do-ra mode
nr_pdcp_add_srbs() adds UE SRBs in pdcp, nr_pdcp_remove_UE() removes it
nr_pdcp_add_drbs() adds UE DRBs in pdcp, nr_pdcp_remove_UE() removes it
......
......@@ -84,21 +84,11 @@ int nr_rlc_get_available_tx_space(const rnti_t rntiP, const logical_chan_id_t ch
return 0;
}
void nr_rlc_bearer_init(NR_RLC_BearerConfig_t *RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR rb_type)
{
abort();
}
void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP, NR_CellGroupConfig_t *cell_groupConfig_from_DU)
{
abort();
}
void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig)
{
abort();
}
void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig)
{
abort();
......@@ -110,11 +100,6 @@ int nr_rrc_gNB_process_GTPV1U_CREATE_TUNNEL_RESP(const protocol_ctxt_t *const ct
return 0;
}
void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr)
{
abort();
}
void prepare_and_send_ue_context_modification_f1(rrc_gNB_ue_context_t *ue_context_p, e1ap_bearer_setup_resp_t *e1ap_resp)
{
abort();
......
......@@ -58,7 +58,7 @@
//#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "NR_asn_constant.h"
#include "RRC/NR/MESSAGES/asn1_msg.h"
#include "RRC/NR/nr_rrc_config.h"
#include "openair1/SIMULATION/RF/rf.h"
#include "openair1/SIMULATION/TOOLS/sim.h"
#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
......@@ -641,8 +641,6 @@ int main(int argc, char **argv)
RC.nb_nr_mac_CC[i] = 1;
mac_top_init_gNB(ngran_gNB);
gNB_mac = RC.nrmac[0];
gNB_RRC_INST rrc;
memset((void*)&rrc,0,sizeof(rrc));
gNB_mac->dl_bler.harq_round_max = num_rounds;
......@@ -688,20 +686,16 @@ int main(int argc, char **argv)
NR_ServingCellConfigCommon_t *scc = secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon;
*/
NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc));;
prepare_scc(scc);
uint64_t ssb_bitmap = 1; // Enable only first SSB with index ssb_indx=0
fill_scc_sim(scc, &ssb_bitmap, N_RB_DL, N_RB_DL, mu, mu);
fix_scc(scc, ssb_bitmap);
rrc.carrier.servingcellconfigcommon = calloc(1,sizeof(*rrc.carrier.servingcellconfigcommon));
NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
NR_ServingCellConfig_t *scd = calloc(1,sizeof(NR_ServingCellConfig_t));
NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
prepare_scc(rrc.carrier.servingcellconfigcommon);
uint64_t ssb_bitmap = 1;
fill_scc_sim(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
ssb_bitmap = 1;// Enable only first SSB with index ssb_indx=0
fix_scc(scc,ssb_bitmap);
NR_ServingCellConfig_t *scd = calloc(1,sizeof(*scd));
prepare_scd(scd);
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts;
rrc_pdsch_AntennaPorts_t pdsch_AntennaPorts = {0};
pdsch_AntennaPorts.N1 = n_tx>1 ? n_tx>>1 : 1;
pdsch_AntennaPorts.N2 = 1;
pdsch_AntennaPorts.XP = n_tx>1 ? 2 : 1;
......@@ -723,10 +717,11 @@ int main(int argc, char **argv)
.do_SRS = 0,
.force_256qam_off = false
};
fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, UE_Capability_nr, 0, 1, &conf, 0);
NR_CellGroupConfig_t *secondaryCellGroup = get_default_secondaryCellGroup(scc, scd, UE_Capability_nr, 0, 1, &conf, 0);
/* RRC parameter validation for secondaryCellGroup */
fix_scd(scd);
/* -U option modify DMRS */
if(modify_dmrs) {
update_dmrs_config(secondaryCellGroup, dmrs_arg);
......@@ -891,11 +886,8 @@ int main(int argc, char **argv)
AssertFatal(input_fd==NULL,"Not ready for input signal file\n");
//Configure UE
rrc.carrier.MIB = (uint8_t*) malloc(4);
rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
nr_rrc_mac_config_req_ue(0,0,0,rrc.carrier.mib.message.choice.mib, NULL, NULL, secondaryCellGroup);
NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc);
nr_rrc_mac_config_req_ue(0, 0, 0, mib->message.choice.mib, NULL, NULL, secondaryCellGroup);
nr_dcireq_t dcireq;
nr_scheduled_response_t scheduled_response;
......
......@@ -53,7 +53,7 @@
#include "openair1/SIMULATION/TOOLS/sim.h"
#include "openair1/SIMULATION/RF/rf.h"
#include "openair1/SIMULATION/NR_PHY/nr_unitary_defs.h"
#include "openair2/RRC/NR/MESSAGES/asn1_msg.h"
#include "openair2/RRC/NR/nr_rrc_config.h"
#include "openair2/LAYER2/NR_MAC_UE/mac_proto.h"
#include "openair2/LAYER2/NR_MAC_gNB/mac_proto.h"
#include "common/utils/threadPool/thread-pool.h"
......@@ -621,21 +621,14 @@ int main(int argc, char **argv)
for (i = 0; i < RC.nb_nr_macrlc_inst; i++)
RC.nb_nr_mac_CC[i] = 1;
mac_top_init_gNB(ngran_gNB);
//gNB_MAC_INST* gNB_mac = RC.nrmac[0];
gNB_RRC_INST rrc;
memset((void*)&rrc,0,sizeof(rrc));
rrc.carrier.servingcellconfigcommon = calloc(1,sizeof(*rrc.carrier.servingcellconfigcommon));
NR_ServingCellConfigCommon_t *scc = rrc.carrier.servingcellconfigcommon;
NR_ServingCellConfig_t *scd = calloc(1,sizeof(NR_ServingCellConfig_t));
NR_CellGroupConfig_t *secondaryCellGroup=calloc(1,sizeof(*secondaryCellGroup));
prepare_scc(rrc.carrier.servingcellconfigcommon);
NR_ServingCellConfigCommon_t *scc = calloc(1,sizeof(*scc));;
prepare_scc(scc);
uint64_t ssb_bitmap;
fill_scc_sim(rrc.carrier.servingcellconfigcommon,&ssb_bitmap,N_RB_DL,N_RB_DL,mu,mu);
fill_scc_sim(scc, &ssb_bitmap, N_RB_DL, N_RB_DL, mu, mu);
fix_scc(scc,ssb_bitmap);
NR_ServingCellConfig_t *scd = calloc(1,sizeof(NR_ServingCellConfig_t));
prepare_scd(scd);
// TODO do a UECAP for phy-sim
......@@ -647,19 +640,19 @@ int main(int argc, char **argv)
.do_SRS = 0,
.force_256qam_off = false
};
fill_default_secondaryCellGroup(scc, scd, secondaryCellGroup, NULL, 0, 1, &conf, 0);
// xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
NR_CellGroupConfig_t *secondaryCellGroup = get_default_secondaryCellGroup(scc, scd, NULL, 0, 1, &conf, 0);
/* RRC parameter validation for secondaryCellGroup */
fix_scd(scd);
NR_BCCH_BCH_Message_t *mib = get_new_MIB_NR(scc);
AssertFatal((gNB->if_inst = NR_IF_Module_init(0))!=NULL,"Cannot register interface");
gNB->if_inst->NR_PHY_config_req = nr_phy_config_request;
// common configuration
nr_mac_config_scc(RC.nrmac[0], conf.pdsch_AntennaPorts, n_tx, 0, 6, scc);
nr_mac_config_mib(RC.nrmac[0], &rrc.carrier.mib);
nr_mac_config_mib(RC.nrmac[0], mib);
// UE dedicated configuration
nr_mac_add_test_ue(RC.nrmac[0], secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, secondaryCellGroup);
frame_parms->nb_antennas_tx = 1;
......@@ -731,12 +724,9 @@ int main(int argc, char **argv)
}
//Configure UE
NR_UE_RRC_INST_t rrcue;
memset(&rrcue,0,sizeof(NR_UE_RRC_INST_t));
rrc.carrier.MIB = (uint8_t*) malloc(4);
rrc.carrier.sizeof_MIB = do_MIB_NR(&rrc,0);
rrcue.mib = rrc.carrier.mib.message.choice.mib;
rrcue.scell_group_config=secondaryCellGroup;
NR_UE_RRC_INST_t rrcue = {0};
rrcue.mib = mib->message.choice.mib;
rrcue.scell_group_config = secondaryCellGroup;
nr_l2_init_ue(&rrcue);
NR_UE_MAC_INST_t* UE_mac = get_mac_inst(0);
......@@ -1670,7 +1660,8 @@ int main(int argc, char **argv)
mapping_type,
length_dmrs,
num_dmrs_cdm_grps_no_data);
free_MIB_NR(mib);
free(test_input_bit);
free(estimated_output_bit);
if (gNB->ldpc_offload_flag)
......
......@@ -691,7 +691,7 @@ void RCconfig_nr_prs(void)
}
else
{
LOG_E(PHY,"No " CONFIG_STRING_PRS_CONFIG " configuration found..!!\n");
LOG_I(PHY,"No " CONFIG_STRING_PRS_CONFIG " configuration found..!!\n");
}
}
......@@ -1896,8 +1896,12 @@ int RCconfig_NR_DU_F1(MessageDef *msg_p, uint32_t i) {
f1Setup->measurement_timing_information[k] = "0";
f1Setup->ranac[k] = 0;
f1Setup->mib[k] = rrc->carrier.MIB;
f1Setup->mib_length[k] = rrc->carrier.sizeof_MIB;
DevAssert(rrc->carrier.mib != NULL);
int buf_len = 3; // this is what we assume in monolithic
f1Setup->mib[k] = calloc(buf_len, sizeof(*f1Setup->mib[k]));
DevAssert(f1Setup->mib[k] != NULL);
f1Setup->mib_length[k] = encode_MIB_NR(rrc->carrier.mib, 0, f1Setup->mib[k], buf_len);
DevAssert(f1Setup->mib_length[k] == buf_len);
NR_BCCH_DL_SCH_Message_t *bcch_message = NULL;
asn_codec_ctx_t st={100*1000};
......
......@@ -35,10 +35,11 @@
#include "radio/COMMON/common_lib.h"
//#undef MALLOC
#include "assertions.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_entity.h"
#include "executables/softmodem-common.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_oai_api.h"
#include "nr_rlc/nr_rlc_oai_api.h"
#include "RRC/NR/MESSAGES/asn1_msg.h"
#include <pthread.h>
static NR_UE_MAC_INST_t *nr_ue_mac_inst;
......@@ -66,9 +67,22 @@ NR_UE_MAC_INST_t * nr_l2_init_ue(NR_UE_RRC_INST_t* rrc_inst) {
nr_rrc_mac_config_req_ue(0,0,0,NULL,NULL,NULL,rrc_inst->scell_group_config);
AssertFatal(rlc_module_init(0) == 0, "%s: Could not initialize RLC layer\n", __FUNCTION__);
if (IS_SOFTMODEM_NOS1){
// get default noS1 configuration
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = &rlc_rbconfig, .count = 1, .size = 1, }
};
// set up PDCP, RLC, MAC
nr_pdcp_layer_init();
nr_DRB_preconfiguration(nr_ue_mac_inst->crnti);
nr_pdcp_add_drbs(ENB_FLAG_NO, nr_ue_mac_inst->crnti, 0, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_rlc_add_drb(nr_ue_mac_inst->crnti, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
nr_ue_mac_inst->logicalChannelBearer_exist[0] = true;
// free memory
free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
}
// Allocate memory for ul_config_request in the mac instance. This is now a pointer and will
// point to a list of structures (one for each UL slot) to store PUSCH scheduling parameters
......
......@@ -54,10 +54,10 @@ extern RAN_CONTEXT_t RC;
//extern int l2_init_gNB(void);
extern uint8_t nfapi_mode;
void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_bearer2release_list,
NR_UE_sched_ctrl_t *sched_ctrl) {
static void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *rlc_bearer2add_list,
struct NR_CellGroupConfig__rlc_BearerToReleaseList *rlc_bearer2release_list,
NR_UE_sched_ctrl_t *sched_ctrl)
{
if (rlc_bearer2release_list) {
for (int i = 0; i < rlc_bearer2release_list->list.count; i++) {
for (int idx = 0; idx < sched_ctrl->dl_lc_num; idx++) {
......@@ -97,8 +97,9 @@ void process_rlcBearerConfig(struct NR_CellGroupConfig__rlc_BearerToAddModList *
}
static void process_drx_Config(NR_UE_sched_ctrl_t *sched_ctrl, NR_SetupRelease_DRX_Config_t *drx_Config)
{
void process_drx_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_DRX_Config_t *drx_Config) {
if (!drx_Config) return;
AssertFatal(drx_Config->present != NR_SetupRelease_DRX_Config_PR_NOTHING, "Cannot have NR_SetupRelease_DRX_Config_PR_NOTHING\n");
......@@ -110,23 +111,27 @@ void process_drx_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_DRX_Confi
}
}
void process_schedulingRequestConfig(NR_UE_sched_ctrl_t *sched_ctrl,NR_SchedulingRequestConfig_t *schedulingRequestConfig) {
static void process_schedulingRequestConfig(NR_UE_sched_ctrl_t *sched_ctrl, NR_SchedulingRequestConfig_t *schedulingRequestConfig)
{
if (!schedulingRequestConfig) return;
LOG_I(NR_MAC,"Adding SchedulingRequestconfig\n");
}
void process_bsrConfig(NR_UE_sched_ctrl_t *sched_ctrl,NR_BSR_Config_t *bsr_Config) {
static void process_bsrConfig(NR_UE_sched_ctrl_t *sched_ctrl, NR_BSR_Config_t *bsr_Config)
{
if (!bsr_Config) return;
LOG_I(NR_MAC,"Adding BSR config\n");
}
void process_tag_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_TAG_Config_t *tag_Config) {
static void process_tag_Config(NR_UE_sched_ctrl_t *sched_ctrl, NR_TAG_Config_t *tag_Config)
{
if (!tag_Config) return;
LOG_I(NR_MAC,"Adding TAG config\n");
}
void process_phr_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_PHR_Config_t *phr_Config) {
static void process_phr_Config(NR_UE_sched_ctrl_t *sched_ctrl, NR_SetupRelease_PHR_Config_t *phr_Config)
{
if (!phr_Config) return;
AssertFatal(phr_Config->present != NR_SetupRelease_PHR_Config_PR_NOTHING, "Cannot have NR_SetupRelease_PHR_Config_PR_NOTHING\n");
......@@ -138,8 +143,8 @@ void process_phr_Config(NR_UE_sched_ctrl_t *sched_ctrl,NR_SetupRelease_PHR_Confi
}
}
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl) {
void process_CellGroup(NR_CellGroupConfig_t *CellGroup, NR_UE_sched_ctrl_t *sched_ctrl)
{
AssertFatal(CellGroup, "CellGroup is null\n");
NR_MAC_CellGroupConfig_t *mac_CellGroupConfig = CellGroup->mac_CellGroupConfig;
......
......@@ -38,7 +38,7 @@
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "UTIL/OPT/opt.h"
#include "RRC/NR/nr_rrc_extern.h"
#include "RRC/NR/nr_rrc_config.h"
#include "common/utils/nr/nr_common.h"
......@@ -94,7 +94,7 @@ void schedule_nr_mib(module_id_t module_idP, frame_t frameP, sub_frame_t slotP,
gNB_MAC_INST *gNB = RC.nrmac[module_idP];
NR_COMMON_channels_t *cc;
nfapi_nr_dl_tti_request_body_t *dl_req;
NR_MIB_t *mib = RC.nrrrc[module_idP]->carrier.mib.message.choice.mib;
NR_MIB_t *mib = RC.nrrrc[module_idP]->carrier.mib->message.choice.mib;
uint8_t num_tdd_period,num_ssb;
int mib_sdu_length;
int CC_id;
......
......@@ -2491,8 +2491,6 @@ void reset_ul_harq_list(NR_UE_sched_ctrl_t *sched_ctrl) {
void mac_remove_nr_ue(gNB_MAC_INST *nr_mac, rnti_t rnti)
{
nr_rlc_remove_ue(rnti);
NR_UEs_t *UE_info = &nr_mac->UE_info;
pthread_mutex_lock(&UE_info->mutex);
UE_iterator(UE_info->list, UE) {
......@@ -2894,24 +2892,16 @@ void send_initial_ul_rrc_message(gNB_MAC_INST *mac, int rnti, const uint8_t *sdu
NR_UE_info_t *UE = (NR_UE_info_t *)rawUE;
uint8_t du2cu_rrc_container[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
UE->CellGroup,
du2cu_rrc_container,
sizeof(du2cu_rrc_container));
AssertFatal(enc_rval.encoded > 0,
"Could not encode cellGroupConfig for UE %04x, failed element %s\n",
rnti,
enc_rval.failed_type->name);
uint8_t du2cu[1024];
int encoded = encode_cellGroupConfig(UE->CellGroup, du2cu, sizeof(du2cu));
const f1ap_initial_ul_rrc_message_t ul_rrc_msg = {
/* TODO: add mcc, mnc, cell_id, ..., is not available at MAC yet */
.crnti = rnti,
.rrc_container = (uint8_t *) sdu,
.rrc_container_length = sdu_len,
.du2cu_rrc_container = (uint8_t *) du2cu_rrc_container,
.du2cu_rrc_container_length = (enc_rval.encoded + 7) / 8
.du2cu_rrc_container = (uint8_t *) du2cu,
.du2cu_rrc_container_length = encoded
};
mac->mac_rrc.initial_ul_rrc_message_transfer(0, &ul_rrc_msg);
}
......@@ -2925,20 +2915,7 @@ void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE)
gNB_RRC_INST *rrc = RC.nrrrc[mod_id];
const NR_ServingCellConfigCommon_t *scc = rrc->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = rrc->configuration.scd;
NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(*cellGroupConfig));
AssertFatal(cellGroupConfig != NULL, "out of memory\n");
fill_initial_cellGroupConfig(UE->uid, cellGroupConfig, scc, sccd, &rrc->configuration);
uint8_t du2cu_rrc_container[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
cellGroupConfig,
du2cu_rrc_container,
sizeof(du2cu_rrc_container));
AssertFatal(enc_rval.encoded > 0,
"Could not encode cellGroupConfig for UE %04x, failed element %s\n",
UE->rnti,
enc_rval.failed_type->name);
NR_CellGroupConfig_t *cellGroupConfig = get_initial_cellGroupConfig(UE->uid, scc, sccd, &rrc->configuration);
UE->CellGroup = cellGroupConfig;
nr_mac_update_cellgroup(mac, UE->rnti, cellGroupConfig);
......
......@@ -37,6 +37,8 @@
#include "RRC/NR/nr_rrc_defs.h"
#include "common/utils/LOG/log.h"
#include "nr_rlc/nr_rlc_oai_api.h"
#include "RRC/NR/MESSAGES/asn1_msg.h"
//#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
#include "common/ran_context.h"
......@@ -251,8 +253,30 @@ void mac_top_init_gNB(ngran_node_t node_type)
// These should be out of here later
if (get_softmodem_params()->usim_test == 0 ) nr_pdcp_layer_init();
if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->phy_test)
nr_DRB_preconfiguration(0x1234);
if(IS_SOFTMODEM_NOS1 && get_softmodem_params()->phy_test) {
// get default noS1 configuration
NR_RadioBearerConfig_t *rbconfig = NULL;
NR_RLC_BearerConfig_t *rlc_rbconfig = NULL;
fill_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
NR_RLC_BearerConfig_t *rlc_rbconfig_list[1] = {rlc_rbconfig};
struct NR_CellGroupConfig__rlc_BearerToAddModList rlc_bearer_list = {
.list = { .array = rlc_rbconfig_list, .count = 1, .size = 1, }
};
/* Note! previously, in nr_DRB_preconfiguration(), we passed ENB_FLAG_NO
* if ENB_NAS_USE_TUN was *not* set. It seems to me that we could not set
* this flag anywhere in the code, hence we would always configure PDCP
* with ENB_FLAG_NO in nr_DRB_preconfiguration(). This makes sense for
* noS1, because the result of passing ENB_FLAG_NO to PDCP is that PDCP
* will output the packets at a local interface, which is in line with
* the noS1 mode. Hence, below, we simply hardcode ENB_FLAG_NO */
// setup PDCP, RLC
nr_pdcp_add_drbs(ENB_FLAG_NO, 0x1234, 0, rbconfig->drb_ToAddModList, 0, NULL, NULL, &rlc_bearer_list);
nr_rlc_add_drb(0x1234, rbconfig->drb_ToAddModList->list.array[0]->drb_Identity, rlc_rbconfig);
// free memory
free_nr_noS1_bearer_config(&rbconfig, &rlc_rbconfig);
}
} else {
RC.nrmac = NULL;
......
......@@ -26,6 +26,5 @@
#define _NR_PDCP_H_
void nr_pdcp_layer_init_ue(void);
void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid);
#endif /* _NR_PDCP_H_ */
......@@ -187,6 +187,4 @@ nr_pdcp_entity_t *new_nr_pdcp_entity(
unsigned char *ciphering_key,
unsigned char *integrity_key);
void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid);
#endif /* _NR_PDCP_ENTITY_H_ */
......@@ -962,78 +962,6 @@ bool rrc_pdcp_config_asn1_req(const protocol_ctxt_t *const ctxt_pP,
return 0;
}
void nr_DRB_preconfiguration(ue_id_t crntiMaybeUEid)
{
NR_RadioBearerConfig_t *rbconfig = NULL;
struct NR_CellGroupConfig__rlc_BearerToAddModList *Rlc_Bearer_ToAdd_list = NULL;
protocol_ctxt_t ctxt;
//fill_default_rbconfig(rb_config, 5, 1);
rbconfig = calloc(1, sizeof(*rbconfig));
rbconfig->srb_ToAddModList = NULL;
rbconfig->srb3_ToRelease = NULL;
rbconfig->drb_ToAddModList = calloc(1,sizeof(*rbconfig->drb_ToAddModList));
NR_DRB_ToAddMod_t *drb_ToAddMod = calloc(1,sizeof(*drb_ToAddMod));
drb_ToAddMod->cnAssociation = calloc(1,sizeof(*drb_ToAddMod->cnAssociation));
drb_ToAddMod->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity;
drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= 10;
drb_ToAddMod->drb_Identity = 1;
drb_ToAddMod->reestablishPDCP = NULL;
drb_ToAddMod->recoverPDCP = NULL;
drb_ToAddMod->pdcp_Config = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config));
asn1cCalloc(drb_ToAddMod->pdcp_Config->drb, drb);
asn1cCallocOne(drb->discardTimer, NR_PDCP_Config__drb__discardTimer_infinity);
asn1cCallocOne(drb->pdcp_SN_SizeUL, NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits);
asn1cCallocOne(drb->pdcp_SN_SizeDL, NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits);
drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drb->headerCompression.choice.notUsed = 0;
drb->integrityProtection = NULL;
drb->statusReportRequired = NULL;
drb->outOfOrderDelivery = NULL;
drb_ToAddMod->pdcp_Config->moreThanOneRLC = NULL;
asn1cCallocOne(drb_ToAddMod->pdcp_Config->t_Reordering, NR_PDCP_Config__t_Reordering_ms0);
drb_ToAddMod->pdcp_Config->ext1 = NULL;
asn1cSeqAdd(&rbconfig->drb_ToAddModList->list,drb_ToAddMod);
rbconfig->drb_ToReleaseList = NULL;
asn1cCalloc(rbconfig->securityConfig, secConf);
asn1cCalloc(secConf->securityAlgorithmConfig, secConfAlgo);
secConfAlgo->cipheringAlgorithm = NR_CipheringAlgorithm_nea0;
secConfAlgo->integrityProtAlgorithm = NULL;
asn1cCallocOne(secConf->keyToUse, NR_SecurityConfig__keyToUse_master);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)rbconfig);
}
NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig));
nr_rlc_bearer_init(RLC_BearerConfig,NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity);
nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional);
//nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am);
nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig);
Rlc_Bearer_ToAdd_list = calloc(1,sizeof(*Rlc_Bearer_ToAdd_list));
asn1cSeqAdd(&Rlc_Bearer_ToAdd_list->list, RLC_BearerConfig);
if (ENB_NAS_USE_TUN){
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_YES, crntiMaybeUEid, 0, 0, 0);
}
else{
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, 0, ENB_FLAG_NO, crntiMaybeUEid, 0, 0, 0);
}
nr_pdcp_add_drbs(ctxt.enb_flag, ctxt.rntiMaybeUEid, 0, rbconfig->drb_ToAddModList, 0, NULL, NULL, Rlc_Bearer_ToAdd_list);
nr_rlc_add_drb(ctxt.rntiMaybeUEid, drb_ToAddMod->drb_Identity, RLC_BearerConfig);
LOG_D(PDCP, "%s:%d: done RRC PDCP/RLC ASN1 request for UE ID/RNTI %ld\n", __FUNCTION__, __LINE__, ctxt.rntiMaybeUEid);
}
uint64_t get_pdcp_optmask(void)
{
return pdcp_optmask;
......
......@@ -54,84 +54,6 @@ static int nr_rlc_current_time_last_frame;
static int nr_rlc_current_time_last_subframe;
void nr_rlc_bearer_init(NR_RLC_BearerConfig_t *RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR rb_type){
RLC_BearerConfig->servedRadioBearer = calloc(1, sizeof(*RLC_BearerConfig->servedRadioBearer));
RLC_BearerConfig->reestablishRLC = calloc(1, sizeof(*RLC_BearerConfig->reestablishRLC));
RLC_BearerConfig->rlc_Config = calloc(1, sizeof(*RLC_BearerConfig->rlc_Config));
RLC_BearerConfig->mac_LogicalChannelConfig = calloc(1, sizeof(*RLC_BearerConfig->mac_LogicalChannelConfig));
*RLC_BearerConfig->reestablishRLC = NR_RLC_BearerConfig__reestablishRLC_true;
if(rb_type == NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity){
RLC_BearerConfig->logicalChannelIdentity = 4;
RLC_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity;
RLC_BearerConfig->servedRadioBearer->choice.drb_Identity = 1;
}
else{
RLC_BearerConfig->logicalChannelIdentity = 1;
RLC_BearerConfig->servedRadioBearer->present = NR_RLC_BearerConfig__servedRadioBearer_PR_srb_Identity;
RLC_BearerConfig->servedRadioBearer->choice.srb_Identity = 1;
}
}
void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig){
mac_LogicalChannelConfig->ul_SpecificParameters = calloc(1, sizeof(*mac_LogicalChannelConfig->ul_SpecificParameters));
mac_LogicalChannelConfig->ul_SpecificParameters->priority = 1;
mac_LogicalChannelConfig->ul_SpecificParameters->prioritisedBitRate = NR_LogicalChannelConfig__ul_SpecificParameters__prioritisedBitRate_infinity;
mac_LogicalChannelConfig->ul_SpecificParameters->bucketSizeDuration = NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms50;
mac_LogicalChannelConfig->ul_SpecificParameters->allowedServingCells = NULL;
mac_LogicalChannelConfig->ul_SpecificParameters->allowedSCS_List = NULL;
mac_LogicalChannelConfig->ul_SpecificParameters->maxPUSCH_Duration = NULL;
mac_LogicalChannelConfig->ul_SpecificParameters->configuredGrantType1Allowed = NULL;
mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = calloc(1,sizeof(*mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup));
*mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelGroup = 1;
mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = calloc(1,sizeof(*mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID));
*mac_LogicalChannelConfig->ul_SpecificParameters->schedulingRequestID = 0;
mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_Mask = false;
mac_LogicalChannelConfig->ul_SpecificParameters->logicalChannelSR_DelayTimerApplied = false;
mac_LogicalChannelConfig->ul_SpecificParameters->bitRateQueryProhibitTimer = NULL;
}
void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr){
switch (rlc_config_pr){
case NR_RLC_Config_PR_um_Bi_Directional:
// RLC UM Bi-directional Bearer configuration
LOG_I(RLC, "RLC UM Bi-directional Bearer configuration selected \n");
rlc_Config->choice.um_Bi_Directional = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional));
rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength));
*rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = NR_SN_FieldLengthUM_size12;
rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength));
*rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = NR_SN_FieldLengthUM_size12;
rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.t_Reassembly = NR_T_Reassembly_ms15;
break;
case NR_RLC_Config_PR_am:
// RLC AM Bearer configuration
rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am));
rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength));
*rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = NR_SN_FieldLengthAM_size18;
rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45;
rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64;
rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB500;
rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t32;
rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength));
*rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = NR_SN_FieldLengthAM_size18;
rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms15;
rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms15;
break;
default:
AssertFatal(0, "RLC config type %d not handled\n", rlc_config_pr);
break;
}
rlc_Config->present = rlc_config_pr;
}
void mac_rlc_data_ind (
const module_id_t module_idP,
const rnti_t rntiP,
......
......@@ -39,12 +39,6 @@
struct NR_RLC_Config;
struct NR_LogicalChannelConfig;
void nr_rlc_bearer_init(NR_RLC_BearerConfig_t *RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR rb_type);
void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr);
void nr_rlc_bearer_init_ul_spec(struct NR_LogicalChannelConfig *mac_LogicalChannelConfig);
void nr_rlc_add_srb(int rnti, int srb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
void nr_rlc_add_drb(int rnti, int drb_id, const NR_RLC_BearerConfig_t *rlc_BearerConfig);
......
......@@ -696,7 +696,6 @@ typedef struct {
uint32_t N_RB_DL;
uint32_t pbch_repetition;
LTE_BCCH_BCH_Message_t mib;
LTE_BCCH_BCH_Message_t *mib_DU;
LTE_BCCH_DL_SCH_Message_t siblock1;
LTE_BCCH_DL_SCH_Message_t siblock1_BR;
LTE_BCCH_DL_SCH_Message_t *siblock1_DU;
......
......@@ -35,6 +35,9 @@
#include "common/ran_context.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_common.h"
#include "LAYER2/NR_MAC_COMMON/nr_mac_extern.h"
#include "LAYER2/NR_MAC_gNB/nr_mac_gNB.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "intertask_interface.h"
......@@ -47,12 +50,17 @@
extern RAN_CONTEXT_t RC;
void nr_rrc_mac_remove_ue(rnti_t rntiMaybeUEid)
{
nr_rlc_remove_ue(rntiMaybeUEid);
int
nr_rrc_mac_remove_ue(module_id_t mod_idP,
rnti_t rntiP){
// todo
return 0;
gNB_MAC_INST *nrmac = RC.nrmac[0];
mac_remove_nr_ue(nrmac, rntiMaybeUEid);
}
void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc)
{
nr_mac_update_cellgroup(RC.nrmac[0], rntiMaybeUEid, cgc);
}
uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
......@@ -69,30 +77,15 @@ uint16_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
// MIBCH
if ((Srb_id & RAB_OFFSET) == MIBCH) {
asn_enc_rval_t enc_rval;
uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f);
int encode_size = 3;
rrc_gNB_carrier_data_t *carrier = &RC.nrrrc[Mod_idP]->carrier;
NR_BCCH_BCH_Message_t *mib = &carrier->mib;
mib->message.choice.mib->systemFrameNumber.buf[0] = sfn_msb << 2;
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message,
NULL,
(void *) mib,
carrier->MIB,
24);
LOG_D(NR_RRC, "Encoded MIB for frame %d sfn_msb %d (%p), bits %lu\n", frameP, sfn_msb, carrier->MIB,
enc_rval.encoded);
buffer_pP[0] = carrier->MIB[0];
buffer_pP[1] = carrier->MIB[1];
buffer_pP[2] = carrier->MIB[2];
int encoded = encode_MIB_NR(carrier->mib, frameP, buffer_pP, encode_size);
DevAssert(encoded == encode_size);
LOG_D(NR_RRC, "MIB PDU buffer_pP[0]=%x , buffer_pP[1]=%x, buffer_pP[2]=%x\n", buffer_pP[0], buffer_pP[1],
buffer_pP[2]);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
return 3;
return encode_size;
}
// TODO BCCH SIB1 SIBs
if ((Srb_id & RAB_OFFSET) == BCCH) {
memcpy(&buffer_pP[0], RC.nrrrc[Mod_idP]->carrier.SIB1, RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1);
return RC.nrrrc[Mod_idP]->carrier.sizeof_SIB1;
......
......@@ -194,401 +194,6 @@ int xer_nr_sprint (char *string, size_t string_size, asn_TYPE_descriptor_t *td,
//------------------------------------------------------------------------------
uint8_t do_MIB_NR(gNB_RRC_INST *rrc,uint32_t frame) {
asn_enc_rval_t enc_rval;
rrc_gNB_carrier_data_t *carrier = &rrc->carrier;
NR_BCCH_BCH_Message_t *mib = &carrier->mib;
NR_ServingCellConfigCommon_t *scc = carrier->servingcellconfigcommon;
memset(mib,0,sizeof(NR_BCCH_BCH_Message_t));
mib->message.present = NR_BCCH_BCH_MessageType_PR_mib;
mib->message.choice.mib = CALLOC(1,sizeof(struct NR_MIB));
memset(mib->message.choice.mib,0,sizeof(struct NR_MIB));
//36.331 SFN BIT STRING (SIZE (8) , 38.331 SFN BIT STRING (SIZE (6))
uint8_t sfn_msb = (uint8_t)((frame>>4)&0x3f);
mib->message.choice.mib->systemFrameNumber.buf = CALLOC(1,sizeof(uint8_t));
mib->message.choice.mib->systemFrameNumber.buf[0] = sfn_msb << 2;
mib->message.choice.mib->systemFrameNumber.size = 1;
mib->message.choice.mib->systemFrameNumber.bits_unused=2;
//38.331 spare BIT STRING (SIZE (1))
uint16_t *spare= CALLOC(1, sizeof(uint16_t));
if (spare == NULL) abort();
mib->message.choice.mib->spare.buf = (uint8_t *)spare;
mib->message.choice.mib->spare.size = 1;
mib->message.choice.mib->spare.bits_unused = 7; // This makes a spare of 1 bits
AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n");
int band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
frequency_range_t frequency_range = band < 100 ? FR1 : FR2;
int ssb_subcarrier_offset = 31; // default value for NSA
if (get_softmodem_params()->sa) {
uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB - scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
int scs_scaling = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000 ? 3 : 1;
ssb_subcarrier_offset = (absolute_diff/scs_scaling) % 24;
if(frequency_range == FR2)
ssb_subcarrier_offset >>= 1; // this assumes 120kHz SCS for SSB and subCarrierSpacingCommon (only option supported by OAI for now)
}
mib->message.choice.mib->ssb_SubcarrierOffset = ssb_subcarrier_offset & 15;
/*
* The SIB1 will be sent in this allocation (Type0-PDCCH) : 38.213, 13-4 Table and 38.213 13-11 to 13-14 tables
* the reverse allocation is in nr_ue_decode_mib()
*/
const NR_PDCCH_ConfigCommon_t *pdcch_cc = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup;
long cset0 = pdcch_cc->controlResourceSetZero ? *pdcch_cc->controlResourceSetZero : 0;
mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = cset0;
long ss0 = pdcch_cc->searchSpaceZero ? *pdcch_cc->searchSpaceZero : 0;
mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = ss0;
switch (*scc->ssbSubcarrierSpacing) {
case NR_SubcarrierSpacing_kHz15:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
break;
case NR_SubcarrierSpacing_kHz30:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
break;
case NR_SubcarrierSpacing_kHz60:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
break;
case NR_SubcarrierSpacing_kHz120:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
break;
case NR_SubcarrierSpacing_kHz240:
AssertFatal(1==0,"Unknown subCarrierSpacingCommon %d\n",(int)*scc->ssbSubcarrierSpacing);
break;
default:
AssertFatal(1==0,"Unknown subCarrierSpacingCommon %d\n",(int)*scc->ssbSubcarrierSpacing);
}
switch (scc->dmrs_TypeA_Position) {
case NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2:
mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos2;
break;
case NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3:
mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos3;
break;
default:
AssertFatal(1==0,"Unknown dmrs_TypeA_Position %d\n",(int)scc->dmrs_TypeA_Position);
}
// assign_enum
mib->message.choice.mib->cellBarred = NR_MIB__cellBarred_notBarred;
// assign_enum
mib->message.choice.mib->intraFreqReselection = NR_MIB__intraFreqReselection_notAllowed;
//encode MIB to data
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message,
NULL,
(void *)mib,
carrier->MIB,
24);
AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
return((enc_rval.encoded+7)/8);
}
uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier,
gNB_RrcConfigurationReq *configuration) {
asn_enc_rval_t enc_rval;
NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t));
carrier->siblock1 = sib1_message;
sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1;
sib1_message->message.choice.c1 = CALLOC(1,sizeof(struct NR_BCCH_DL_SCH_MessageType__c1));
sib1_message->message.choice.c1->present = NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
sib1_message->message.choice.c1->choice.systemInformationBlockType1 = CALLOC(1,sizeof(struct NR_SIB1));
struct NR_SIB1 *sib1 = sib1_message->message.choice.c1->choice.systemInformationBlockType1;
// cellSelectionInfo
sib1->cellSelectionInfo = CALLOC(1,sizeof(struct NR_SIB1__cellSelectionInfo));
// Fixme: should be in config file
//The IE Q-RxLevMin is used to indicate for cell selection/ re-selection the required minimum received RSRP level in the (NR) cell.
//Corresponds to parameter Qrxlevmin in TS38.304.
//Actual value Qrxlevmin = field value * 2 [dBm].
sib1->cellSelectionInfo->q_RxLevMin = -65;
// cellAccessRelatedInfo
// TODO : Add support for more than one PLMN
int num_plmn = 1; // int num_plmn = configuration->num_plmn;
asn1cSequenceAdd(sib1->cellAccessRelatedInfo.plmn_IdentityInfoList.list, struct NR_PLMN_IdentityInfo, nr_plmn_info);
for (int i = 0; i < num_plmn; ++i) {
asn1cSequenceAdd(nr_plmn_info->plmn_IdentityList.list, struct NR_PLMN_Identity, nr_plmn);
asn1cCalloc(nr_plmn->mcc, mcc);
int confMcc=configuration->mcc[i];
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc0);
*mcc0=(confMcc/100)%10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc1);
*mcc1=(confMcc/10)%10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc2);
*mcc2=confMcc%10;
int mnc=configuration->mnc[i];
if(configuration->mnc_digit_length[i] == 3) {
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc0);
*mnc0=(configuration->mnc[i]/100)%10;
}
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc1);
*mnc1=(mnc/10)%10;
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc2);
*mnc2=(mnc)%10;
}//end plmn loop
nr_plmn_info->cellIdentity.buf = CALLOC(1,5);
nr_plmn_info->cellIdentity.size= 5;
nr_plmn_info->cellIdentity.bits_unused= 4;
uint64_t tmp=htobe64(configuration->cell_identity)<<4;
memcpy(nr_plmn_info->cellIdentity.buf, ((char*)&tmp)+3, 5);
nr_plmn_info->cellReservedForOperatorUse = NR_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
nr_plmn_info->trackingAreaCode = CALLOC(1,sizeof(NR_TrackingAreaCode_t));
uint32_t tmp2=htobe32(configuration->tac);
nr_plmn_info->trackingAreaCode->buf = CALLOC(1,3);
memcpy(nr_plmn_info->trackingAreaCode->buf, ((char*) &tmp2)+1, 3);
nr_plmn_info->trackingAreaCode->size = 3;
nr_plmn_info->trackingAreaCode->bits_unused = 0;
// connEstFailureControl
// TODO: add connEstFailureControl
//si-SchedulingInfo
/*sib1->si_SchedulingInfo = CALLOC(1,sizeof(struct NR_SI_SchedulingInfo));
asn_set_empty(&sib1->si_SchedulingInfo->schedulingInfoList.list);
sib1->si_SchedulingInfo->si_WindowLength = NR_SI_SchedulingInfo__si_WindowLength_s40;
struct NR_SchedulingInfo *schedulingInfo = CALLOC(1,sizeof(struct NR_SchedulingInfo));
schedulingInfo->si_BroadcastStatus = NR_SchedulingInfo__si_BroadcastStatus_broadcasting;
schedulingInfo->si_Periodicity = NR_SchedulingInfo__si_Periodicity_rf8;
asn_set_empty(&schedulingInfo->sib_MappingInfo.list);
NR_SIB_TypeInfo_t *sib_type3 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type3->type = NR_SIB_TypeInfo__type_sibType3;
sib_type3->valueTag = CALLOC(1,sizeof(sib_type3->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type3);
NR_SIB_TypeInfo_t *sib_type5 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type5->type = NR_SIB_TypeInfo__type_sibType5;
sib_type5->valueTag = CALLOC(1,sizeof(sib_type5->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type5);
NR_SIB_TypeInfo_t *sib_type4 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type4->type = NR_SIB_TypeInfo__type_sibType4;
sib_type4->valueTag = CALLOC(1,sizeof(sib_type4->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type4);
NR_SIB_TypeInfo_t *sib_type2 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type2->type = NR_SIB_TypeInfo__type_sibType2;
sib_type2->valueTag = CALLOC(1,sizeof(sib_type2->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type2);
asn1cSeqAdd(&sib1->si_SchedulingInfo->schedulingInfoList.list,schedulingInfo);*/
// servingCellConfigCommon
asn1cCalloc(sib1->servingCellConfigCommon, ServCellCom);
NR_BWP_DownlinkCommon_t *initialDownlinkBWP=&ServCellCom->downlinkConfigCommon.initialDownlinkBWP;
initialDownlinkBWP->genericParameters=
configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters;
for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.count; i++) {
asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list,
struct NR_NR_MultiBandInfo, nrMultiBandInfo);
nrMultiBandInfo->freqBandIndicatorNR = configuration->scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[i];
}
int scs_scaling0 = 1<<(configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing);
int scs_scaling = scs_scaling0;
int scs_scaling2 = scs_scaling0;
if (configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000) {
scs_scaling = scs_scaling0*3;
}
if (configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA > 2016666) {
scs_scaling = scs_scaling0>>2;
scs_scaling2 = scs_scaling0>>2;
}
uint32_t absolute_diff = (*configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB -
configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA = scs_scaling2 * (absolute_diff/(12*scs_scaling) - 10);
LOG_I(NR_RRC,"SIB1 freq: absoluteFrequencySSB %ld, absoluteFrequencyPointA %ld\n",
*configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB,
configuration->scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
LOG_I(NR_RRC,"SIB1 freq: absolute_diff %d, %d*(absolute_diff/(12*%d) - 10) %d\n",
absolute_diff,scs_scaling2,scs_scaling,(int)sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA);
for(int i = 0; i< configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.count; i++) {
asn1cSeqAdd(&ServCellCom->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list,
configuration->scc->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[i]);
}
initialDownlinkBWP->pdcch_ConfigCommon =
configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon;
initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList =
CALLOC(1,sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList));
NR_SearchSpace_t *ss1 = rrc_searchspace_config(true, 1, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss1);
NR_SearchSpace_t *ss2 = rrc_searchspace_config(true, 2, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss2);
NR_SearchSpace_t *ss3 = rrc_searchspace_config(true, 3, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss3);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1, 0);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation, 3);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 2);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace, 1);
initialDownlinkBWP->pdsch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon;
ServCellCom->downlinkConfigCommon.bcch_Config.modificationPeriodCoeff = NR_BCCH_Config__modificationPeriodCoeff_n2;
ServCellCom->downlinkConfigCommon.pcch_Config.defaultPagingCycle = NR_PagingCycle_rf256;
ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.present = NR_PCCH_Config__nAndPagingFrameOffset_PR_quarterT;
ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.choice.quarterT = 1;
ServCellCom->downlinkConfigCommon.pcch_Config.ns = NR_PCCH_Config__ns_one;
asn1cCalloc(ServCellCom->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO,
P0);
P0->present = NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT;
asn1cCalloc(P0->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT,
Z8);
asn1cSequenceAdd(Z8->list,
long,
ZoneEight);
asn1cCallocOne(ZoneEight, 0);
asn1cCalloc(ServCellCom->uplinkConfigCommon, UL);
asn_set_empty(&UL->frequencyInfoUL.scs_SpecificCarrierList.list);
for(int i = 0; i< configuration->scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.count; i++) {
asn1cSeqAdd(&UL->frequencyInfoUL.scs_SpecificCarrierList.list,
configuration->scc->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[i]);
}
asn1cCallocOne(UL->frequencyInfoUL.p_Max, *configuration->scc->uplinkConfigCommon->frequencyInfoUL->p_Max);
UL->initialUplinkBWP.genericParameters = configuration->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters;
UL->initialUplinkBWP.rach_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon;
UL->initialUplinkBWP.pusch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon;
UL->initialUplinkBWP.pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = NULL;
UL->initialUplinkBWP.pucch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon;
UL->timeAlignmentTimerCommon = NR_TimeAlignmentTimer_infinity;
ServCellCom->n_TimingAdvanceOffset = configuration->scc->n_TimingAdvanceOffset;
ServCellCom->ssb_PositionsInBurst.inOneGroup.buf = calloc(1, sizeof(uint8_t));
uint8_t bitmap8,temp_bitmap=0;
switch (configuration->scc->ssb_PositionsInBurst->present) {
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.shortBitmap;
break;
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.mediumBitmap;
break;
/*
groupPresence: This field is present when maximum number of SS/PBCH blocks per half frame equals to 64 as defined in TS 38.213 [13], clause 4.1.
The first/leftmost bit corresponds to the SS/PBCH index 0-7, the second bit corresponds to SS/PBCH block 8-15, and so on.
Value 0 in the bitmap indicates that the SSBs according to inOneGroup are absent. Value 1 indicates that the SS/PBCH blocks are transmitted in accordance with inOneGroup.
inOneGroup: When maximum number of SS/PBCH blocks per half frame equals to 64 as defined in TS 38.213 [13], clause 4.1, all 8 bit are valid;
The first/ leftmost bit corresponds to the first SS/PBCH block index in the group (i.e., to SSB index 0, 8, and so on); the second bit corresponds to the second SS/PBCH block index in the group
(i.e., to SSB index 1, 9, and so on), and so on. Value 0 in the bitmap indicates that the corresponding SS/PBCH block is not transmitted while value 1 indicates that the corresponding SS/PBCH block is transmitted.
*/
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup.size = 1;
ServCellCom->ssb_PositionsInBurst.inOneGroup.bits_unused = 0;
ServCellCom->ssb_PositionsInBurst.groupPresence = calloc(1, sizeof(BIT_STRING_t));
ServCellCom->ssb_PositionsInBurst.groupPresence->size = 1;
ServCellCom->ssb_PositionsInBurst.groupPresence->bits_unused = 0;
ServCellCom->ssb_PositionsInBurst.groupPresence->buf = calloc(1, sizeof(uint8_t));
ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] = 0;
for (int i=0; i<8; i++){
bitmap8 = configuration->scc->ssb_PositionsInBurst->choice.longBitmap.buf[i];
if (bitmap8!=0){
if(temp_bitmap==0)
temp_bitmap = bitmap8;
else
AssertFatal(temp_bitmap==bitmap8,"For longBitmap the groups of 8 SSBs containing at least 1 transmitted SSB should be all the same\n");
ServCellCom->ssb_PositionsInBurst.inOneGroup.buf[0] = bitmap8;
ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] |= 1<<(7-i);
}
}
break;
default:
AssertFatal(false,"ssb_PositionsInBurst not present\n");
break;
}
ServCellCom->ssb_PeriodicityServingCell = *configuration->scc->ssb_periodicityServingCell;
if (configuration->scc->tdd_UL_DL_ConfigurationCommon) {
ServCellCom->tdd_UL_DL_ConfigurationCommon = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon));
ServCellCom->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = configuration->scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing;
ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern1 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern1;
ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern2 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern2;
}
ServCellCom->ss_PBCH_BlockPower = configuration->scc->ss_PBCH_BlockPower;
// ims-EmergencySupport
// TODO: add ims-EmergencySupport
// eCallOverIMS-Support
// TODO: add eCallOverIMS-Support
// ue-TimersAndConstants
sib1->ue_TimersAndConstants = CALLOC(1,sizeof(struct NR_UE_TimersAndConstants));
sib1->ue_TimersAndConstants->t300 = NR_UE_TimersAndConstants__t300_ms400;
sib1->ue_TimersAndConstants->t301 = NR_UE_TimersAndConstants__t301_ms400;
sib1->ue_TimersAndConstants->t310 = NR_UE_TimersAndConstants__t310_ms2000;
sib1->ue_TimersAndConstants->n310 = NR_UE_TimersAndConstants__n310_n10;
sib1->ue_TimersAndConstants->t311 = NR_UE_TimersAndConstants__t311_ms3000;
sib1->ue_TimersAndConstants->n311 = NR_UE_TimersAndConstants__n311_n1;
sib1->ue_TimersAndConstants->t319 = NR_UE_TimersAndConstants__t319_ms400;
// uac-BarringInfo
/*sib1->uac_BarringInfo = CALLOC(1, sizeof(struct NR_SIB1__uac_BarringInfo));
NR_UAC_BarringInfoSet_t *nr_uac_BarringInfoSet = CALLOC(1, sizeof(NR_UAC_BarringInfoSet_t));
asn_set_empty(&sib1->uac_BarringInfo->uac_BarringInfoSetList);
nr_uac_BarringInfoSet->uac_BarringFactor = NR_UAC_BarringInfoSet__uac_BarringFactor_p95;
nr_uac_BarringInfoSet->uac_BarringTime = NR_UAC_BarringInfoSet__uac_BarringTime_s4;
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.buf = CALLOC(1, 1);
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.size = 1;
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.bits_unused = 1;
asn1cSeqAdd(&sib1->uac_BarringInfo->uac_BarringInfoSetList, nr_uac_BarringInfoSet);*/
// useFullResumeID
// TODO: add useFullResumeID
// lateNonCriticalExtension
// TODO: add lateNonCriticalExtension
// nonCriticalExtension
// TODO: add nonCriticalExtension
xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void*)sib1_message->message.choice.c1->choice.systemInformationBlockType1);
if(carrier->SIB1 == NULL) carrier->SIB1=(uint8_t *) malloc16(NR_MAX_SIB_LENGTH/8);
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_DL_SCH_Message,
NULL,
(void *)sib1_message,
carrier->SIB1,
NR_MAX_SIB_LENGTH/8);
AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
AssertFatal(enc_rval.encoded <= NR_MAX_SIB_LENGTH, "ASN1 encoded length %zd bits. 3GPP TS 38.331 section 5.2.1 - The physical layer imposes a limit to the maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits.\n", enc_rval.encoded);
return((enc_rval.encoded+7)/8);
}
uint8_t do_SIB23_NR(rrc_gNB_carrier_data_t *carrier,
gNB_RrcConfigurationReq *configuration) {
asn_enc_rval_t enc_rval;
......@@ -687,240 +292,6 @@ int do_RRCReject(uint8_t Mod_id,
return (enc_rval.encoded + 7) / 8;
}
void fill_initial_SpCellConfig(int uid,
NR_SpCellConfig_t *SpCellConfig,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration) {
// This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4.
// However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources,
// where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations.
AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n");
const int pdsch_AntennaPorts = configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP;
int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
SpCellConfig->servCellIndex = NULL;
SpCellConfig->reconfigurationWithSync = NULL;
SpCellConfig->rlmInSyncOutOfSyncThreshold = NULL;
SpCellConfig->rlf_TimersAndConstants = NULL;
SpCellConfig->spCellConfigDedicated = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated));
SpCellConfig->spCellConfigDedicated->uplinkConfig = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig));
NR_UplinkConfig_t *uplinkConfig = SpCellConfig->spCellConfigDedicated->uplinkConfig;
NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP));
uplinkConfig->initialUplinkBWP = initialUplinkBWP;
initialUplinkBWP->pucch_Config = calloc(1,sizeof(*initialUplinkBWP->pucch_Config));
initialUplinkBWP->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup;
NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config));
initialUplinkBWP->pucch_Config->choice.setup=pucch_Config;
pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList));
pucch_Config->resourceSetToReleaseList = NULL;
pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList));
pucch_Config->resourceToReleaseList = NULL;
config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL);
config_pucch_resset1(pucch_Config, NULL);
set_pucch_power_config(pucch_Config, configuration->do_CSIRS);
initialUplinkBWP->pusch_Config = config_pusch(NULL);
long maxMIMO_Layers = uplinkConfig &&
uplinkConfig->pusch_ServingCellConfig &&
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1 &&
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers ?
*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1;
// We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1
initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config));
config_srs(scc, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, 0);
scheduling_request_config(scc, pucch_Config, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing);
set_dl_DataToUL_ACK(pucch_Config, configuration->minRXTXTIME, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing);
SpCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->initialDownlinkBWP));
NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP;
bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp_Dedicated->pdcch_Config));
bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup;
bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup));
bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList));
NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset));
uint64_t bitmap = get_ssb_bitmap(scc);
rrc_coreset_config(coreset, 0, curr_bwp, bitmap);
asn1cSeqAdd(&bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list,
coreset);
bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
NR_SearchSpace_t *ss2 = rrc_searchspace_config(false, 5, coreset->controlResourceSetId);
asn1cSeqAdd(&bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2);
bwp_Dedicated->pdsch_Config = config_pdsch(bitmap, 0, pdsch_AntennaPorts);
SpCellConfig->spCellConfigDedicated->tag_Id=0;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
// Downlink BWPs
int n_dl_bwp = 0;
if (servingcellconfigdedicated &&
servingcellconfigdedicated->downlinkBWP_ToAddModList &&
servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count > 0) {
n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count;
}
if(n_dl_bwp>0){
SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp));
config_downlinkBWP(bwp, scc,
servingcellconfigdedicated,
NULL, 0,
false, bwp_loop, true);
asn1cSeqAdd(&SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp);
}
SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1;
SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
*SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1;
}
// Uplink BWPs
int n_ul_bwp = 0;
if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig &&
servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList &&
servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count > 0) {
n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count;
}
if(n_ul_bwp>0) {
uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*uplinkConfig->uplinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) {
NR_BWP_Uplink_t *ubwp = calloc(1, sizeof(*ubwp));
config_uplinkBWP(ubwp, bwp_loop, true, uid,
configuration,
servingcellconfigdedicated,
scc,
NULL);
asn1cSeqAdd(&uplinkConfig->uplinkBWP_ToAddModList->list, ubwp);
}
uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*uplinkConfig->firstActiveUplinkBWP_Id));
*uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id : 1;
}
SpCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig));
SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig));
SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0));
ssbresset0->csi_SSB_ResourceSetId=0;
for (int i=0;i<64;i++) {
if ((bitmap >> (63 - i)) & 0x01) {
NR_SSB_Index_t *ssbres = NULL;
asn1cCallocOne(ssbres, i);
asn1cSeqAdd(&ssbresset0->csi_SSB_ResourceList.list, ssbres);
}
}
asn1cSeqAdd(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0);
int bwp_loop_end = n_dl_bwp>0 ? n_dl_bwp : 1;
for (int bwp_loop = 0; bwp_loop < bwp_loop_end; bwp_loop++) {
int curr_bwp, bwp_id;
struct NR_SetupRelease_PDSCH_Config *pdsch_Config;
if(n_dl_bwp == 0) {
pdsch_Config = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config;
curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
bwp_id = 0;
}
else {
NR_BWP_Downlink_t *bwp = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop];
pdsch_Config = bwp->bwp_Dedicated->pdsch_Config;
curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
bwp_id = bwp->bwp_Id;
}
config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS, bwp_loop);
config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig, bwp_loop);
NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1));
csires1->csi_ResourceConfigId = bwp_id+20;
csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList));
NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00));
*ssbres00 = 0;
asn1cSeqAdd(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00);
csires1->bwp_Id = bwp_id;
csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1);
NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1));
pucchcsires1->uplinkBandwidthPartId=bwp_id;
pucchcsires1->pucch_Resource=2;
if (configuration->do_CSIRS) {
NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0));
csires0->csi_ResourceConfigId = bwp_id;
csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0));
*nzp0 = bwp_loop;
asn1cSeqAdd(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0);
csires0->bwp_Id = bwp_id;
csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0);
}
if (configuration->do_CSIRS && pdsch_AntennaPorts > 1) {
NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2));
csires2->csi_ResourceConfigId = bwp_id+10;
csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00));
*csiim00 = bwp_loop;
asn1cSeqAdd(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00);
csires2->bwp_Id = bwp_id;
csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2);
config_csi_meas_report(csi_MeasConfig, scc, pucchcsires1, pdsch_Config, &configuration->pdsch_AntennaPorts, NR_MAX_SUPPORTED_DL_LAYERS, bwp_id, uid);
}
config_rsrp_meas_report(csi_MeasConfig, scc, pucchcsires1, configuration->do_CSIRS, bwp_id + 10, uid);
}
pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
pdsch_servingcellconfig->xOverhead = NULL;
pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
pdsch_servingcellconfig->pucch_Cell= NULL;
pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1));
pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
*pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)SpCellConfig);
}
}
NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(long channelId,
long priority,
e_NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration bucketSizeDuration)
......@@ -966,6 +337,42 @@ NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(long channelId,
return rlc_BearerConfig;
}
static void nr_drb_config(struct NR_RLC_Config *rlc_Config, NR_RLC_Config_PR rlc_config_pr)
{
switch (rlc_config_pr) {
case NR_RLC_Config_PR_um_Bi_Directional:
// RLC UM Bi-directional Bearer configuration
LOG_I(RLC, "RLC UM Bi-directional Bearer configuration selected \n");
rlc_Config->choice.um_Bi_Directional = calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional));
rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength =
calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength));
*rlc_Config->choice.um_Bi_Directional->ul_UM_RLC.sn_FieldLength = NR_SN_FieldLengthUM_size12;
rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength =
calloc(1, sizeof(*rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength));
*rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.sn_FieldLength = NR_SN_FieldLengthUM_size12;
rlc_Config->choice.um_Bi_Directional->dl_UM_RLC.t_Reassembly = NR_T_Reassembly_ms15;
break;
case NR_RLC_Config_PR_am:
// RLC AM Bearer configuration
rlc_Config->choice.am = calloc(1, sizeof(*rlc_Config->choice.am));
rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength));
*rlc_Config->choice.am->ul_AM_RLC.sn_FieldLength = NR_SN_FieldLengthAM_size18;
rlc_Config->choice.am->ul_AM_RLC.t_PollRetransmit = NR_T_PollRetransmit_ms45;
rlc_Config->choice.am->ul_AM_RLC.pollPDU = NR_PollPDU_p64;
rlc_Config->choice.am->ul_AM_RLC.pollByte = NR_PollByte_kB500;
rlc_Config->choice.am->ul_AM_RLC.maxRetxThreshold = NR_UL_AM_RLC__maxRetxThreshold_t32;
rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = calloc(1, sizeof(*rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength));
*rlc_Config->choice.am->dl_AM_RLC.sn_FieldLength = NR_SN_FieldLengthAM_size18;
rlc_Config->choice.am->dl_AM_RLC.t_Reassembly = NR_T_Reassembly_ms15;
rlc_Config->choice.am->dl_AM_RLC.t_StatusProhibit = NR_T_StatusProhibit_ms15;
break;
default:
AssertFatal(false, "RLC config type %d not handled\n", rlc_config_pr);
break;
}
rlc_Config->present = rlc_config_pr;
}
NR_RLC_BearerConfig_t *get_DRB_RLC_BearerConfig(long lcChannelId, long drbId, NR_RLC_Config_PR rlc_conf, long priority)
{
NR_RLC_BearerConfig_t *rlc_BearerConfig = calloc(1, sizeof(NR_RLC_BearerConfig_t));
......@@ -997,6 +404,74 @@ NR_RLC_BearerConfig_t *get_DRB_RLC_BearerConfig(long lcChannelId, long drbId, NR
return rlc_BearerConfig;
}
/* returns a default radio bearer config suitable for NSA etc */
NR_RadioBearerConfig_t *get_default_rbconfig(int eps_bearer_id,
int rb_id,
e_NR_CipheringAlgorithm ciphering_algorithm,
e_NR_SecurityConfig__keyToUse key_to_use)
{
NR_RadioBearerConfig_t *rbconfig = calloc(1, sizeof(*rbconfig));
rbconfig->srb_ToAddModList = NULL;
rbconfig->srb3_ToRelease = NULL;
rbconfig->drb_ToAddModList = calloc(1,sizeof(*rbconfig->drb_ToAddModList));
NR_DRB_ToAddMod_t *drb_ToAddMod = calloc(1,sizeof(*drb_ToAddMod));
drb_ToAddMod->cnAssociation = calloc(1,sizeof(*drb_ToAddMod->cnAssociation));
drb_ToAddMod->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity;
drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= eps_bearer_id;
drb_ToAddMod->drb_Identity = rb_id;
drb_ToAddMod->reestablishPDCP = NULL;
drb_ToAddMod->recoverPDCP = NULL;
drb_ToAddMod->pdcp_Config = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config));
asn1cCalloc(drb_ToAddMod->pdcp_Config->drb, drb);
asn1cCallocOne(drb->discardTimer, NR_PDCP_Config__drb__discardTimer_infinity);
asn1cCallocOne(drb->pdcp_SN_SizeUL, NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits);
asn1cCallocOne(drb->pdcp_SN_SizeDL, NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits);
drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drb->headerCompression.choice.notUsed = 0;
drb->integrityProtection = NULL;
drb->statusReportRequired = NULL;
drb->outOfOrderDelivery = NULL;
drb_ToAddMod->pdcp_Config->moreThanOneRLC = NULL;
asn1cCallocOne(drb_ToAddMod->pdcp_Config->t_Reordering, NR_PDCP_Config__t_Reordering_ms100);
drb_ToAddMod->pdcp_Config->ext1 = NULL;
asn1cSeqAdd(&rbconfig->drb_ToAddModList->list,drb_ToAddMod);
rbconfig->drb_ToReleaseList = NULL;
asn1cCalloc(rbconfig->securityConfig, secConf);
asn1cCalloc(secConf->securityAlgorithmConfig, secConfAlgo);
secConfAlgo->cipheringAlgorithm = ciphering_algorithm;
secConfAlgo->integrityProtAlgorithm = NULL;
asn1cCallocOne(secConf->keyToUse, key_to_use);
return rbconfig;
}
void fill_nr_noS1_bearer_config(NR_RadioBearerConfig_t **rbconfig,
NR_RLC_BearerConfig_t **rlc_rbconfig)
{
/* the EPS bearer ID is arbitrary; the rb_id is 1/the first DRB, it needs to
* match the one in get_DRB_RLC_BearerConfig(). No ciphering is to be
* configured */
*rbconfig = get_default_rbconfig(10, 1, NR_CipheringAlgorithm_nea0, NR_SecurityConfig__keyToUse_master);
AssertFatal(*rbconfig != NULL, "get_default_rbconfig() failed\n");
/* LCID is 4 because the RLC layer requires it to be 3+rb_id; the rb_id 1 is
* common with get_default_rbconfig() (first RB). We pre-configure RLC UM
* Bi-directional, priority is 1 */
*rlc_rbconfig = get_DRB_RLC_BearerConfig(4, 1, NR_RLC_Config_PR_um_Bi_Directional, 1);
AssertFatal(*rlc_rbconfig != NULL, "get_DRB_RLC_BearerConfig() failed\n");
}
void free_nr_noS1_bearer_config(NR_RadioBearerConfig_t **rbconfig,
NR_RLC_BearerConfig_t **rlc_rbconfig)
{
ASN_STRUCT_FREE(asn_DEF_NR_RadioBearerConfig, *rbconfig);
*rbconfig = NULL;
ASN_STRUCT_FREE(asn_DEF_NR_RLC_BearerConfig, *rlc_rbconfig);
*rlc_rbconfig = NULL;
}
void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGroupConfig_t *ue_context_mastercellGroup, int use_rlc_um_for_drb, uint8_t configure_srb, uint8_t bearer_id_start, uint8_t nb_bearers_to_setup, long *priority) {
cellGroupConfig->cellGroupId = 0;
......@@ -1020,175 +495,12 @@ void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, NR_CellGr
}
}
//TODO temp function (to remove once CSI meas config harmonization is done)
void update_cqitables(struct NR_SetupRelease_PDSCH_Config *pdsch_Config,
NR_CSI_MeasConfig_t *csi_MeasConfig) {
int nb_csi = csi_MeasConfig->csi_ReportConfigToAddModList->list.count;
for (int i = 0; i < nb_csi; i++) {
NR_CSI_ReportConfig_t *csirep = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[i];
if(csirep->cqi_Table) {
if(pdsch_Config->choice.setup->mcs_Table!=NULL)
*csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2;
else
*csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
}
}
}
void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
const int uid,
NR_UE_NR_Capability_t *uecap,
const gNB_RrcConfigurationReq* configuration) {
NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig;
if (SpCellConfig == NULL) return;
NR_ServingCellConfigCommon_t *scc = configuration ? configuration->scc : NULL;
if(scc) {
int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
NR_UplinkConfig_t *uplinkConfig = SpCellConfig && SpCellConfig->spCellConfigDedicated ? SpCellConfig->spCellConfigDedicated->uplinkConfig : NULL;
uint8_t ul_max_layers = 1;
if (uecap &&
uecap->featureSets &&
uecap->featureSets->featureSetsUplinkPerCC &&
uecap->featureSets->featureSetsUplinkPerCC->list.count > 0) {
NR_FeatureSetUplinkPerCC_t *ul_feature_setup_per_cc = uecap->featureSets->featureSetsUplinkPerCC->list.array[0];
if (ul_feature_setup_per_cc->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH) {
switch (*ul_feature_setup_per_cc->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH) {
case NR_MIMO_LayersUL_twoLayers:
ul_max_layers = 2;
break;
case NR_MIMO_LayersUL_fourLayers:
ul_max_layers = 4;
break;
default:
ul_max_layers = 1;
}
}
ul_max_layers = min(ul_max_layers, configuration->pusch_AntennaPorts);
if (uplinkConfig->initialUplinkBWP->pusch_Config) {
NR_PUSCH_Config_t *pusch_Config = uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup;
if (pusch_Config->maxRank == NULL) {
pusch_Config->maxRank = calloc(1, sizeof(*pusch_Config->maxRank));
}
*pusch_Config->maxRank = ul_max_layers;
}
if (uplinkConfig->pusch_ServingCellConfig == NULL) {
uplinkConfig->pusch_ServingCellConfig = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig));
uplinkConfig->pusch_ServingCellConfig->present = NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup;
uplinkConfig->pusch_ServingCellConfig->choice.setup = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup));
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1 = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1));
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers));
}
*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers = ul_max_layers;
}
long maxMIMO_Layers = uplinkConfig &&
uplinkConfig->pusch_ServingCellConfig &&
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1 &&
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers ?
*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1;
// UL and SRS configuration
if (configuration->do_SRS && uplinkConfig && uplinkConfig->initialUplinkBWP) {
if (!uplinkConfig->initialUplinkBWP->srs_Config) {
uplinkConfig->initialUplinkBWP->srs_Config = calloc(1, sizeof(*uplinkConfig->initialUplinkBWP->srs_Config));
}
config_srs(scc,
SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config,
uecap,
curr_bwp,
uid,
0,
maxMIMO_Layers,
configuration->do_SRS);
}
// Set DL MCS table
NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP;
set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing,
configuration->force_256qam_off ? NULL : uecap, bwp_Dedicated, scc);
struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList;
struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = uplinkConfig->uplinkBWP_ToAddModList;
if (DL_BWP_list) {
for (int i=0; i<DL_BWP_list->list.count; i++){
NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i];
int scs = bwp->bwp_Common->genericParameters.subcarrierSpacing;
set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, scc);
}
}
if (configuration->do_SRS && UL_BWP_list) {
for (int i=0; i<UL_BWP_list->list.count; i++) {
NR_BWP_Uplink_t *ul_bwp = UL_BWP_list->list.array[i];
int bwp_size = NRRIV2BW(ul_bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
if (ul_bwp->bwp_Dedicated->pusch_Config) {
NR_PUSCH_Config_t *pusch_Config = ul_bwp->bwp_Dedicated->pusch_Config->choice.setup;
if (pusch_Config->maxRank == NULL) {
pusch_Config->maxRank = calloc(1, sizeof(*pusch_Config->maxRank));
}
*pusch_Config->maxRank = ul_max_layers;
}
config_srs(scc,
ul_bwp->bwp_Dedicated->srs_Config,
uecap,
bwp_size,
uid,
i+1,
maxMIMO_Layers,
configuration->do_SRS);
}
}
update_cqitables(bwp_Dedicated->pdsch_Config, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup);
}
}
void fill_initial_cellGroupConfig(int uid,
NR_CellGroupConfig_t *cellGroupConfig,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration)
{
NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = NULL;
cellGroupConfig->cellGroupId = 0;
/* Rlc Bearer Config */
/* TS38.331 9.2.1 Default SRB configurations */
cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList));
NR_RLC_BearerConfig_t *rlc_BearerConfig = get_SRB_RLC_BearerConfig(1, 1, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000);
asn1cSeqAdd(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig);
cellGroupConfig->rlc_BearerToReleaseList = NULL;
/* mac CellGroup Config */
cellGroupConfig->mac_CellGroupConfig = configure_mac_cellgroup();
physicalCellGroupConfig = calloc(1,sizeof(*physicalCellGroupConfig));
physicalCellGroupConfig->p_NR_FR1 = NULL;
physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook = NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic;
cellGroupConfig->physicalCellGroupConfig = physicalCellGroupConfig;
cellGroupConfig->spCellConfig = calloc(1,sizeof(*cellGroupConfig->spCellConfig));
fill_initial_SpCellConfig(uid,cellGroupConfig->spCellConfig,scc,servingcellconfigdedicated,configuration);
cellGroupConfig->sCellToAddModList = NULL;
cellGroupConfig->sCellToReleaseList = NULL;
}
//------------------------------------------------------------------------------
int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
uint8_t *const buffer,
const uint8_t transaction_id,
const uint8_t *masterCellGroup,
int masterCellGroup_len,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration)
//------------------------------------------------------------------------------
{
......@@ -1198,7 +510,6 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
NR_RRCSetup_IEs_t *ie;
NR_SRB_ToAddMod_t *SRB1_config = NULL;
NR_PDCP_Config_t *pdcp_Config = NULL;
NR_CellGroupConfig_t *cellGroupConfig = NULL;
AssertFatal(ue_context_pP != NULL,"ue_context_p is null\n");
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
......@@ -1248,11 +559,10 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
ie->masterCellGroup.size = masterCellGroup_len;
// decode masterCellGroup OCTET_STRING received from DU and place in ue context
uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cellGroupConfig, masterCellGroup, masterCellGroup_len, 0, 0);
ue_p->masterCellGroup = cellGroupConfig;
ue_p->masterCellGroup = decode_cellGroupConfig(masterCellGroup, masterCellGroup_len);
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig);
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, ue_p->masterCellGroup);
xer_fprint(stdout, &asn_DEF_NR_DL_CCCH_Message, (void *)&dl_ccch_msg);
}
......@@ -1877,38 +1187,6 @@ int do_RRCReestablishment(const protocol_ctxt_t *const ctxt_pP,
*SRB_configList = CALLOC(1, sizeof(NR_SRB_ToAddModList_t));
asn1cSeqAdd(&(*SRB_configList)->list, SRB1_config);
/****************************** masterCellGroup ******************************/
/*
NR_CellGroupConfig_t *cellGroupConfig = NULL;
char masterCellGroup_buf[1000];
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
if (masterCellGroup_from_DU) {
// decode masterCellGroup OCTET_STRING received from DU and place in ue context
uper_decode(NULL,
&asn_DEF_NR_CellGroupConfig, //might be added prefix later
(void **)&cellGroupConfig,
(uint8_t *)masterCellGroup_from_DU->buf,
masterCellGroup_from_DU->size, 0, 0);
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)cellGroupConfig);
}
else {
cellGroupConfig = calloc(1, sizeof(NR_CellGroupConfig_t));
fill_initial_cellGroupConfig(ue_context_pP->ue_context.rnti,ue_context_pP->local_uid,cellGroupConfig,scc,carrier);
enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL,
(void *)cellGroupConfig,
masterCellGroup_buf,
1000);
if(enc_rval.encoded == -1) {
LOG_E(NR_RRC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name, enc_rval.encoded);
return -1;
}
}
ue_p->masterCellGroup = cellGroupConfig;
*/
rrcReestablishment->rrc_TransactionIdentifier = Transaction_id;
rrcReestablishment->criticalExtensions.present = NR_RRCReestablishment__criticalExtensions_PR_rrcReestablishment;
rrcReestablishment->criticalExtensions.choice.rrcReestablishment = CALLOC(1, sizeof(NR_RRCReestablishment_IEs_t));
......
......@@ -55,16 +55,6 @@
*/
int xer_sprint_NR(char *string, size_t string_size, struct asn_TYPE_descriptor_s *td, void *sptr);
uint8_t do_MIB_NR(gNB_RRC_INST *rrc,
uint32_t frame);
/**
\brief Generate configuration for SIB1 (gNB).
@param carrier pointer to Carrier information
@param configuration Pointer Configuration Request structure
@return size of encoded bit stream in bytes*/
uint16_t do_SIB1_NR(rrc_gNB_carrier_data_t *carrier, gNB_RrcConfigurationReq *configuration);
uint8_t do_SIB23_NR(rrc_gNB_carrier_data_t *carrier,
gNB_RrcConfigurationReq *configuration);
......@@ -74,22 +64,22 @@ void do_SpCellConfig(gNB_RRC_INST *rrc,
int do_RRCReject(uint8_t Mod_id,
uint8_t *const buffer);
void fill_initial_SpCellConfig(int uid,
NR_SpCellConfig_t *SpCellConfig,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration);
NR_RLC_BearerConfig_t *get_SRB_RLC_BearerConfig(
long channelId,
long priority,
e_NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration bucketSizeDuration);
NR_RLC_BearerConfig_t *get_DRB_RLC_BearerConfig(long lcChannelId, long drbId, NR_RLC_Config_PR rlc_conf, long priority);
NR_RadioBearerConfig_t *get_default_rbconfig(int eps_bearer_id,
int rb_id,
e_NR_CipheringAlgorithm ciphering_algorithm,
e_NR_SecurityConfig__keyToUse key_to_use);
void fill_initial_cellGroupConfig(int uid,
NR_CellGroupConfig_t *cellGroupConfig,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration);
void fill_nr_noS1_bearer_config(NR_RadioBearerConfig_t **rbconfig,
NR_RLC_BearerConfig_t **rlc_rbconfig);
void free_nr_noS1_bearer_config(NR_RadioBearerConfig_t **rbconfig,
NR_RLC_BearerConfig_t **rlc_rbconfig);
void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
const int uid,
NR_UE_NR_Capability_t *uecap,
const gNB_RrcConfigurationReq *configuration);
void fill_mastercellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
NR_CellGroupConfig_t *ue_context_mastercellGroup,
......@@ -104,8 +94,6 @@ int do_RRCSetup(rrc_gNB_ue_context_t *const ue_context_pP,
const uint8_t transaction_id,
const uint8_t *masterCellGroup,
int masterCellGroup_len,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration);
uint8_t do_NR_SecurityModeCommand(
......
......@@ -32,42 +32,11 @@
#include "common/utils/nr/nr_common.h"
#include "executables/softmodem-common.h"
#include "oai_asn1.h"
#include "SIMULATION/TOOLS/sim.h" // for taus();
const uint8_t slotsperframe[5] = {10, 20, 40, 80, 160};
NR_MAC_CellGroupConfig_t *configure_mac_cellgroup(void)
{
NR_MAC_CellGroupConfig_t * mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig));
mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config));
mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10;
mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80;
mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config));
mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL;
mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList));
struct NR_TAG *tag=calloc(1,sizeof(*tag));
tag->tag_Id = 0;
tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity;
asn1cSeqAdd(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag);
set_phr_config(mac_CellGroupConfig);
mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig));
mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList));
struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist));
schedulingrequestlist->schedulingRequestId = 0;
schedulingrequestlist->sr_ProhibitTimer = NULL;
schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64;
asn1cSeqAdd(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist);
mac_CellGroupConfig->skipUplinkTxDynamic=false;
mac_CellGroupConfig->ext1 = NULL;
return mac_CellGroupConfig;
}
NR_SearchSpace_t *rrc_searchspace_config(bool is_common,
int searchspaceid,
int coresetid)
static NR_SearchSpace_t *rrc_searchspace_config(bool is_common, int searchspaceid, int coresetid)
{
NR_SearchSpace_t *ss = calloc(1,sizeof(*ss));
......@@ -111,11 +80,10 @@ NR_SearchSpace_t *rrc_searchspace_config(bool is_common,
return ss;
}
void rrc_coreset_config(NR_ControlResourceSet_t *coreset,
int bwp_id,
int curr_bwp,
uint64_t ssb_bitmap) {
static NR_ControlResourceSet_t *get_coreset_config(int bwp_id, int curr_bwp, uint64_t ssb_bitmap)
{
NR_ControlResourceSet_t *coreset = calloc(1, sizeof(*coreset));
AssertFatal(coreset != NULL, "out of memory\n");
// frequency domain resources depending on BWP size
coreset->frequencyDomainResources.buf = calloc(1,6);
coreset->frequencyDomainResources.buf[0] = (curr_bwp < 48) ? 0xf0 : 0xff;
......@@ -145,9 +113,11 @@ void rrc_coreset_config(NR_ControlResourceSet_t *coreset,
coreset->tci_StatesPDCCH_ToReleaseList = NULL;
coreset->tci_PresentInDCI = NULL;
coreset->pdcch_DMRS_ScramblingID = NULL;
return coreset;
}
uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc) {
static uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc)
{
uint64_t bitmap=0;
switch (scc->ssb_PositionsInBurst->present) {
case 1 :
......@@ -167,8 +137,8 @@ uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc) {
return bitmap;
}
void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_slots_per_period) {
static void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_slots_per_period)
{
nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset));
int ideal_period = nb_slots_per_period * MAX_MOBILES_PER_GNB;
......@@ -214,14 +184,14 @@ void set_csirs_periodicity(NR_NZP_CSI_RS_Resource_t *nzpcsi0, int uid, int nb_sl
}
}
void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_CSI_MeasConfig_t *csi_MeasConfig,
int uid,
int num_dl_antenna_ports,
int curr_bwp,
int do_csirs,
int id) {
static void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_CSI_MeasConfig_t *csi_MeasConfig,
int uid,
int num_dl_antenna_ports,
int curr_bwp,
int do_csirs,
int id)
{
if (do_csirs) {
if(!csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList)
......@@ -306,9 +276,9 @@ void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
csi_MeasConfig->nzp_CSI_RS_ResourceToReleaseList = NULL;
}
void set_csiim_offset(struct NR_CSI_ResourcePeriodicityAndOffset *periodicityAndOffset,
struct NR_CSI_ResourcePeriodicityAndOffset *target_periodicityAndOffset) {
static void set_csiim_offset(struct NR_CSI_ResourcePeriodicityAndOffset *periodicityAndOffset,
struct NR_CSI_ResourcePeriodicityAndOffset *target_periodicityAndOffset)
{
switch(periodicityAndOffset->present) {
case NR_CSI_ResourcePeriodicityAndOffset_PR_slots4:
periodicityAndOffset->choice.slots4 = target_periodicityAndOffset->choice.slots4;
......@@ -355,9 +325,12 @@ void set_csiim_offset(struct NR_CSI_ResourcePeriodicityAndOffset *periodicityAnd
}
void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp,
NR_CSI_MeasConfig_t *csi_MeasConfig, int id) {
static void config_csiim(int do_csirs,
int dl_antenna_ports,
int curr_bwp,
NR_CSI_MeasConfig_t *csi_MeasConfig,
int id)
{
if (do_csirs && dl_antenna_ports > 1) {
if (!csi_MeasConfig->csi_IM_ResourceToAddModList)
csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList));
......@@ -429,8 +402,8 @@ long rrc_get_max_nr_csrs(const int max_rbs, const long b_SRS) {
return c_srs;
}
struct NR_SRS_Resource__resourceType__periodic *configure_periodic_srs(const NR_ServingCellConfigCommon_t *scc,
const int uid)
static struct NR_SRS_Resource__resourceType__periodic *configure_periodic_srs(const NR_ServingCellConfigCommon_t *scc,
const int uid)
{
const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
......@@ -503,14 +476,14 @@ struct NR_SRS_Resource__resourceType__periodic *configure_periodic_srs(const NR_
return periodic_srs;
}
void config_srs(const NR_ServingCellConfigCommon_t *scc,
NR_SetupRelease_SRS_Config_t *setup_release_srs_Config,
const NR_UE_NR_Capability_t *uecap,
const int curr_bwp,
const int uid,
const int res_id,
const long maxMIMO_Layers,
const int do_srs)
static void config_srs(const NR_ServingCellConfigCommon_t *scc,
NR_SetupRelease_SRS_Config_t *setup_release_srs_Config,
const NR_UE_NR_Capability_t *uecap,
const int curr_bwp,
const int uid,
const int res_id,
const long maxMIMO_Layers,
const int do_srs)
{
setup_release_srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
......@@ -786,7 +759,7 @@ void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay){
}
}
void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time, NR_SubcarrierSpacing_t subcarrierSpacing)
static void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time, NR_SubcarrierSpacing_t subcarrierSpacing)
{
pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK));
long *delay[8];
......@@ -799,8 +772,8 @@ void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time,
}
// PUCCH resource set 0 for configuration with O_uci <= 2 bits and/or a positive or negative SR (section 9.2.1 of 38.213)
void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap) {
static void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, const NR_UE_NR_Capability_t *uecap)
{
NR_PUCCH_ResourceSet_t *pucchresset = calloc(1,sizeof(*pucchresset));
pucchresset->pucch_ResourceSetId = 0;
NR_PUCCH_ResourceId_t *pucchid=calloc(1,sizeof(*pucchid));
......@@ -830,8 +803,8 @@ void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp
// PUCCH resource set 1 for configuration with O_uci > 2 bits (currently format2)
void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap) {
static void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, const NR_UE_NR_Capability_t *uecap)
{
NR_PUCCH_ResourceSet_t *pucchresset=calloc(1,sizeof(*pucchresset));
pucchresset->pucch_ResourceSetId = 1;
NR_PUCCH_ResourceId_t *pucchressetid=calloc(1,sizeof(*pucchressetid));
......@@ -957,9 +930,7 @@ static void set_SR_periodandoffset(NR_SchedulingRequestResourceConfig_t *schedul
}
}
void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc,
NR_PUCCH_Config_t *pucch_Config,
int scs)
static void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc, NR_PUCCH_Config_t *pucch_Config, int scs)
{
// format with <=2 bits in pucch resource set 0
NR_PUCCH_ResourceSet_t *pucchresset = pucch_Config->resourceSetToAddModList->list.array[0];
......@@ -978,11 +949,11 @@ void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc,
asn1cSeqAdd(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig);
}
void set_dl_mcs_table(int scs,
NR_UE_NR_Capability_t *cap,
NR_BWP_DownlinkDedicated_t *bwp_Dedicated,
const NR_ServingCellConfigCommon_t *scc) {
static void set_dl_mcs_table(int scs,
const NR_UE_NR_Capability_t *cap,
NR_BWP_DownlinkDedicated_t *bwp_Dedicated,
const NR_ServingCellConfigCommon_t *scc)
{
if (cap == NULL){
bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NULL;
return;
......@@ -1021,7 +992,7 @@ void set_dl_mcs_table(int scs,
bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NULL;
}
struct NR_SetupRelease_PUSCH_Config *config_pusch(NR_PUSCH_Config_t *pusch_Config)
static struct NR_SetupRelease_PUSCH_Config *config_pusch(NR_PUSCH_Config_t *pusch_Config)
{
struct NR_SetupRelease_PUSCH_Config *setup_puschconfig = calloc(1, sizeof(*setup_puschconfig));
setup_puschconfig->present = NR_SetupRelease_PUSCH_Config_PR_setup;
......@@ -1102,7 +1073,7 @@ struct NR_SetupRelease_PUSCH_Config *config_pusch(NR_PUSCH_Config_t *pusch_Confi
return setup_puschconfig;
}
struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_Id, int dl_antenna_ports)
static struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_Id, int dl_antenna_ports)
{
struct NR_SetupRelease_PDSCH_Config *setup_pdsch_Config = calloc(1,sizeof(*setup_pdsch_Config));
setup_pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup;
......@@ -1145,14 +1116,15 @@ struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_I
return setup_pdsch_Config;
}
void config_downlinkBWP(NR_BWP_Downlink_t *bwp,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
NR_UE_NR_Capability_t *uecap,
int dl_antenna_ports,
bool force_256qam_off,
int bwp_loop, bool is_SA) {
static void config_downlinkBWP(NR_BWP_Downlink_t *bwp,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_UE_NR_Capability_t *uecap,
int dl_antenna_ports,
bool force_256qam_off,
int bwp_loop,
bool is_SA)
{
bwp->bwp_Common = calloc(1,sizeof(*bwp->bwp_Common));
if(servingcellconfigdedicated->downlinkBWP_ToAddModList &&
......@@ -1176,9 +1148,8 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp,
int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset));
uint64_t ssb_bitmap = get_ssb_bitmap(scc);
rrc_coreset_config(coreset, bwp->bwp_Id, curr_bwp, ssb_bitmap);
NR_ControlResourceSet_t *coreset = get_coreset_config(bwp->bwp_Id, curr_bwp, ssb_bitmap);
bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset;
bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL;
......@@ -1231,13 +1202,15 @@ void config_downlinkBWP(NR_BWP_Downlink_t *bwp,
scc);
}
void config_uplinkBWP(NR_BWP_Uplink_t *ubwp,
long bwp_loop, bool is_SA, int uid,
const gNB_RrcConfigurationReq *configuration,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_ServingCellConfigCommon_t *scc,
NR_UE_NR_Capability_t *uecap) {
static void config_uplinkBWP(NR_BWP_Uplink_t *ubwp,
long bwp_loop,
bool is_SA,
int uid,
const gNB_RrcConfigurationReq *configuration,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_ServingCellConfigCommon_t *scc,
const NR_UE_NR_Capability_t *uecap)
{
ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common));
if(servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList &&
bwp_loop < servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count) {
......@@ -1311,7 +1284,7 @@ void config_uplinkBWP(NR_BWP_Uplink_t *ubwp,
ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL;
}
void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig)
static void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig)
{
mac_CellGroupConfig->phr_Config = calloc(1, sizeof(*mac_CellGroupConfig->phr_Config));
mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup;
......@@ -1321,7 +1294,7 @@ void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig)
mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB1;
}
void set_csi_meas_periodicity(const NR_ServingCellConfigCommon_t *scc, NR_CSI_ReportConfig_t *csirep, int uid, bool is_rsrp)
static void set_csi_meas_periodicity(const NR_ServingCellConfigCommon_t *scc, NR_CSI_ReportConfig_t *csirep, int uid, bool is_rsrp)
{
const NR_TDD_UL_DL_Pattern_t *tdd = scc->tdd_UL_DL_ConfigurationCommon ? &scc->tdd_UL_DL_ConfigurationCommon->pattern1 : NULL;
const int n_slots_frame = slotsperframe[*scc->ssbSubcarrierSpacing];
......@@ -1366,7 +1339,9 @@ void set_csi_meas_periodicity(const NR_ServingCellConfigCommon_t *scc, NR_CSI_Re
}
}
void config_csi_codebook(const rrc_pdsch_AntennaPorts_t *antennaports, const int max_layers, struct NR_CodebookConfig *codebookConfig)
static void config_csi_codebook(const rrc_pdsch_AntennaPorts_t *antennaports,
const int max_layers,
struct NR_CodebookConfig *codebookConfig)
{
const int num_ant_ports = antennaports->N1 * antennaports->N2 * antennaports->XP;
codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
......@@ -1465,14 +1440,14 @@ void config_csi_codebook(const rrc_pdsch_AntennaPorts_t *antennaports, const int
codebookConfig->codebookType.choice.type1->codebookMode = 1;
}
void config_csi_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_PUCCH_CSI_Resource_t *pucchcsires,
struct NR_SetupRelease_PDSCH_Config *pdsch_Config,
const rrc_pdsch_AntennaPorts_t *antennaports,
const int max_layers,
int rep_id,
int uid)
static void config_csi_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_PUCCH_CSI_Resource_t *pucchcsires,
struct NR_SetupRelease_PDSCH_Config *pdsch_Config,
const rrc_pdsch_AntennaPorts_t *antennaports,
const int max_layers,
int rep_id,
int uid)
{
NR_CSI_ReportConfig_t *csirep = calloc(1, sizeof(*csirep));
csirep->reportConfigId = rep_id;
......@@ -1530,12 +1505,12 @@ void config_csi_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
asn1cSeqAdd(&csi_MeasConfig->csi_ReportConfigToAddModList->list, csirep);
}
void config_rsrp_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_PUCCH_CSI_Resource_t *pucchcsires,
int do_csi, // if rsrp is based on CSI or SSB
int rep_id,
int uid)
static void config_rsrp_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_PUCCH_CSI_Resource_t *pucchcsires,
int do_csi, // if rsrp is based on CSI or SSB
int rep_id,
int uid)
{
NR_CSI_ReportConfig_t *csirep = calloc(1, sizeof(*csirep));
csirep->reportConfigId = rep_id;
......@@ -1576,3 +1551,1274 @@ void config_rsrp_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
*csirep->groupBasedBeamReporting.choice.disabled->nrofReportedRS = NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1;
asn1cSeqAdd(&csi_MeasConfig->csi_ReportConfigToAddModList->list, csirep);
}
static void update_cqitables(struct NR_SetupRelease_PDSCH_Config *pdsch_Config, NR_CSI_MeasConfig_t *csi_MeasConfig)
{
int nb_csi = csi_MeasConfig->csi_ReportConfigToAddModList->list.count;
for (int i = 0; i < nb_csi; i++) {
NR_CSI_ReportConfig_t *csirep = csi_MeasConfig->csi_ReportConfigToAddModList->list.array[i];
if(csirep->cqi_Table) {
if(pdsch_Config->choice.setup->mcs_Table!=NULL)
*csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table2;
else
*csirep->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
}
}
}
NR_BCCH_BCH_Message_t *get_new_MIB_NR(const NR_ServingCellConfigCommon_t *scc)
{
NR_BCCH_BCH_Message_t *mib = calloc(1, sizeof(*mib));
if (mib == NULL)
abort();
mib->message.present = NR_BCCH_BCH_MessageType_PR_mib;
mib->message.choice.mib = calloc(1, sizeof(struct NR_MIB));
if (mib->message.choice.mib == NULL)
abort();
// 36.331 SFN BIT STRING (SIZE (8) , 38.331 SFN BIT STRING (SIZE (6))
uint8_t sfn_msb = 0; // encoding will update with the correct frame number
mib->message.choice.mib->systemFrameNumber.buf = CALLOC(1, sizeof(uint8_t));
mib->message.choice.mib->systemFrameNumber.buf[0] = sfn_msb << 2;
mib->message.choice.mib->systemFrameNumber.size = 1;
mib->message.choice.mib->systemFrameNumber.bits_unused = 2;
// 38.331 spare BIT STRING (SIZE (1))
uint16_t *spare = CALLOC(1, sizeof(uint16_t));
if (spare == NULL)
abort();
mib->message.choice.mib->spare.buf = (uint8_t *)spare;
mib->message.choice.mib->spare.size = 1;
mib->message.choice.mib->spare.bits_unused = 7; // This makes a spare of 1 bits
AssertFatal(scc->ssbSubcarrierSpacing != NULL, "scc->ssbSubcarrierSpacing is null\n");
int band = *scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
frequency_range_t frequency_range = band < 100 ? FR1 : FR2;
int ssb_subcarrier_offset = 31; // default value for NSA
if (get_softmodem_params()->sa) {
uint32_t absolute_diff = (*scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencySSB
- scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA);
int scs_scaling = scc->downlinkConfigCommon->frequencyInfoDL->absoluteFrequencyPointA < 600000 ? 3 : 1;
ssb_subcarrier_offset = (absolute_diff / scs_scaling) % 24;
if (frequency_range == FR2) {
// this assumes 120kHz SCS for SSB and subCarrierSpacingCommon (only
// option supported by OAI for now)
ssb_subcarrier_offset >>= 1;
}
}
mib->message.choice.mib->ssb_SubcarrierOffset = ssb_subcarrier_offset & 15;
/*
* The SIB1 will be sent in this allocation (Type0-PDCCH) : 38.213, 13-4 Table and 38.213 13-11 to 13-14 tables
* the reverse allocation is in nr_ue_decode_mib()
*/
const NR_PDCCH_ConfigCommon_t *pdcch_cc = scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon->choice.setup;
long cset0 = pdcch_cc->controlResourceSetZero ? *pdcch_cc->controlResourceSetZero : 0;
mib->message.choice.mib->pdcch_ConfigSIB1.controlResourceSetZero = cset0;
long ss0 = pdcch_cc->searchSpaceZero ? *pdcch_cc->searchSpaceZero : 0;
mib->message.choice.mib->pdcch_ConfigSIB1.searchSpaceZero = ss0;
switch (*scc->ssbSubcarrierSpacing) {
case NR_SubcarrierSpacing_kHz15:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
break;
case NR_SubcarrierSpacing_kHz30:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
break;
case NR_SubcarrierSpacing_kHz60:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs15or60;
break;
case NR_SubcarrierSpacing_kHz120:
mib->message.choice.mib->subCarrierSpacingCommon = NR_MIB__subCarrierSpacingCommon_scs30or120;
break;
case NR_SubcarrierSpacing_kHz240:
AssertFatal(1 == 0, "Unknown subCarrierSpacingCommon %d\n", (int)*scc->ssbSubcarrierSpacing);
break;
default:
AssertFatal(1 == 0, "Unknown subCarrierSpacingCommon %d\n", (int)*scc->ssbSubcarrierSpacing);
}
switch (scc->dmrs_TypeA_Position) {
case NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos2:
mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos2;
break;
case NR_ServingCellConfigCommon__dmrs_TypeA_Position_pos3:
mib->message.choice.mib->dmrs_TypeA_Position = NR_MIB__dmrs_TypeA_Position_pos3;
break;
default:
AssertFatal(1 == 0, "Unknown dmrs_TypeA_Position %d\n", (int)scc->dmrs_TypeA_Position);
}
mib->message.choice.mib->cellBarred = NR_MIB__cellBarred_notBarred;
mib->message.choice.mib->intraFreqReselection = NR_MIB__intraFreqReselection_notAllowed;
return mib;
}
void free_MIB_NR(NR_BCCH_BCH_Message_t *mib)
{
ASN_STRUCT_FREE(asn_DEF_NR_BCCH_BCH_Message, mib);
}
int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_size)
{
DevAssert(mib != NULL && mib->message.choice.mib->systemFrameNumber.buf != NULL);
uint8_t sfn_msb = (uint8_t)((frame >> 4) & 0x3f);
*mib->message.choice.mib->systemFrameNumber.buf = sfn_msb << 2;
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_BCH_Message, NULL, mib, buf, buf_size);
AssertFatal(enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
LOG_D(NR_RRC, "Encoded MIB for frame %d sfn_msb %d, bits %lu\n", frame, sfn_msb, enc_rval.encoded);
return (enc_rval.encoded + 7) / 8;
}
NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration)
{
NR_BCCH_DL_SCH_Message_t *sib1_message = CALLOC(1,sizeof(NR_BCCH_DL_SCH_Message_t));
AssertFatal(sib1_message != NULL, "out of memory\n");
sib1_message->message.present = NR_BCCH_DL_SCH_MessageType_PR_c1;
sib1_message->message.choice.c1 = CALLOC(1,sizeof(struct NR_BCCH_DL_SCH_MessageType__c1));
AssertFatal(sib1_message->message.choice.c1 != NULL, "out of memory\n");
sib1_message->message.choice.c1->present = NR_BCCH_DL_SCH_MessageType__c1_PR_systemInformationBlockType1;
sib1_message->message.choice.c1->choice.systemInformationBlockType1 = CALLOC(1,sizeof(struct NR_SIB1));
AssertFatal(sib1_message->message.choice.c1->choice.systemInformationBlockType1 != NULL, "out of memory\n");
struct NR_SIB1 *sib1 = sib1_message->message.choice.c1->choice.systemInformationBlockType1;
// cellSelectionInfo
sib1->cellSelectionInfo = CALLOC(1,sizeof(*sib1->cellSelectionInfo));
AssertFatal(sib1->cellSelectionInfo != NULL, "out of memory\n");
// Fixme: should be in config file
//The IE Q-RxLevMin is used to indicate for cell selection/ re-selection the required minimum received RSRP level in the (NR) cell.
//Corresponds to parameter Qrxlevmin in TS38.304.
//Actual value Qrxlevmin = field value * 2 [dBm].
sib1->cellSelectionInfo->q_RxLevMin = -65;
// cellAccessRelatedInfo
// TODO : Add support for more than one PLMN
int num_plmn = 1; // int num_plmn = configuration->num_plmn;
asn1cSequenceAdd(sib1->cellAccessRelatedInfo.plmn_IdentityInfoList.list, struct NR_PLMN_IdentityInfo, nr_plmn_info);
for (int i = 0; i < num_plmn; ++i) {
asn1cSequenceAdd(nr_plmn_info->plmn_IdentityList.list, struct NR_PLMN_Identity, nr_plmn);
asn1cCalloc(nr_plmn->mcc, mcc);
int confMcc = configuration->mcc[i];
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc0);
*mcc0 = (confMcc / 100) % 10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc1);
*mcc1 = (confMcc / 10) % 10;
asn1cSequenceAdd(mcc->list, NR_MCC_MNC_Digit_t, mcc2);
*mcc2 = confMcc % 10;
int mnc = configuration->mnc[i];
if (configuration->mnc_digit_length[i] == 3) {
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc0);
*mnc0 = (configuration->mnc[i] / 100) % 10;
}
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc1);
*mnc1 = (mnc / 10) % 10;
asn1cSequenceAdd(nr_plmn->mnc.list, NR_MCC_MNC_Digit_t, mnc2);
*mnc2 = (mnc) % 10;
}
nr_plmn_info->cellIdentity.buf = CALLOC(1, 5);
AssertFatal(nr_plmn_info->cellIdentity.buf != NULL, "out of memory\n");
nr_plmn_info->cellIdentity.size = 5;
nr_plmn_info->cellIdentity.bits_unused = 4;
uint64_t tmp = htobe64(configuration->cell_identity) << 4;
memcpy(nr_plmn_info->cellIdentity.buf, ((char *)&tmp) + 3, 5);
nr_plmn_info->cellReservedForOperatorUse = NR_PLMN_IdentityInfo__cellReservedForOperatorUse_notReserved;
nr_plmn_info->trackingAreaCode = CALLOC(1, sizeof(NR_TrackingAreaCode_t));
AssertFatal(nr_plmn_info->trackingAreaCode != NULL, "out of memory\n");
uint32_t tmp2 = htobe32(configuration->tac);
nr_plmn_info->trackingAreaCode->buf = CALLOC(1, 3);
AssertFatal(nr_plmn_info->trackingAreaCode->buf != NULL, "out of memory\n");
memcpy(nr_plmn_info->trackingAreaCode->buf, ((char *)&tmp2) + 1, 3);
nr_plmn_info->trackingAreaCode->size = 3;
nr_plmn_info->trackingAreaCode->bits_unused = 0;
// connEstFailureControl
// TODO: add connEstFailureControl
//si-SchedulingInfo
/*sib1->si_SchedulingInfo = CALLOC(1,sizeof(struct NR_SI_SchedulingInfo));
asn_set_empty(&sib1->si_SchedulingInfo->schedulingInfoList.list);
sib1->si_SchedulingInfo->si_WindowLength = NR_SI_SchedulingInfo__si_WindowLength_s40;
struct NR_SchedulingInfo *schedulingInfo = CALLOC(1,sizeof(struct NR_SchedulingInfo));
schedulingInfo->si_BroadcastStatus = NR_SchedulingInfo__si_BroadcastStatus_broadcasting;
schedulingInfo->si_Periodicity = NR_SchedulingInfo__si_Periodicity_rf8;
asn_set_empty(&schedulingInfo->sib_MappingInfo.list);
NR_SIB_TypeInfo_t *sib_type3 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type3->type = NR_SIB_TypeInfo__type_sibType3;
sib_type3->valueTag = CALLOC(1,sizeof(sib_type3->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type3);
NR_SIB_TypeInfo_t *sib_type5 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type5->type = NR_SIB_TypeInfo__type_sibType5;
sib_type5->valueTag = CALLOC(1,sizeof(sib_type5->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type5);
NR_SIB_TypeInfo_t *sib_type4 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type4->type = NR_SIB_TypeInfo__type_sibType4;
sib_type4->valueTag = CALLOC(1,sizeof(sib_type4->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type4);
NR_SIB_TypeInfo_t *sib_type2 = CALLOC(1,sizeof(e_NR_SIB_TypeInfo__type));
sib_type2->type = NR_SIB_TypeInfo__type_sibType2;
sib_type2->valueTag = CALLOC(1,sizeof(sib_type2->valueTag));
asn1cSeqAdd(&schedulingInfo->sib_MappingInfo.list,sib_type2);
asn1cSeqAdd(&sib1->si_SchedulingInfo->schedulingInfoList.list,schedulingInfo);*/
// servingCellConfigCommon
asn1cCalloc(sib1->servingCellConfigCommon, ServCellCom);
NR_BWP_DownlinkCommon_t *initialDownlinkBWP = &ServCellCom->downlinkConfigCommon.initialDownlinkBWP;
initialDownlinkBWP->genericParameters = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters;
const NR_FrequencyInfoDL_t *frequencyInfoDL = configuration->scc->downlinkConfigCommon->frequencyInfoDL;
for (int i = 0; i < frequencyInfoDL->frequencyBandList.list.count; i++) {
asn1cSequenceAdd(ServCellCom->downlinkConfigCommon.frequencyInfoDL.frequencyBandList.list,
struct NR_NR_MultiBandInfo,
nrMultiBandInfo);
nrMultiBandInfo->freqBandIndicatorNR =
frequencyInfoDL->frequencyBandList.list.array[i];
}
int scs_scaling0 = 1 << (configuration->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing);
int scs_scaling = scs_scaling0;
int scs_scaling2 = scs_scaling0;
if (frequencyInfoDL->absoluteFrequencyPointA < 600000) {
scs_scaling = scs_scaling0 * 3;
}
if (frequencyInfoDL->absoluteFrequencyPointA > 2016666) {
scs_scaling = scs_scaling0 >> 2;
scs_scaling2 = scs_scaling0 >> 2;
}
uint32_t absolute_diff = (*frequencyInfoDL->absoluteFrequencySSB - frequencyInfoDL->absoluteFrequencyPointA);
sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA =
scs_scaling2 * (absolute_diff / (12 * scs_scaling) - 10);
LOG_I(NR_RRC,
"SIB1 freq: absoluteFrequencySSB %ld, absoluteFrequencyPointA %ld\n",
*frequencyInfoDL->absoluteFrequencySSB,
frequencyInfoDL->absoluteFrequencyPointA);
LOG_I(NR_RRC,
"SIB1 freq: absolute_diff %d, %d*(absolute_diff/(12*%d) - 10) %d\n",
absolute_diff,
scs_scaling2,
scs_scaling,
(int)sib1->servingCellConfigCommon->downlinkConfigCommon.frequencyInfoDL.offsetToPointA);
for (int i = 0; i < frequencyInfoDL->scs_SpecificCarrierList.list.count; i++) {
asn1cSeqAdd(&ServCellCom->downlinkConfigCommon.frequencyInfoDL.scs_SpecificCarrierList.list,
frequencyInfoDL->scs_SpecificCarrierList.list.array[i]);
}
initialDownlinkBWP->pdcch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdcch_ConfigCommon;
initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList =
CALLOC(1, sizeof(struct NR_PDCCH_ConfigCommon__commonSearchSpaceList));
AssertFatal(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList != NULL, "out of memory\n");
NR_SearchSpace_t *ss1 = rrc_searchspace_config(true, 1, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss1);
NR_SearchSpace_t *ss2 = rrc_searchspace_config(true, 2, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss2);
NR_SearchSpace_t *ss3 = rrc_searchspace_config(true, 3, 0);
asn1cSeqAdd(&initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list, ss3);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1, 0);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation, 3);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->pagingSearchSpace, 2);
asn1cCallocOne(initialDownlinkBWP->pdcch_ConfigCommon->choice.setup->ra_SearchSpace, 1);
initialDownlinkBWP->pdsch_ConfigCommon = configuration->scc->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon;
ServCellCom->downlinkConfigCommon.bcch_Config.modificationPeriodCoeff = NR_BCCH_Config__modificationPeriodCoeff_n2;
ServCellCom->downlinkConfigCommon.pcch_Config.defaultPagingCycle = NR_PagingCycle_rf256;
ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.present = NR_PCCH_Config__nAndPagingFrameOffset_PR_quarterT;
ServCellCom->downlinkConfigCommon.pcch_Config.nAndPagingFrameOffset.choice.quarterT = 1;
ServCellCom->downlinkConfigCommon.pcch_Config.ns = NR_PCCH_Config__ns_one;
asn1cCalloc(ServCellCom->downlinkConfigCommon.pcch_Config.firstPDCCH_MonitoringOccasionOfPO, P0);
P0->present = NR_PCCH_Config__firstPDCCH_MonitoringOccasionOfPO_PR_sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT;
asn1cCalloc(P0->choice.sCS120KHZoneT_SCS60KHZhalfT_SCS30KHZquarterT_SCS15KHZoneEighthT, Z8);
asn1cSequenceAdd(Z8->list, long, ZoneEight);
asn1cCallocOne(ZoneEight, 0);
asn1cCalloc(ServCellCom->uplinkConfigCommon, UL);
asn_set_empty(&UL->frequencyInfoUL.scs_SpecificCarrierList.list);
const NR_FrequencyInfoUL_t *frequencyInfoUL = configuration->scc->uplinkConfigCommon->frequencyInfoUL;
for (int i = 0; i < frequencyInfoUL->scs_SpecificCarrierList.list.count; i++) {
asn1cSeqAdd(&UL->frequencyInfoUL.scs_SpecificCarrierList.list, frequencyInfoUL->scs_SpecificCarrierList.list.array[i]);
}
asn1cCallocOne(UL->frequencyInfoUL.p_Max, *frequencyInfoUL->p_Max);
UL->initialUplinkBWP.genericParameters = configuration->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters;
UL->initialUplinkBWP.rach_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon;
UL->initialUplinkBWP.pusch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon;
UL->initialUplinkBWP.pusch_ConfigCommon->choice.setup->groupHoppingEnabledTransformPrecoding = NULL;
UL->initialUplinkBWP.pucch_ConfigCommon = configuration->scc->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon;
UL->timeAlignmentTimerCommon = NR_TimeAlignmentTimer_infinity;
ServCellCom->n_TimingAdvanceOffset = configuration->scc->n_TimingAdvanceOffset;
ServCellCom->ssb_PositionsInBurst.inOneGroup.buf = calloc(1, sizeof(uint8_t));
uint8_t bitmap8,temp_bitmap=0;
switch (configuration->scc->ssb_PositionsInBurst->present) {
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_shortBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.shortBitmap;
break;
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_mediumBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup = configuration->scc->ssb_PositionsInBurst->choice.mediumBitmap;
break;
/*
* groupPresence: This field is present when maximum number of SS/PBCH blocks per half frame equals to 64 as defined in
* TS 38.213 [13], clause 4.1. The first/leftmost bit corresponds to the SS/PBCH index 0-7, the second bit corresponds to
* SS/PBCH block 8-15, and so on. Value 0 in the bitmap indicates that the SSBs according to inOneGroup are absent. Value 1
* indicates that the SS/PBCH blocks are transmitted in accordance with inOneGroup. inOneGroup: When maximum number of SS/PBCH
* blocks per half frame equals to 64 as defined in TS 38.213 [13], clause 4.1, all 8 bit are valid; The first/ leftmost bit
* corresponds to the first SS/PBCH block index in the group (i.e., to SSB index 0, 8, and so on); the second bit corresponds to
* the second SS/PBCH block index in the group (i.e., to SSB index 1, 9, and so on), and so on. Value 0 in the bitmap indicates
* that the corresponding SS/PBCH block is not transmitted while value 1 indicates that the corresponding SS/PBCH block is
* transmitted.
*/
case NR_ServingCellConfigCommon__ssb_PositionsInBurst_PR_longBitmap:
ServCellCom->ssb_PositionsInBurst.inOneGroup.size = 1;
ServCellCom->ssb_PositionsInBurst.inOneGroup.bits_unused = 0;
ServCellCom->ssb_PositionsInBurst.groupPresence = calloc(1, sizeof(BIT_STRING_t));
AssertFatal(ServCellCom->ssb_PositionsInBurst.groupPresence != NULL, "out of memory\n");
ServCellCom->ssb_PositionsInBurst.groupPresence->size = 1;
ServCellCom->ssb_PositionsInBurst.groupPresence->bits_unused = 0;
ServCellCom->ssb_PositionsInBurst.groupPresence->buf = calloc(1, sizeof(uint8_t));
AssertFatal(ServCellCom->ssb_PositionsInBurst.groupPresence->buf != NULL, "out of memory\n");
ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] = 0;
for (int i = 0; i < 8; i++) {
bitmap8 = configuration->scc->ssb_PositionsInBurst->choice.longBitmap.buf[i];
if (bitmap8 != 0) {
if (temp_bitmap == 0)
temp_bitmap = bitmap8;
else
AssertFatal(temp_bitmap == bitmap8,
"For longBitmap the groups of 8 SSBs containing at least 1 transmitted SSB should be all the same\n");
ServCellCom->ssb_PositionsInBurst.inOneGroup.buf[0] = bitmap8;
ServCellCom->ssb_PositionsInBurst.groupPresence->buf[0] |= 1<<(7-i);
}
}
break;
default:
AssertFatal(false, "ssb_PositionsInBurst not present\n");
break;
}
ServCellCom->ssb_PeriodicityServingCell = *configuration->scc->ssb_periodicityServingCell;
if (configuration->scc->tdd_UL_DL_ConfigurationCommon) {
ServCellCom->tdd_UL_DL_ConfigurationCommon = CALLOC(1,sizeof(struct NR_TDD_UL_DL_ConfigCommon));
AssertFatal(ServCellCom->tdd_UL_DL_ConfigurationCommon != NULL, "out of memory\n");
ServCellCom->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing = configuration->scc->tdd_UL_DL_ConfigurationCommon->referenceSubcarrierSpacing;
ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern1 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern1;
ServCellCom->tdd_UL_DL_ConfigurationCommon->pattern2 = configuration->scc->tdd_UL_DL_ConfigurationCommon->pattern2;
}
ServCellCom->ss_PBCH_BlockPower = configuration->scc->ss_PBCH_BlockPower;
// ims-EmergencySupport
// TODO: add ims-EmergencySupport
// eCallOverIMS-Support
// TODO: add eCallOverIMS-Support
// ue-TimersAndConstants
sib1->ue_TimersAndConstants = CALLOC(1,sizeof(struct NR_UE_TimersAndConstants));
AssertFatal(sib1->ue_TimersAndConstants != NULL, "out of memory\n");
sib1->ue_TimersAndConstants->t300 = NR_UE_TimersAndConstants__t300_ms400;
sib1->ue_TimersAndConstants->t301 = NR_UE_TimersAndConstants__t301_ms400;
sib1->ue_TimersAndConstants->t310 = NR_UE_TimersAndConstants__t310_ms2000;
sib1->ue_TimersAndConstants->n310 = NR_UE_TimersAndConstants__n310_n10;
sib1->ue_TimersAndConstants->t311 = NR_UE_TimersAndConstants__t311_ms3000;
sib1->ue_TimersAndConstants->n311 = NR_UE_TimersAndConstants__n311_n1;
sib1->ue_TimersAndConstants->t319 = NR_UE_TimersAndConstants__t319_ms400;
// uac-BarringInfo
/*sib1->uac_BarringInfo = CALLOC(1, sizeof(struct NR_SIB1__uac_BarringInfo));
NR_UAC_BarringInfoSet_t *nr_uac_BarringInfoSet = CALLOC(1, sizeof(NR_UAC_BarringInfoSet_t));
asn_set_empty(&sib1->uac_BarringInfo->uac_BarringInfoSetList);
nr_uac_BarringInfoSet->uac_BarringFactor = NR_UAC_BarringInfoSet__uac_BarringFactor_p95;
nr_uac_BarringInfoSet->uac_BarringTime = NR_UAC_BarringInfoSet__uac_BarringTime_s4;
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.buf = CALLOC(1, 1);
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.size = 1;
nr_uac_BarringInfoSet->uac_BarringForAccessIdentity.bits_unused = 1;
asn1cSeqAdd(&sib1->uac_BarringInfo->uac_BarringInfoSetList, nr_uac_BarringInfoSet);*/
// useFullResumeID
// TODO: add useFullResumeID
// lateNonCriticalExtension
// TODO: add lateNonCriticalExtension
// nonCriticalExtension
// TODO: add nonCriticalExtension
//xer_fprint(stdout, &asn_DEF_NR_SIB1, (const void*)sib1_message->message.choice.c1->choice.systemInformationBlockType1);
return sib1_message;
}
void free_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1)
{
ASN_STRUCT_FREE(asn_DEF_NR_BCCH_DL_SCH_Message, sib1);
}
int encode_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1, uint8_t *buffer, int max_buffer_size)
{
AssertFatal(max_buffer_size <= NR_MAX_SIB_LENGTH / 8,
"%s(): maximum buffer size too large: 3GPP TS 38.331 section 5.2.1 - The physical layer imposes a limit to the "
"maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits.\n",
__func__);
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_BCCH_DL_SCH_Message, NULL, sib1, buffer, max_buffer_size);
AssertFatal(enc_rval.encoded > 0 && enc_rval.encoded <= max_buffer_size * 8, "ASN1 message encoding failed (%s, %lu)!\n", enc_rval.failed_type->name, enc_rval.encoded);
return (enc_rval.encoded + 7) / 8;
}
static NR_MAC_CellGroupConfig_t *configure_mac_cellgroup(void)
{
NR_MAC_CellGroupConfig_t * mac_CellGroupConfig = calloc(1, sizeof(*mac_CellGroupConfig));
mac_CellGroupConfig->bsr_Config = calloc(1, sizeof(*mac_CellGroupConfig->bsr_Config));
mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10;
mac_CellGroupConfig->bsr_Config->retxBSR_Timer = NR_BSR_Config__retxBSR_Timer_sf80;
mac_CellGroupConfig->tag_Config = calloc(1, sizeof(*mac_CellGroupConfig->tag_Config));
mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL;
mac_CellGroupConfig->tag_Config->tag_ToAddModList = calloc(1,sizeof(*mac_CellGroupConfig->tag_Config->tag_ToAddModList));
struct NR_TAG *tag=calloc(1,sizeof(*tag));
tag->tag_Id = 0;
tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity;
asn1cSeqAdd(&mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag);
set_phr_config(mac_CellGroupConfig);
mac_CellGroupConfig->schedulingRequestConfig = calloc(1, sizeof(*mac_CellGroupConfig->schedulingRequestConfig));
mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = CALLOC(1,sizeof(*mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList));
struct NR_SchedulingRequestToAddMod *schedulingrequestlist = CALLOC(1,sizeof(*schedulingrequestlist));
schedulingrequestlist->schedulingRequestId = 0;
schedulingrequestlist->sr_ProhibitTimer = NULL;
schedulingrequestlist->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n64;
asn1cSeqAdd(&(mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list),schedulingrequestlist);
mac_CellGroupConfig->skipUplinkTxDynamic=false;
mac_CellGroupConfig->ext1 = NULL;
return mac_CellGroupConfig;
}
static NR_SpCellConfig_t *get_initial_SpCellConfig(int uid,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration)
{
// This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4.
// However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources,
// where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations.
AssertFatal(uid >= 0 && uid < 30, "gNB cannot allocate the SRS resources\n");
const int pdsch_AntennaPorts =
configuration->pdsch_AntennaPorts.N1 * configuration->pdsch_AntennaPorts.N2 * configuration->pdsch_AntennaPorts.XP;
int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
NR_SpCellConfig_t *SpCellConfig = calloc(1, sizeof(*SpCellConfig));
SpCellConfig->servCellIndex = NULL;
SpCellConfig->reconfigurationWithSync = NULL;
SpCellConfig->rlmInSyncOutOfSyncThreshold = NULL;
SpCellConfig->rlf_TimersAndConstants = NULL;
SpCellConfig->spCellConfigDedicated = calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated));
SpCellConfig->spCellConfigDedicated->uplinkConfig = calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->uplinkConfig));
NR_UplinkConfig_t *uplinkConfig = SpCellConfig->spCellConfigDedicated->uplinkConfig;
NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1, sizeof(*initialUplinkBWP));
uplinkConfig->initialUplinkBWP = initialUplinkBWP;
initialUplinkBWP->pucch_Config = calloc(1, sizeof(*initialUplinkBWP->pucch_Config));
initialUplinkBWP->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup;
NR_PUCCH_Config_t *pucch_Config = calloc(1, sizeof(*pucch_Config));
initialUplinkBWP->pucch_Config->choice.setup = pucch_Config;
pucch_Config->resourceSetToAddModList = calloc(1, sizeof(*pucch_Config->resourceSetToAddModList));
pucch_Config->resourceSetToReleaseList = NULL;
pucch_Config->resourceToAddModList = calloc(1, sizeof(*pucch_Config->resourceToAddModList));
pucch_Config->resourceToReleaseList = NULL;
config_pucch_resset0(pucch_Config, uid, curr_bwp, NULL);
config_pucch_resset1(pucch_Config, NULL);
set_pucch_power_config(pucch_Config, configuration->do_CSIRS);
initialUplinkBWP->pusch_Config = config_pusch(NULL);
long maxMIMO_Layers = uplinkConfig && uplinkConfig->pusch_ServingCellConfig
&& uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1
&& uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
? *uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
: 1;
// We are using do_srs = 0 here because the periodic SRS will only be enabled in update_cellGroupConfig() if do_srs == 1
initialUplinkBWP->srs_Config = calloc(1, sizeof(*initialUplinkBWP->srs_Config));
config_srs(scc, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, 0);
scheduling_request_config(scc, pucch_Config, scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing);
set_dl_DataToUL_ACK(pucch_Config,
configuration->minRXTXTIME,
scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.subcarrierSpacing);
SpCellConfig->spCellConfigDedicated->initialDownlinkBWP =
calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->initialDownlinkBWP));
NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP;
bwp_Dedicated->pdcch_Config = calloc(1, sizeof(*bwp_Dedicated->pdcch_Config));
bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup;
bwp_Dedicated->pdcch_Config->choice.setup = calloc(1, sizeof(*bwp_Dedicated->pdcch_Config->choice.setup));
bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList =
calloc(1, sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList =
calloc(1, sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList));
uint64_t bitmap = get_ssb_bitmap(scc);
NR_ControlResourceSet_t *coreset = get_coreset_config(0, curr_bwp, bitmap);
asn1cSeqAdd(&bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list, coreset);
bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList =
calloc(1, sizeof(*bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
NR_SearchSpace_t *ss2 = rrc_searchspace_config(false, 5, coreset->controlResourceSetId);
asn1cSeqAdd(&bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list, ss2);
bwp_Dedicated->pdsch_Config = config_pdsch(bitmap, 0, pdsch_AntennaPorts);
SpCellConfig->spCellConfigDedicated->tag_Id = 0;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig =
calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1, sizeof(*pdsch_servingcellconfig));
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
SpCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
// Downlink BWPs
int n_dl_bwp = 0;
if (servingcellconfigdedicated && servingcellconfigdedicated->downlinkBWP_ToAddModList
&& servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count > 0) {
n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count;
}
if (n_dl_bwp > 0) {
SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList =
calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp));
config_downlinkBWP(bwp, scc, servingcellconfigdedicated, NULL, 0, false, bwp_loop, true);
asn1cSeqAdd(&SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list, bwp);
}
SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id =
calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
*SpCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id =
servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1;
SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id =
calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
*SpCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id =
servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1;
}
// Uplink BWPs
int n_ul_bwp = 0;
if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig
&& servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList
&& servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count > 0) {
n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count;
}
if (n_ul_bwp > 0) {
uplinkConfig->uplinkBWP_ToAddModList = calloc(1, sizeof(*uplinkConfig->uplinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) {
NR_BWP_Uplink_t *ubwp = calloc(1, sizeof(*ubwp));
config_uplinkBWP(ubwp, bwp_loop, true, uid, configuration, servingcellconfigdedicated, scc, NULL);
asn1cSeqAdd(&uplinkConfig->uplinkBWP_ToAddModList->list, ubwp);
}
uplinkConfig->firstActiveUplinkBWP_Id = calloc(1, sizeof(*uplinkConfig->firstActiveUplinkBWP_Id));
*uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id
? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id
: 1;
}
SpCellConfig->spCellConfigDedicated->csi_MeasConfig = calloc(1, sizeof(*SpCellConfig->spCellConfigDedicated->csi_MeasConfig));
SpCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1, sizeof(*csi_MeasConfig));
SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1, sizeof(*ssbresset0));
ssbresset0->csi_SSB_ResourceSetId = 0;
for (int i = 0; i < 64; i++) {
if ((bitmap >> (63 - i)) & 0x01) {
NR_SSB_Index_t *ssbres = NULL;
asn1cCallocOne(ssbres, i);
asn1cSeqAdd(&ssbresset0->csi_SSB_ResourceList.list, ssbres);
}
}
asn1cSeqAdd(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list, ssbresset0);
int bwp_loop_end = n_dl_bwp > 0 ? n_dl_bwp : 1;
for (int bwp_loop = 0; bwp_loop < bwp_loop_end; bwp_loop++) {
int curr_bwp, bwp_id;
struct NR_SetupRelease_PDSCH_Config *pdsch_Config;
if (n_dl_bwp == 0) {
pdsch_Config = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config;
curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
bwp_id = 0;
} else {
NR_BWP_Downlink_t *bwp = SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop];
pdsch_Config = bwp->bwp_Dedicated->pdsch_Config;
curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
bwp_id = bwp->bwp_Id;
}
config_csirs(scc, csi_MeasConfig, uid, pdsch_AntennaPorts, curr_bwp, configuration->do_CSIRS, bwp_loop);
config_csiim(configuration->do_CSIRS, pdsch_AntennaPorts, curr_bwp, csi_MeasConfig, bwp_loop);
NR_CSI_ResourceConfig_t *csires1 = calloc(1, sizeof(*csires1));
csires1->csi_ResourceConfigId = bwp_id + 20;
csires1->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB =
calloc(1, sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList =
calloc(1, sizeof(*csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList));
NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1, sizeof(*ssbres00));
*ssbres00 = 0;
asn1cSeqAdd(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list, ssbres00);
csires1->bwp_Id = bwp_id;
csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, csires1);
NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1, sizeof(*pucchcsires1));
pucchcsires1->uplinkBandwidthPartId = bwp_id;
pucchcsires1->pucch_Resource = 2;
if (configuration->do_CSIRS) {
NR_CSI_ResourceConfig_t *csires0 = calloc(1, sizeof(*csires0));
csires0->csi_ResourceConfigId = bwp_id;
csires0->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB =
calloc(1, sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList =
calloc(1, sizeof(*csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1, sizeof(*nzp0));
*nzp0 = bwp_loop;
asn1cSeqAdd(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list, nzp0);
csires0->bwp_Id = bwp_id;
csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, csires0);
}
if (configuration->do_CSIRS && pdsch_AntennaPorts > 1) {
NR_CSI_ResourceConfig_t *csires2 = calloc(1, sizeof(*csires2));
csires2->csi_ResourceConfigId = bwp_id + 10;
csires2->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList =
calloc(1, sizeof(*csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1, sizeof(*csiim00));
*csiim00 = bwp_loop;
asn1cSeqAdd(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list, csiim00);
csires2->bwp_Id = bwp_id;
csires2->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, csires2);
config_csi_meas_report(csi_MeasConfig,
scc,
pucchcsires1,
pdsch_Config,
&configuration->pdsch_AntennaPorts,
NR_MAX_SUPPORTED_DL_LAYERS,
bwp_id,
uid);
}
config_rsrp_meas_report(csi_MeasConfig, scc, pucchcsires1, configuration->do_CSIRS, bwp_id + 10, uid);
}
pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
pdsch_servingcellconfig->xOverhead = NULL;
pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
pdsch_servingcellconfig->pucch_Cell = NULL;
pdsch_servingcellconfig->ext1 = calloc(1, sizeof(*pdsch_servingcellconfig->ext1));
pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1, sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
*pdsch_servingcellconfig->ext1->maxMIMO_Layers = 2;
if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, SpCellConfig);
}
return SpCellConfig;
}
NR_CellGroupConfig_t *get_initial_cellGroupConfig(int uid,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration)
{
NR_CellGroupConfig_t *cellGroupConfig = calloc(1, sizeof(*cellGroupConfig));
cellGroupConfig->cellGroupId = 0;
/* Rlc Bearer Config */
/* TS38.331 9.2.1 Default SRB configurations */
cellGroupConfig->rlc_BearerToAddModList = calloc(1, sizeof(*cellGroupConfig->rlc_BearerToAddModList));
NR_RLC_BearerConfig_t *rlc_BearerConfig =
get_SRB_RLC_BearerConfig(1, 1, NR_LogicalChannelConfig__ul_SpecificParameters__bucketSizeDuration_ms1000);
asn1cSeqAdd(&cellGroupConfig->rlc_BearerToAddModList->list, rlc_BearerConfig);
cellGroupConfig->rlc_BearerToReleaseList = NULL;
/* mac CellGroup Config */
cellGroupConfig->mac_CellGroupConfig = configure_mac_cellgroup();
NR_PhysicalCellGroupConfig_t *physicalCellGroupConfig = calloc(1, sizeof(*physicalCellGroupConfig));
physicalCellGroupConfig->p_NR_FR1 = NULL;
physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook = NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic;
cellGroupConfig->physicalCellGroupConfig = physicalCellGroupConfig;
cellGroupConfig->spCellConfig = get_initial_SpCellConfig(uid, scc, servingcellconfigdedicated, configuration);
cellGroupConfig->sCellToAddModList = NULL;
cellGroupConfig->sCellToReleaseList = NULL;
return cellGroupConfig;
}
void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
const int uid,
NR_UE_NR_Capability_t *uecap,
const gNB_RrcConfigurationReq *configuration)
{
DevAssert(cellGroupConfig != NULL);
/* this is wrong: we should not call this function is spCellConfig is not
* allocated */
if (cellGroupConfig->spCellConfig == NULL)
return;
/* same as for spCellConfig */
if (configuration == NULL)
return;
DevAssert(configuration->scc != NULL);
NR_SpCellConfig_t *SpCellConfig = cellGroupConfig->spCellConfig;
NR_ServingCellConfigCommon_t *scc = configuration->scc;
int curr_bwp = NRRIV2BW(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
NR_UplinkConfig_t *uplinkConfig =
SpCellConfig && SpCellConfig->spCellConfigDedicated ? SpCellConfig->spCellConfigDedicated->uplinkConfig : NULL;
uint8_t ul_max_layers = 1;
if (uecap && uecap->featureSets && uecap->featureSets->featureSetsUplinkPerCC
&& uecap->featureSets->featureSetsUplinkPerCC->list.count > 0) {
NR_FeatureSetUplinkPerCC_t *ul_feature_setup_per_cc = uecap->featureSets->featureSetsUplinkPerCC->list.array[0];
if (ul_feature_setup_per_cc->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH) {
switch (*ul_feature_setup_per_cc->mimo_CB_PUSCH->maxNumberMIMO_LayersCB_PUSCH) {
case NR_MIMO_LayersUL_twoLayers:
ul_max_layers = 2;
break;
case NR_MIMO_LayersUL_fourLayers:
ul_max_layers = 4;
break;
default:
ul_max_layers = 1;
}
}
ul_max_layers = min(ul_max_layers, configuration->pusch_AntennaPorts);
if (uplinkConfig->initialUplinkBWP->pusch_Config) {
NR_PUSCH_Config_t *pusch_Config = uplinkConfig->initialUplinkBWP->pusch_Config->choice.setup;
if (pusch_Config->maxRank == NULL) {
pusch_Config->maxRank = calloc(1, sizeof(*pusch_Config->maxRank));
}
*pusch_Config->maxRank = ul_max_layers;
}
if (uplinkConfig->pusch_ServingCellConfig == NULL) {
uplinkConfig->pusch_ServingCellConfig = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig));
uplinkConfig->pusch_ServingCellConfig->present = NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup;
uplinkConfig->pusch_ServingCellConfig->choice.setup = calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup));
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1 =
calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1));
uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers =
calloc(1, sizeof(*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers));
}
*uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers = ul_max_layers;
}
long maxMIMO_Layers = uplinkConfig && uplinkConfig->pusch_ServingCellConfig
&& uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1
&& uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
? *uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
: 1;
// UL and SRS configuration
if (configuration->do_SRS && uplinkConfig && uplinkConfig->initialUplinkBWP) {
if (!uplinkConfig->initialUplinkBWP->srs_Config) {
uplinkConfig->initialUplinkBWP->srs_Config = calloc(1, sizeof(*uplinkConfig->initialUplinkBWP->srs_Config));
}
config_srs(scc,
SpCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->srs_Config,
uecap,
curr_bwp,
uid,
0,
maxMIMO_Layers,
configuration->do_SRS);
}
// Set DL MCS table
NR_BWP_DownlinkDedicated_t *bwp_Dedicated = SpCellConfig->spCellConfigDedicated->initialDownlinkBWP;
set_dl_mcs_table(scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters.subcarrierSpacing,
configuration->force_256qam_off ? NULL : uecap,
bwp_Dedicated,
scc);
struct NR_ServingCellConfig__downlinkBWP_ToAddModList *DL_BWP_list =
SpCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList;
struct NR_UplinkConfig__uplinkBWP_ToAddModList *UL_BWP_list = uplinkConfig->uplinkBWP_ToAddModList;
if (DL_BWP_list) {
for (int i = 0; i < DL_BWP_list->list.count; i++) {
NR_BWP_Downlink_t *bwp = DL_BWP_list->list.array[i];
int scs = bwp->bwp_Common->genericParameters.subcarrierSpacing;
set_dl_mcs_table(scs, configuration->force_256qam_off ? NULL : uecap, bwp->bwp_Dedicated, scc);
}
}
if (configuration->do_SRS && UL_BWP_list) {
for (int i = 0; i < UL_BWP_list->list.count; i++) {
NR_BWP_Uplink_t *ul_bwp = UL_BWP_list->list.array[i];
int bwp_size = NRRIV2BW(ul_bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
if (ul_bwp->bwp_Dedicated->pusch_Config) {
NR_PUSCH_Config_t *pusch_Config = ul_bwp->bwp_Dedicated->pusch_Config->choice.setup;
if (pusch_Config->maxRank == NULL) {
pusch_Config->maxRank = calloc(1, sizeof(*pusch_Config->maxRank));
}
*pusch_Config->maxRank = ul_max_layers;
}
config_srs(scc, ul_bwp->bwp_Dedicated->srs_Config, uecap, bwp_size, uid, i + 1, maxMIMO_Layers, configuration->do_SRS);
}
}
update_cqitables(bwp_Dedicated->pdsch_Config, SpCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup);
}
void free_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig)
{
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, cellGroupConfig);
}
int encode_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t *buffer, int max_buffer_size)
{
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, cellGroupConfig, buffer, max_buffer_size);
AssertFatal(enc_rval.encoded > 0 && enc_rval.encoded <= max_buffer_size * 8,
"ASN1 message encoding failed (%s, %lu)!\n",
enc_rval.failed_type->name,
enc_rval.encoded);
return (enc_rval.encoded + 7) / 8;
}
NR_CellGroupConfig_t *decode_cellGroupConfig(const uint8_t *buffer, int buffer_size)
{
NR_CellGroupConfig_t *cellGroupConfig = NULL;
asn_dec_rval_t rval = uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cellGroupConfig, buffer, buffer_size, 0, 0);
AssertFatal(rval.code == RC_OK, "could not decode cellGroupConfig\n");
return cellGroupConfig;
}
/* TODO: this should disappear */
static void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd)
{
int b = 0;
while (b < scd->downlinkBWP_ToAddModList->list.count) {
if (scd->downlinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) {
asn_sequence_del(&scd->downlinkBWP_ToAddModList->list, b, 1);
} else {
b++;
}
}
if (scd->downlinkBWP_ToAddModList->list.count == 0) {
free(scd->downlinkBWP_ToAddModList);
scd->downlinkBWP_ToAddModList = NULL;
}
b = 0;
while (b < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count) {
if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) {
asn_sequence_del(&scd->uplinkConfig->uplinkBWP_ToAddModList->list, b, 1);
} else {
b++;
}
}
if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.count == 0) {
free(scd->uplinkConfig->uplinkBWP_ToAddModList);
scd->uplinkConfig->uplinkBWP_ToAddModList = NULL;
}
}
NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_UE_NR_Capability_t *uecap,
int scg_id,
int servCellIndex,
const gNB_RrcConfigurationReq *configuration,
int uid)
{
const rrc_pdsch_AntennaPorts_t *pdschap = &configuration->pdsch_AntennaPorts;
const int dl_antenna_ports = pdschap->N1 * pdschap->N2 * pdschap->XP;
const int do_csirs = configuration->do_CSIRS;
AssertFatal(servingcellconfigcommon != NULL, "servingcellconfigcommon is null\n");
if (uecap == NULL)
LOG_E(RRC, "No UE Capabilities available when programming default CellGroup in NSA\n");
// This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4.
// However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources,
// where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations.
AssertFatal(uid >= 0 && uid < 30, "gNB cannot allocate the SRS resources\n");
uint64_t bitmap = get_ssb_bitmap(servingcellconfigcommon);
// See comment at the end of this function regarding ServingCellConfig
fix_servingcellconfigdedicated(servingcellconfigdedicated);
NR_CellGroupConfig_t *secondaryCellGroup = calloc(1, sizeof(*secondaryCellGroup));
secondaryCellGroup->cellGroupId = scg_id;
/* LCID is 4 because the RLC layer requires it to be 3+rb_id; the rb_id is 1
* for first RB. We pre-configure RLC UM Bi-directional, priority is 1 */
NR_RLC_BearerConfig_t *RLC_BearerConfig = get_DRB_RLC_BearerConfig(4, 1, NR_RLC_Config_PR_um_Bi_Directional, 1);
secondaryCellGroup->rlc_BearerToAddModList = calloc(1, sizeof(*secondaryCellGroup->rlc_BearerToAddModList));
asn1cSeqAdd(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig);
secondaryCellGroup->mac_CellGroupConfig = configure_mac_cellgroup();
secondaryCellGroup->physicalCellGroupConfig = calloc(1, sizeof(*secondaryCellGroup->physicalCellGroupConfig));
secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH = NULL;
secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH = NULL;
secondaryCellGroup->physicalCellGroupConfig->p_NR_FR1 = NULL;
secondaryCellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook =
NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic;
secondaryCellGroup->physicalCellGroupConfig->tpc_SRS_RNTI = NULL;
secondaryCellGroup->physicalCellGroupConfig->tpc_PUCCH_RNTI = NULL;
secondaryCellGroup->physicalCellGroupConfig->tpc_PUSCH_RNTI = NULL;
secondaryCellGroup->physicalCellGroupConfig->sp_CSI_RNTI = NULL;
secondaryCellGroup->physicalCellGroupConfig->cs_RNTI = NULL;
secondaryCellGroup->physicalCellGroupConfig->ext1 = NULL;
secondaryCellGroup->spCellConfig = calloc(1, sizeof(*secondaryCellGroup->spCellConfig));
secondaryCellGroup->spCellConfig->servCellIndex = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->servCellIndex));
*secondaryCellGroup->spCellConfig->servCellIndex = servCellIndex;
secondaryCellGroup->spCellConfig->reconfigurationWithSync =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->reconfigurationWithSync));
NR_ReconfigurationWithSync_t *reconfigurationWithSync = secondaryCellGroup->spCellConfig->reconfigurationWithSync;
reconfigurationWithSync->spCellConfigCommon =
(NR_ServingCellConfigCommon_t *)servingcellconfigcommon;
reconfigurationWithSync->newUE_Identity =
(get_softmodem_params()->phy_test == 1) ? 0x1234 : (taus() & 0xffff);
reconfigurationWithSync->t304 = NR_ReconfigurationWithSync__t304_ms2000;
reconfigurationWithSync->rach_ConfigDedicated = NULL;
reconfigurationWithSync->ext1 = NULL;
// For 2-step contention-free random access procedure
reconfigurationWithSync->rach_ConfigDedicated = calloc(1, sizeof(*reconfigurationWithSync->rach_ConfigDedicated));
reconfigurationWithSync->rach_ConfigDedicated->present = NR_ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink = calloc(1, sizeof(struct NR_RACH_ConfigDedicated));
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra = calloc(1, sizeof(struct NR_CFRA));
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->ra_Prioritization = NULL;
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions = calloc(1, sizeof(struct NR_CFRA__occasions));
memcpy(&reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions->rach_ConfigGeneric,
&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric,
sizeof(NR_RACH_ConfigGeneric_t));
asn1cCallocOne(reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions->ssb_perRACH_Occasion,
NR_CFRA__occasions__ssb_perRACH_Occasion_one);
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.present = NR_CFRA__resources_PR_ssb;
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb =
calloc(1, sizeof(struct NR_CFRA__resources__ssb));
reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0;
int n_ssb = 0;
struct NR_CFRA_SSB_Resource *ssbElem[64];
for (int i = 0; i < 64; i++) {
if ((bitmap >> (63 - i)) & 0x01) {
ssbElem[n_ssb] = calloc(1, sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[n_ssb]->ssb = i;
ssbElem[n_ssb]->ra_PreambleIndex = 63 - (uid % 64);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources
.choice.ssb->ssb_ResourceList.list,
ssbElem[n_ssb]);
n_ssb++;
}
}
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->t310 = NR_RLF_TimersAndConstants__t310_ms4000;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n310 = NR_RLF_TimersAndConstants__n310_n20;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n311 = NR_RLF_TimersAndConstants__n311_n1;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1 =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1->t311 =
NR_RLF_TimersAndConstants__ext1__t311_ms30000;
secondaryCellGroup->spCellConfig->rlmInSyncOutOfSyncThreshold = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->tdd_UL_DL_ConfigurationDedicated = NULL;
/// initialDownlinkBWP
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdcch_Config = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config =
config_pdsch(bitmap, 0, dl_antenna_ports);
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config =
NULL; // calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL;
/// initialUplinkBWP
if (!secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig));
}
NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1, sizeof(*initialUplinkBWP));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP;
initialUplinkBWP->pucch_Config = NULL;
NR_PUSCH_Config_t *pusch_Config = NULL;
if (servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) {
pusch_Config =
servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup;
}
initialUplinkBWP->pusch_Config = config_pusch(pusch_Config);
long maxMIMO_Layers =
servingcellconfigdedicated->uplinkConfig && servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig
&& servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1
&& servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
? *servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers
: 1;
int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,
MAX_BWP_SIZE);
initialUplinkBWP->srs_Config = calloc(1, sizeof(*initialUplinkBWP->srs_Config));
config_srs(servingcellconfigcommon, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, configuration->do_SRS);
// Downlink BWPs
int n_dl_bwp = 1;
if (servingcellconfigdedicated && servingcellconfigdedicated->downlinkBWP_ToAddModList) {
n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count;
}
if (n_dl_bwp > 0) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp = calloc(1, sizeof(*bwp));
config_downlinkBWP(bwp,
servingcellconfigcommon,
servingcellconfigdedicated,
uecap,
dl_antenna_ports,
configuration->force_256qam_off,
bwp_loop,
false);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list, bwp);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id =
servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id =
servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1;
}
// Uplink BWPs
int n_ul_bwp = 1;
if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig
&& servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) {
n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count;
}
if (n_ul_bwp > 0) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) {
NR_BWP_Uplink_t *ubwp = calloc(1, sizeof(*ubwp));
config_uplinkBWP(ubwp, bwp_loop, false, uid, configuration, servingcellconfigdedicated, servingcellconfigcommon, uecap);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list, ubwp);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id =
servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id
? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id
: 1;
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig));
NR_PUSCH_ServingCellConfig_t *pusch_scc = calloc(1, sizeof(*pusch_scc));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->present =
NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup = pusch_scc;
pusch_scc->codeBlockGroupTransmission = NULL;
pusch_scc->rateMatching = NULL;
pusch_scc->xOverhead = NULL;
pusch_scc->ext1 = calloc(1, sizeof(*pusch_scc->ext1));
pusch_scc->ext1->maxMIMO_Layers = calloc(1, sizeof(*pusch_scc->ext1->maxMIMO_Layers));
*pusch_scc->ext1->maxMIMO_Layers = 1;
pusch_scc->ext1->processingType2Enabled = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1, sizeof(*pdsch_servingcellconfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present =
NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
pdsch_servingcellconfig->xOverhead = NULL;
pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
pdsch_servingcellconfig->pucch_Cell = NULL;
pdsch_servingcellconfig->ext1 = calloc(1, sizeof(*pdsch_servingcellconfig->ext1));
pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1, sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
*pdsch_servingcellconfig->ext1->maxMIMO_Layers = NR_MAX_SUPPORTED_DL_LAYERS;
pdsch_servingcellconfig->ext1->processingType2Enabled = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig =
calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1, sizeof(*csi_MeasConfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1, sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1, sizeof(*ssbresset0));
ssbresset0->csi_SSB_ResourceSetId = 0;
for (int i = 0; i < 64; i++) {
if ((bitmap >> (63 - i)) & 0x01) {
NR_SSB_Index_t *ssbres = NULL;
asn1cCallocOne(ssbres, i);
asn1cSeqAdd(&ssbresset0->csi_SSB_ResourceList.list, ssbres);
}
}
asn1cSeqAdd(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list, ssbresset0);
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp =
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop];
int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
config_csirs(servingcellconfigcommon, csi_MeasConfig, uid, dl_antenna_ports, curr_bwp, do_csirs, bwp_loop);
config_csiim(do_csirs, dl_antenna_ports, curr_bwp, csi_MeasConfig, bwp_loop);
if (do_csirs) {
NR_CSI_ResourceConfig_t *csires = calloc(1, sizeof(*csires));
csires->csi_ResourceConfigId = bwp->bwp_Id;
csires->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB =
calloc(1, sizeof(*csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList =
calloc(1, sizeof(*csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1, sizeof(*nzp0));
*nzp0 = bwp_loop;
asn1cSeqAdd(&csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list, nzp0);
csires->bwp_Id = bwp->bwp_Id;
csires->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, csires);
}
if (do_csirs && dl_antenna_ports > 1) {
NR_CSI_ResourceConfig_t *csiresim = calloc(1, sizeof(*csiresim));
csiresim->csi_ResourceConfigId = bwp->bwp_Id + 10;
csiresim->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList =
calloc(1, sizeof(*csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1, sizeof(*csiim00));
*csiim00 = bwp_loop;
asn1cSeqAdd(&csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list, csiim00);
csiresim->bwp_Id = bwp->bwp_Id;
csiresim->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, csiresim);
}
NR_CSI_ResourceConfig_t *ssbres = calloc(1, sizeof(*ssbres));
ssbres->csi_ResourceConfigId = bwp->bwp_Id + 20;
ssbres->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1, sizeof(*ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList =
calloc(1, sizeof(*ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList));
NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1, sizeof(*ssbres00));
*ssbres00 = 0;
asn1cSeqAdd(&ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list, ssbres00);
ssbres->bwp_Id = bwp->bwp_Id;
ssbres->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list, ssbres);
NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1, sizeof(*pucchcsires1));
pucchcsires1->uplinkBandwidthPartId = bwp->bwp_Id;
pucchcsires1->pucch_Resource = 2;
config_csi_meas_report(csi_MeasConfig,
servingcellconfigcommon,
pucchcsires1,
bwp->bwp_Dedicated->pdsch_Config,
pdschap,
NR_MAX_SUPPORTED_DL_LAYERS,
bwp->bwp_Id,
uid);
config_rsrp_meas_report(csi_MeasConfig, servingcellconfigcommon, pucchcsires1, do_csirs, bwp->bwp_Id + 10, uid);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id = 0;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->dummy1 = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO = NULL;
// this is pure evil: We should only pass in a ServingCellConfig, without
// modifying it! TODO: make a separate function that creates a
// ServingCellConfig, and reuse it here
*servingcellconfigdedicated = *secondaryCellGroup->spCellConfig->spCellConfigDedicated;
if (LOG_DEBUGFLAG(DEBUG_ASN1)) {
xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)secondaryCellGroup->spCellConfig);
}
return secondaryCellGroup;
}
......@@ -34,77 +34,51 @@
#include "nr_rrc_defs.h"
#include "openair2/RRC/NR/MESSAGES/asn1_msg.h"
void set_phr_config(NR_MAC_CellGroupConfig_t *mac_CellGroupConfig);
uint64_t get_ssb_bitmap(const NR_ServingCellConfigCommon_t *scc);
void rrc_coreset_config(NR_ControlResourceSet_t *coreset,
int bwp_id,
int curr_bwp,
uint64_t ssb_bitmap);
NR_SearchSpace_t *rrc_searchspace_config(bool is_common,
int searchspaceid,
int coresetid);
void nr_rrc_config_dl_tda(struct NR_PDSCH_TimeDomainResourceAllocationList *pdsch_TimeDomainAllocationList,
frame_type_t frame_type,
NR_TDD_UL_DL_ConfigCommon_t *tdd_UL_DL_ConfigurationCommon,
int curr_bwp);
void nr_rrc_config_ul_tda(NR_ServingCellConfigCommon_t *scc, int min_fb_delay);
void config_pucch_resset0(NR_PUCCH_Config_t *pucch_Config, int uid, int curr_bwp, NR_UE_NR_Capability_t *uecap);
void config_pucch_resset1(NR_PUCCH_Config_t *pucch_Config, NR_UE_NR_Capability_t *uecap);
void set_dl_DataToUL_ACK(NR_PUCCH_Config_t *pucch_Config, int min_feedback_time, NR_SubcarrierSpacing_t subcarrierSpacing);
void set_pucch_power_config(NR_PUCCH_Config_t *pucch_Config, int do_csirs);
void scheduling_request_config(const NR_ServingCellConfigCommon_t *scc,
NR_PUCCH_Config_t *pucch_Config,
int scs);
void config_rsrp_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig, const NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_PUCCH_CSI_Resource_t *pucchcsires, int do_csi, int rep_id, int uid);
void config_csi_meas_report(NR_CSI_MeasConfig_t *csi_MeasConfig,
const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_PUCCH_CSI_Resource_t *pucchcsires,
struct NR_SetupRelease_PDSCH_Config *pdsch_Config,
const rrc_pdsch_AntennaPorts_t *antennaports,
const int max_layers,
int rep_id,
int uid);
void config_csirs(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_CSI_MeasConfig_t *csi_MeasConfig,
int uid,
int num_dl_antenna_ports,
int curr_bwp,
int do_csirs,
int id);
void config_csiim(int do_csirs, int dl_antenna_ports, int curr_bwp,
NR_CSI_MeasConfig_t *csi_MeasConfig, int id);
void config_srs(const NR_ServingCellConfigCommon_t *scc,
NR_SetupRelease_SRS_Config_t *setup_release_srs_Config,
const NR_UE_NR_Capability_t *uecap,
const int curr_bwp,
const int uid,
const int res_id,
const long maxMIMO_Layers,
const int do_srs);
struct NR_SetupRelease_PDSCH_Config *config_pdsch(uint64_t ssb_bitmap, int bwp_Id, int dl_antenna_ports);
void set_dl_mcs_table(int scs,
NR_UE_NR_Capability_t *cap,
NR_BWP_DownlinkDedicated_t *bwp_Dedicated,
const NR_ServingCellConfigCommon_t *scc);
void prepare_sim_uecap(NR_UE_NR_Capability_t *cap,
NR_ServingCellConfigCommon_t *scc,
int numerology,
int rbsize,
int mcs_table);
struct NR_SetupRelease_PUSCH_Config *config_pusch(NR_PUSCH_Config_t *pusch_Config);
void config_downlinkBWP(NR_BWP_Downlink_t *bwp,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
NR_UE_NR_Capability_t *uecap,
int dl_antenna_ports,
bool force_256qam_off,
int bwp_loop, bool is_SA);
void config_uplinkBWP(NR_BWP_Uplink_t *ubwp,
long bwp_loop, bool is_SA, int uid,
const gNB_RrcConfigurationReq *configuration,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_ServingCellConfigCommon_t *scc,
NR_UE_NR_Capability_t *uecap);
NR_MAC_CellGroupConfig_t *configure_mac_cellgroup(void);
NR_BCCH_BCH_Message_t *get_new_MIB_NR(const NR_ServingCellConfigCommon_t *scc);
void free_MIB_NR(NR_BCCH_BCH_Message_t *mib);
int encode_MIB_NR(NR_BCCH_BCH_Message_t *mib, int frame, uint8_t *buf, int buf_size);
#define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1
NR_BCCH_DL_SCH_Message_t *get_SIB1_NR(const gNB_RrcConfigurationReq *configuration);
void free_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1);
int encode_SIB1_NR(NR_BCCH_DL_SCH_Message_t *sib1, uint8_t *buffer, int max_buffer_size);
NR_CellGroupConfig_t *get_initial_cellGroupConfig(int uid,
const NR_ServingCellConfigCommon_t *scc,
const NR_ServingCellConfig_t *servingcellconfigdedicated,
const gNB_RrcConfigurationReq *configuration);
void update_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig,
const int uid,
NR_UE_NR_Capability_t *uecap,
const gNB_RrcConfigurationReq *configuration);
void free_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig);
int encode_cellGroupConfig(NR_CellGroupConfig_t *cellGroupConfig, uint8_t *buffer, int max_buffer_size);
NR_CellGroupConfig_t *decode_cellGroupConfig(const uint8_t *buffer, int max_buffer_size);
/* Note: this function returns a new CellGroupConfig for a user with given
* configuration, but it will also overwrite the ServingCellConfig passed in
* parameter servingcellconfigdedicated! */
NR_CellGroupConfig_t *get_default_secondaryCellGroup(const NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
const NR_UE_NR_Capability_t *uecap,
int scg_id,
int servCellIndex,
const gNB_RrcConfigurationReq *configuration,
int uid);
#endif
......@@ -442,32 +442,22 @@ typedef struct rrc_gNB_ue_context_s {
typedef struct {
// buffer that contains the encoded messages
uint8_t *MIB;
uint8_t sizeof_MIB;
uint8_t *SIB1;
uint16_t sizeof_SIB1;
uint8_t *SIB23;
uint8_t sizeof_SIB23;
uint8_t *ServingCellConfigCommon;
uint8_t sizeof_servingcellconfigcommon;
int physCellId;
NR_BCCH_BCH_Message_t mib;
NR_BCCH_BCH_Message_t *mib_DU;
NR_BCCH_BCH_Message_t *mib;
NR_SIB1_t *siblock1_DU;
//NR_BCCH_DL_SCH_Message_t *siblock1_DU;
NR_SIB1_t *sib1;
NR_SIB2_t *sib2;
NR_SIB3_t *sib3;
NR_BCCH_DL_SCH_Message_t systemInformation; // SIB23
NR_BCCH_DL_SCH_Message_t *siblock1;
NR_ServingCellConfigCommon_t *servingcellconfigcommon;
NR_ServingCellConfig_t *servingcellconfig;
NR_CellGroupConfig_t *secondaryCellGroup[MAX_NR_RRC_UE_CONTEXTS];
int p_gNB;
......
......@@ -35,8 +35,6 @@
#include "LAYER2/RLC/rlc.h"
#include "openair2/RRC/common.h"
#define NR_MAX_SIB_LENGTH 2976 // 3GPP TS 38.331 section 5.2.1 - The physical layer imposes a limit to the maximum size a SIB can take. The maximum SIB1 or SI message size is 2976 bits.
extern UE_RRC_INST *UE_rrc_inst;
extern uint8_t DRB2LCHAN[8];
......
......@@ -42,6 +42,7 @@
#include "NR_CG-Config.h"
#include "NR_CG-ConfigInfo.h"
#include "NR_SecurityConfig.h"
#include "NR_CellGroupConfig.h"
#define NR_MAX_SUPPORTED_DL_LAYERS 2
void rrc_init_nr_srb_param(NR_LCHAN_DESC *chan);
......@@ -72,15 +73,6 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
void rrc_remove_nsa_user(gNB_RRC_INST *rrc, int rnti);
void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
NR_CellGroupConfig_t *secondaryCellGroup,
NR_UE_NR_Capability_t *uecap,
int scg_id,
int servCellIndex,
const gNB_RrcConfigurationReq *configuration,
int uid);
void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
NR_RRCReconfiguration_IEs_t *reconfig,
......@@ -89,11 +81,6 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
const gNB_RrcConfigurationReq *configuration,
int uid);
void fill_default_rbconfig(NR_RadioBearerConfig_t *rbconfig,
int eps_bearer_id, int rb_id,
e_NR_CipheringAlgorithm ciphering_algorithm,
e_NR_SecurityConfig__keyToUse key_to_use);
int generate_CG_Config(gNB_RRC_INST *rrc,
NR_CG_Config_t *cg_Config,
NR_RRCReconfiguration_t *reconfig,
......@@ -136,9 +123,8 @@ void nr_rrc_trigger(protocol_ctxt_t *ctxt, int CC_id, int frame, int subframe);
\ *reOffset Pointer to RE Offset Value */
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMcs, int *epre_Ratio, int * reOffset);
int
nr_rrc_mac_remove_ue(module_id_t mod_idP,
rnti_t rntiP);
void nr_rrc_mac_remove_ue(rnti_t rntiP);
void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc);
int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const frame_t frameP,
......
......@@ -92,7 +92,6 @@
#include <openair2/X2AP/x2ap_eNB.h>
#include <openair3/ocp-gtpu/gtp_itf.h>
#include <openair2/RRC/NR/nr_rrc_proto.h>
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "openair2/LAYER2/nr_pdcp/nr_pdcp_e1_api.h"
#include "openair2/F1AP/f1ap_common.h"
#include "openair2/SDAP/nr_sdap/nr_sdap_entity.h"
......@@ -178,13 +177,16 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
{
LOG_D(RRC,"%s()\n\n\n\n",__FUNCTION__);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
rrc->carrier.MIB = (uint8_t *) malloc16(4);
rrc->carrier.sizeof_MIB = do_MIB_NR(rrc,0);
}
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type))
rrc->carrier.mib = get_new_MIB_NR(rrc->carrier.servingcellconfigcommon);
if((get_softmodem_params()->sa) && ( (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)))) {
rrc->carrier.sizeof_SIB1 = do_SIB1_NR(&rrc->carrier,configuration);
NR_BCCH_DL_SCH_Message_t *sib1 = get_SIB1_NR(configuration);
rrc->carrier.SIB1 = calloc(NR_MAX_SIB_LENGTH / 8, sizeof(*rrc->carrier.SIB1));
AssertFatal(rrc->carrier.SIB1 != NULL, "out of memory\n");
rrc->carrier.sizeof_SIB1 = encode_SIB1_NR(sib1, rrc->carrier.SIB1, NR_MAX_SIB_LENGTH / 8);
rrc->carrier.siblock1 = sib1;
nr_mac_config_sib1(RC.nrmac[rrc->module_id], sib1);
}
if (!NODE_IS_DU(rrc->node_type)) {
......@@ -205,9 +207,7 @@ static void init_NR_SI(gNB_RRC_INST *rrc, gNB_RrcConfigurationReq *configuration
rrc->configuration.sib1_tda,
rrc->configuration.minRXTXTIME,
rrc->carrier.servingcellconfigcommon);
nr_mac_config_mib(RC.nrmac[rrc->module_id], &rrc->carrier.mib);
if (get_softmodem_params()->sa)
nr_mac_config_sib1(RC.nrmac[rrc->module_id], rrc->carrier.siblock1);
nr_mac_config_mib(RC.nrmac[rrc->module_id], rrc->carrier.mib);
}
/* set flag to indicate that cell information is configured. This is required
......@@ -271,7 +271,6 @@ static void openair_rrc_gNB_configuration(const module_id_t gnb_mod_idP, gNB_Rrc
RB_INIT(&rrc->rrc_ue_head);
rrc->configuration = *configuration;
rrc->carrier.servingcellconfigcommon = configuration->scc;
rrc->carrier.servingcellconfig = configuration->scd;
nr_rrc_config_ul_tda(configuration->scc,configuration->minRXTXTIME);
/// System Information INIT
pthread_mutex_init(&rrc->cell_info_mutex,NULL);
......@@ -322,7 +321,7 @@ unsigned int rrc_gNB_get_next_transaction_identifier(module_id_t gnb_mod_idP)
static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP)
{
NR_CellGroupConfig_t *cgc = get_softmodem_params()->sa ? ue_context_pP->ue_context.masterCellGroup : NULL;
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, cgc);
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, cgc);
nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.SRB_configList, cgc->rlc_BearerToAddModList);
nr_rrc_addmod_drbs(ctxt_pP->rntiMaybeUEid, ue_context_pP->ue_context.DRB_configList, cgc->rlc_BearerToAddModList);
......@@ -330,7 +329,7 @@ static void apply_macrlc_config(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const u
void apply_macrlc_config_reest(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *const ue_context_pP, const protocol_ctxt_t *const ctxt_pP, ue_id_t ue_id)
{
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_id, ue_context_pP->ue_context.masterCellGroup);
nr_rrc_mac_update_cellgroup(ue_id, ue_context_pP->ue_context.masterCellGroup);
nr_rrc_addmod_srbs(ctxt_pP->rntiMaybeUEid,
ue_context_pP->ue_context.SRB_configList,
......@@ -342,8 +341,7 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance,
rnti_t rnti,
rrc_gNB_ue_context_t *const ue_context_pP,
const uint8_t *masterCellGroup,
int masterCellGroup_len,
NR_ServingCellConfigCommon_t *scc)
int masterCellGroup_len)
//-----------------------------------------------------------------------------
{
LOG_I(NR_RRC, "rrc_gNB_generate_RRCSetup for RNTI %04x\n", rnti);
......@@ -351,8 +349,7 @@ static void rrc_gNB_generate_RRCSetup(instance_t instance,
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
gNB_RRC_INST *rrc = RC.nrrrc[instance];
unsigned char buf[1024];
const NR_ServingCellConfig_t *sccd = rrc->configuration.scd;
int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(instance), masterCellGroup, masterCellGroup_len, scc, sccd, &rrc->configuration);
int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(instance), masterCellGroup, masterCellGroup_len, &rrc->configuration);
AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n");
......@@ -386,14 +383,12 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t
LOG_I(NR_RRC, "generate RRCSetup for RRCReestablishmentRequest \n");
rrc_gNB_ue_context_t *ue_context_pP = NULL;
gNB_RRC_INST *rrc_instance_p = RC.nrrrc[module_id];
const NR_ServingCellConfigCommon_t *scc=rrc_instance_p->carrier.servingcellconfigcommon;
const NR_ServingCellConfig_t *sccd = rrc_instance_p->configuration.scd;
ue_context_pP = rrc_gNB_create_ue_context(rnti, rrc_instance_p, 0);
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
unsigned char buf[1024];
int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(module_id), NULL, 0, scc, sccd, &rrc_instance_p->configuration);
int size = do_RRCSetup(ue_context_pP, buf, rrc_gNB_get_next_transaction_identifier(module_id), NULL, 0, &rrc_instance_p->configuration);
AssertFatal(size > 0, "do_RRCSetup failed\n");
AssertFatal(size <= 1024, "memory corruption\n");
......@@ -413,7 +408,7 @@ static void rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id_t
rrc_instance_p->configuration.sib1_tda,
rrc_instance_p->configuration.minRXTXTIME,
rrc_instance_p->carrier.servingcellconfigcommon);
nr_mac_config_mib(RC.nrmac[rrc_instance_p->module_id], &rrc_instance_p->carrier.mib);
nr_mac_config_mib(RC.nrmac[rrc_instance_p->module_id], rrc_instance_p->carrier.mib);
nr_mac_config_sib1(RC.nrmac[rrc_instance_p->module_id], rrc_instance_p->carrier.siblock1);
LOG_I(NR_RRC, " [RAPROC] rnti: %04x Logical Channel DL-CCCH, Generating RRCSetup (bytes %d)\n", rnti, size);
......@@ -577,7 +572,7 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context;
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_p->rnti, ue_p->masterCellGroup);
nr_rrc_mac_update_cellgroup(ue_p->rnti, ue_p->masterCellGroup);
uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated
&& ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList
......@@ -766,7 +761,7 @@ rrc_gNB_generate_dedicatedRRCReconfiguration(
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) {
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup);
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup);
uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated
&& ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList
......@@ -1223,18 +1218,6 @@ void rrc_gNB_generate_RRCReestablishment(const protocol_ctxt_t *ctxt_pP,
&rrc->carrier);
LOG_I(NR_RRC, "[RAPROC] UE %04x Logical Channel DL-DCCH, Generating NR_RRCReestablishment (bytes %d)\n", ue_p->rnti, size);
#if (0)
/* TODO : It may be needed if gNB goes into full stack working. */
UE = find_nr_UE(module_id, rnti);
if (UE_id != -1) {
/* Activate reject timer, if RRCComplete not received after 10 frames, reject UE */
RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 1;
/* Reject UE after 10 frames, NR_RRCReestablishmentReject is triggered */
RC.nrmac[module_id]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer_thres = 100;
} else {
LOG_E(NR_RRC, " Generating NR_RRCReestablishment without UE_id(MAC) rnti %x\n", rnti);
}
#endif
uint8_t *kRRCenc = NULL;
uint8_t *kRRCint = NULL;
......@@ -1562,7 +1545,7 @@ void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *const ctx
ctxt_pP->module_id,
DCCH);
nr_mac_update_cellgroup(RC.nrmac[rrc->module_id], ue_context_pP->ue_context.rnti, cellGroupConfig);
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, cellGroupConfig);
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
}
......@@ -1616,7 +1599,7 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP
NULL,
masterCellGroup);
nr_mac_update_cellgroup(RC.nrmac[ctxt_pP->module_id], ue_context_pP->ue_context.rnti, masterCellGroup);
nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, masterCellGroup);
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_pdcp_data_req_srb(ctxt_pP->rntiMaybeUEid, DCCH, rrc_gNB_mui++, size, buffer, deliver_pdu_srb_f1, rrc);
......@@ -1706,8 +1689,7 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint
// TODO: MAC structures should not be accessed directly from the RRC! An implementation using the F1 interface should be developed.
if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) {
gNB_MAC_INST *nrmac = RC.nrmac[module_id]; // why MAC instances match RRC instances ?
mac_remove_nr_ue(nrmac, UE->rnti);
nr_rrc_mac_remove_ue(ue_context_p->ue_context.rnti);
}
/* replace rnti in the context */
......@@ -1744,8 +1726,11 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint
UE = &ue_context_p->ue_context;
UE->establishment_cause = rrcSetupRequest->establishmentCause;
rrc_gNB_generate_RRCSetup(
module_id, rnti, rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti), du_to_cu_rrc_container, du_to_cu_rrc_container_len, gnb_rrc_inst->carrier.servingcellconfigcommon);
rrc_gNB_generate_RRCSetup(module_id,
rnti,
rrc_gNB_get_ue_context_by_rnti(gnb_rrc_inst, rnti),
du_to_cu_rrc_container,
du_to_cu_rrc_container_len);
}
break;
......@@ -1798,34 +1783,6 @@ static int nr_rrc_gNB_decode_ccch(module_id_t module_id, rnti_t rnti, const uint
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, c_rnti, 0);
break;
}
#if 0
int UE_id = find_nr_UE_id(gnb_rrc_inst, c_rnti);
if (UE_id == -1) {
LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without MAC context, rnti %04x, fallback to RRC establishment\n", c_rnti);
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
break;
}
// previous rnti
rnti_t previous_rnti = 0;
for (int i = 0; i < MAX_MOBILES_PER_ENB; i++) {
if (reestablish_rnti_map[i][1] == c_rnti) {
previous_rnti = reestablish_rnti_map[i][0];
break;
}
}
if (previous_rnti != 0) {
UE_id = find_nr_UE_id(gnb_rrc_inst, previous_rnti);
if (UE_id == -1) {
LOG_E(NR_RRC,"RRCReestablishmentRequest without mac context previous rnti %04x, nex rnti %04x, fallback to RRC establishment\n",
previous_rnti, c_rnti);
rrc_gNB_generate_RRCSetup_for_RRCReestablishmentRequest(module_id, rnti, 0);
break;
}
}
#endif
// c-plane not end
if ((UE->StatusRrc != NR_RRC_RECONFIGURED) && (UE->reestablishment_cause == NR_ReestablishmentCause_spare1)) {
LOG_E(NR_RRC, "NR_RRCReestablishmentRequest (UE %x c-plane is not end), RRC establishment failed\n", c_rnti);
......@@ -2419,24 +2376,10 @@ rrc_gNB_decode_dcch(
break;
}
#if (0)
/* TODO : It may be needed if gNB goes into full stack working. */
// clear
int UE_id = find_nr_UE_id(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid);
if (UE_id == -1) {
LOG_E(NR_RRC, PROTOCOL_RRC_CTXT_UE_FMT " NR_RRCReestablishmentComplete without UE_id(MAC) rnti %lx, fault\n", PROTOCOL_RRC_CTXT_UE_ARGS(ctxt_pP), ctxt_pP->rntiMaybeUEid);
break;
}
RC.nrmac[gnb_rrc_inst]->UE_info.UE_sched_ctrl[UE_id].ue_reestablishment_reject_timer = 0;
#endif
if (ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete->criticalExtensions.present == NR_RRCReestablishmentComplete__criticalExtensions_PR_rrcReestablishmentComplete) {
rrc_gNB_process_RRCReestablishmentComplete(ctxt_pP, reestablish_rnti, ue_context_p, ul_dcch_msg->message.choice.c1->choice.rrcReestablishmentComplete->rrc_TransactionIdentifier);
gNB_MAC_INST *nrmac = RC.nrmac[ctxt_pP->module_id]; // WHAT A BEAUTIFULL RACE CONDITION !!!
mac_remove_nr_ue(nrmac, reestablish_rnti);
nr_rrc_mac_remove_ue(reestablish_rnti);
UE->ue_reestablishment_counter++;
}
......@@ -2471,26 +2414,17 @@ void rrc_gNB_process_f1_setup_req(f1ap_setup_req_t *f1_setup_req) {
//fixme: multi instance is not consistent here
F1AP_SETUP_RESP (msg_p).gNB_CU_name = rrc->node_name;
// check that CU rrc instance corresponds to mcc/mnc/cgi (normally cgi should be enough, but just in case)
rrc->carrier.MIB = malloc(f1_setup_req->mib_length[i]);
rrc->carrier.sizeof_MIB = f1_setup_req->mib_length[i];
LOG_W(NR_RRC, "instance %d mib length %d\n", i, f1_setup_req->mib_length[i]);
LOG_W(NR_RRC, "instance %d sib1 length %d\n", i, f1_setup_req->sib1_length[i]);
memcpy((void *)rrc->carrier.MIB,f1_setup_req->mib[i],f1_setup_req->mib_length[i]);
AssertFatal(rrc->carrier.mib == NULL, "CU MIB is already initialized: double F1 setup request?\n");
asn_dec_rval_t dec_rval = uper_decode_complete(NULL,
&asn_DEF_NR_BCCH_BCH_Message,
(void **)&rrc->carrier.mib_DU,
(void **)&rrc->carrier.mib,
f1_setup_req->mib[i],
f1_setup_req->mib_length[i]);
AssertFatal(dec_rval.code == RC_OK,
"[gNB_CU %"PRIu8"] Failed to decode NR_BCCH_BCH_MESSAGE (%zu bits)\n",
j,
dec_rval.consumed );
NR_BCCH_BCH_Message_t *mib = &rrc->carrier.mib;
NR_BCCH_BCH_Message_t *mib_DU = rrc->carrier.mib_DU;
mib->message.present = NR_BCCH_BCH_MessageType_PR_mib;
mib->message.choice.mib = CALLOC(1,sizeof(struct NR_MIB));
memset(mib->message.choice.mib,0,sizeof(struct NR_MIB));
memcpy(mib->message.choice.mib, mib_DU->message.choice.mib, sizeof(struct NR_MIB));
dec_rval = uper_decode_complete(NULL,
&asn_DEF_NR_SIB1, //&asn_DEF_NR_BCCH_DL_SCH_Message,
......@@ -3269,8 +3203,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
// Remove here the MAC and RRC context when RRC is not connected
if (UE->StatusRrc < NR_RRC_CONNECTED) {
if (!NODE_IS_CU(rrc->node_type)) {
gNB_MAC_INST *nrmac = RC.nrmac[ctxt_pP->module_id]; // WHAT A BEAUTIFULL RACE CONDITION !!!
mac_remove_nr_ue(nrmac, UE->rnti);
nr_rrc_mac_remove_ue(ctxt_pP->rntiMaybeUEid);
rrc_rlc_remove_ue(ctxt_pP);
nr_pdcp_remove_UE(ctxt_pP->rntiMaybeUEid);
......@@ -3305,8 +3238,7 @@ void nr_rrc_subframe_process(protocol_ctxt_t *const ctxt_pP, const int CC_id) {
LOG_I(NR_RRC, "Removing UE %x instance after UE_CONTEXT_RELEASE_Complete (ue_release_timer_rrc timeout)\n", UE->rnti);
UE->ue_release_timer_rrc = 0;
if (!NODE_IS_CU(RC.nrrrc[0]->node_type)) {
gNB_MAC_INST *nrmac = RC.nrmac[ctxt_pP->module_id]; // WHAT A BEAUTIFULL RACE CONDITION !!!
mac_remove_nr_ue(nrmac, UE->rnti);
nr_rrc_mac_remove_ue(ctxt_pP->rntiMaybeUEid);
}
rrc_rlc_remove_ue(ctxt_pP);
nr_pdcp_remove_UE(ctxt_pP->rntiMaybeUEid);
......
......@@ -46,6 +46,7 @@
#include "UTIL/OSA/osa_defs.h"
#include <openair2/RRC/NR/nr_rrc_proto.h>
#include "nr_pdcp/nr_pdcp_oai_api.h"
#include "MESSAGES/asn1_msg.h"
void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerList_t *UE_CapabilityRAT_ContainerList, x2ap_ENDC_sgnb_addition_req_t *m, NR_CG_ConfigInfo_IEs_t *cg_config_info)
{
......@@ -100,7 +101,7 @@ void rrc_parse_ue_capabilities(gNB_RRC_INST *rrc, NR_UE_CapabilityRAT_ContainerL
LOG_A(NR_RRC, "Successfully decoded UE NR capabilities (NR and MRDC)\n");
UE->spCellConfig = calloc(1, sizeof(struct NR_SpCellConfig));
UE->spCellConfig->spCellConfigDedicated = rrc->carrier.servingcellconfig;
UE->spCellConfig->spCellConfigDedicated = rrc->configuration.scd;
LOG_I(NR_RRC,"Adding new NSA user (%p)\n",ue_context_p);
rrc_add_nsa_user(rrc,ue_context_p, m);
}
......@@ -150,15 +151,13 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
// NR RRCReconfiguration
UE->reconfig = calloc(1, sizeof(NR_RRCReconfiguration_t));
UE->secondaryCellGroup = calloc(1, sizeof(NR_CellGroupConfig_t));
memset((void *)UE->reconfig, 0, sizeof(NR_RRCReconfiguration_t));
UE->reconfig->rrc_TransactionIdentifier = 0;
UE->reconfig->criticalExtensions.present = NR_RRCReconfiguration__criticalExtensions_PR_rrcReconfiguration;
NR_RRCReconfiguration_IEs_t *reconfig_ies=calloc(1,sizeof(NR_RRCReconfiguration_IEs_t));
UE->reconfig->criticalExtensions.choice.rrcReconfiguration = reconfig_ies;
UE->rb_config = calloc(1, sizeof(NR_RRCReconfiguration_t));
if (get_softmodem_params()->phy_test == 1 || get_softmodem_params()->do_ra == 1 || get_softmodem_params()->sa == 1){
fill_default_rbconfig(UE->rb_config, 10 /* EPS bearer ID */, 1 /* drb ID */, NR_CipheringAlgorithm_nea0, NR_SecurityConfig__keyToUse_master);
UE->rb_config = get_default_rbconfig(10 /* EPS bearer ID */, 1 /* drb ID */, NR_CipheringAlgorithm_nea0, NR_SecurityConfig__keyToUse_master);
} else {
/* TODO: handle more than one bearer */
if (m == NULL) {
......@@ -235,10 +234,20 @@ void rrc_add_nsa_user(gNB_RRC_INST *rrc, rrc_gNB_ue_context_t *ue_context_p, x2a
exit(1);
}
fill_default_rbconfig(UE->rb_config, m->e_rabs_tobeadded[0].e_rab_id, m->e_rabs_tobeadded[0].drb_ID, cipher_algo, NR_SecurityConfig__keyToUse_secondary);
UE->rb_config = get_default_rbconfig(m->e_rabs_tobeadded[0].e_rab_id, m->e_rabs_tobeadded[0].drb_ID, cipher_algo, NR_SecurityConfig__keyToUse_secondary);
}
NR_ServingCellConfig_t *scc = UE->spCellConfig ? UE->spCellConfig->spCellConfigDedicated : NULL;
UE->secondaryCellGroup = get_default_secondaryCellGroup(carrier->servingcellconfigcommon,
scc,
UE->UE_Capability_nr,
1,
1,
configuration,
ue_context_p->ue_context.gNB_ue_ngap_id);
AssertFatal(UE->secondaryCellGroup != NULL, "out of memory\n");
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, UE->secondaryCellGroup);
fill_default_reconfig(carrier->servingcellconfigcommon, scc, reconfig_ies, UE->secondaryCellGroup, UE->UE_Capability_nr, configuration, ue_context_p->ue_context.gNB_ue_ngap_id);
// the UE context is not yet inserted in the RRC UE manager
// rrc_gNB_update_ue_context_rnti(UE->secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity, rrc,
......
......@@ -43,366 +43,10 @@
#include "assertions.h"
#include "oai_asn1.h"
#include "common/utils/nr/nr_common.h"
#include "SIMULATION/TOOLS/sim.h"
#include "executables/softmodem-common.h"
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
#include "nr_rrc_config.h"
void fix_servingcellconfigdedicated(NR_ServingCellConfig_t *scd) {
int b = 0;
while (b < scd->downlinkBWP_ToAddModList->list.count) {
if (scd->downlinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth == 0) {
asn_sequence_del(&scd->downlinkBWP_ToAddModList->list, b, 1);
} else {
b++;
}
}
if(scd->downlinkBWP_ToAddModList->list.count == 0) {
free(scd->downlinkBWP_ToAddModList);
scd->downlinkBWP_ToAddModList = NULL;
}
b = 0;
while (b < scd->uplinkConfig->uplinkBWP_ToAddModList->list.count) {
if (scd->uplinkConfig->uplinkBWP_ToAddModList->list.array[b]->bwp_Common->genericParameters.locationAndBandwidth ==
0) {
asn_sequence_del(&scd->uplinkConfig->uplinkBWP_ToAddModList->list, b, 1);
} else {
b++;
}
}
if(scd->uplinkConfig->uplinkBWP_ToAddModList->list.count == 0) {
free(scd->uplinkConfig->uplinkBWP_ToAddModList);
scd->uplinkConfig->uplinkBWP_ToAddModList = NULL;
}
}
void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
NR_CellGroupConfig_t *secondaryCellGroup,
NR_UE_NR_Capability_t *uecap,
int scg_id,
int servCellIndex,
const gNB_RrcConfigurationReq *configuration,
int uid) {
const rrc_pdsch_AntennaPorts_t* pdschap = &configuration->pdsch_AntennaPorts;
const int dl_antenna_ports = pdschap->N1 * pdschap->N2 * pdschap->XP;
const int do_csirs = configuration->do_CSIRS;
AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n");
AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n");
if(uecap == NULL)
LOG_E(RRC,"No UE Capabilities available when programming default CellGroup in NSA\n");
// This assert will never happen in the current implementation because NUMBER_OF_UE_MAX = 4.
// However, if in the future NUMBER_OF_UE_MAX is increased, it will be necessary to improve the allocation of SRS resources,
// where the startPosition = 2 or 3 and sl160 = 17, 17, 27 ... 157 only give us 30 different allocations.
AssertFatal(uid>=0 && uid<30, "gNB cannot allocate the SRS resources\n");
uint64_t bitmap = get_ssb_bitmap(servingcellconfigcommon);
fix_servingcellconfigdedicated(servingcellconfigdedicated);
memset(secondaryCellGroup,0,sizeof(NR_CellGroupConfig_t));
secondaryCellGroup->cellGroupId = scg_id;
NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig));
nr_rlc_bearer_init(RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity);
nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional);
//nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am);
nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig);
secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList));
asn1cSeqAdd(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig);
secondaryCellGroup->mac_CellGroupConfig = configure_mac_cellgroup();
secondaryCellGroup->physicalCellGroupConfig = calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig));
secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH=NULL;
secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH=NULL;
secondaryCellGroup->physicalCellGroupConfig->p_NR_FR1 = NULL;
secondaryCellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook=NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic;
secondaryCellGroup->physicalCellGroupConfig->tpc_SRS_RNTI=NULL;
secondaryCellGroup->physicalCellGroupConfig->tpc_PUCCH_RNTI=NULL;
secondaryCellGroup->physicalCellGroupConfig->tpc_PUSCH_RNTI=NULL;
secondaryCellGroup->physicalCellGroupConfig->sp_CSI_RNTI=NULL;
secondaryCellGroup->physicalCellGroupConfig->cs_RNTI=NULL;
secondaryCellGroup->physicalCellGroupConfig->ext1=NULL;
secondaryCellGroup->spCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig));
secondaryCellGroup->spCellConfig->servCellIndex = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->servCellIndex));
*secondaryCellGroup->spCellConfig->servCellIndex = servCellIndex;
secondaryCellGroup->spCellConfig->reconfigurationWithSync=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->reconfigurationWithSync));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon=servingcellconfigcommon;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=(get_softmodem_params()->phy_test==1) ? 0x1234 : (taus()&0xffff);
secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1 = NULL;
// For 2-step contention-free random access procedure
if(get_softmodem_params()->sa == 0) {
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = calloc(1,sizeof(struct NR_ReconfigurationWithSync__rach_ConfigDedicated));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->present= NR_ReconfigurationWithSync__rach_ConfigDedicated_PR_uplink;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink= calloc(1,sizeof(struct NR_RACH_ConfigDedicated));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra= calloc(1,sizeof(struct NR_CFRA));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->ra_Prioritization= NULL;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions= calloc(1,sizeof(struct NR_CFRA__occasions));
memcpy(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions->rach_ConfigGeneric,
&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->rach_ConfigGeneric, sizeof(NR_RACH_ConfigGeneric_t));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions->ssb_perRACH_Occasion= calloc(1,sizeof(long));
*secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->occasions->ssb_perRACH_Occasion = NR_CFRA__occasions__ssb_perRACH_Occasion_one;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.present = NR_CFRA__resources_PR_ssb;
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb = calloc(1,sizeof(struct NR_CFRA__resources__ssb));
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ra_ssb_OccasionMaskIndex = 0;
int n_ssb = 0;
struct NR_CFRA_SSB_Resource *ssbElem[64];
for (int i=0;i<64;i++) {
if ((bitmap>>(63-i))&0x01){
ssbElem[n_ssb] = calloc(1,sizeof(struct NR_CFRA_SSB_Resource));
ssbElem[n_ssb]->ssb = i;
ssbElem[n_ssb]->ra_PreambleIndex = 63 - (uid % 64);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[n_ssb]);
n_ssb++;
}
}
secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL;
}
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->t310 = NR_RLF_TimersAndConstants__t310_ms4000;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n310 = NR_RLF_TimersAndConstants__n310_n20;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n311 = NR_RLF_TimersAndConstants__n311_n1;
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1 = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1));
secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1->t311 = NR_RLF_TimersAndConstants__ext1__t311_ms30000;
secondaryCellGroup->spCellConfig->rlmInSyncOutOfSyncThreshold = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->tdd_UL_DL_ConfigurationDedicated = NULL;
/// initialDownlinkBWP
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdcch_Config=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config = config_pdsch(bitmap, 0, dl_antenna_ports);
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; // calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL;
#if 0
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
#endif
/// initialUplinkBWP
if (!secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig));
}
NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP;
initialUplinkBWP->pucch_Config = NULL;
NR_PUSCH_Config_t *pusch_Config = NULL;
if (servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) {
pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup;
}
initialUplinkBWP->pusch_Config = config_pusch(pusch_Config);
long maxMIMO_Layers = servingcellconfigdedicated->uplinkConfig &&
servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig &&
servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1 &&
servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers ?
*servingcellconfigdedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers : 1;
int curr_bwp = NRRIV2BW(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config));
config_srs(servingcellconfigcommon, initialUplinkBWP->srs_Config, NULL, curr_bwp, uid, 0, maxMIMO_Layers, configuration->do_SRS);
// Downlink BWPs
int n_dl_bwp = 1;
if (servingcellconfigdedicated && servingcellconfigdedicated->downlinkBWP_ToAddModList) {
n_dl_bwp = servingcellconfigdedicated->downlinkBWP_ToAddModList->list.count;
}
if(n_dl_bwp>0) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp = calloc(1,sizeof(*bwp));
config_downlinkBWP(bwp, servingcellconfigcommon,
servingcellconfigdedicated,
uecap,
dl_antenna_ports,
configuration->force_256qam_off,
bwp_loop, false);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id = servingcellconfigdedicated->firstActiveDownlinkBWP_Id ? *servingcellconfigdedicated->firstActiveDownlinkBWP_Id : 1;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = servingcellconfigdedicated->defaultDownlinkBWP_Id ? *servingcellconfigdedicated->defaultDownlinkBWP_Id : 1;
}
// Uplink BWPs
int n_ul_bwp = 1;
if (servingcellconfigdedicated && servingcellconfigdedicated->uplinkConfig && servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList) {
n_ul_bwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.count;
}
if(n_ul_bwp>0) {
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList));
for (int bwp_loop = 0; bwp_loop < n_ul_bwp; bwp_loop++) {
NR_BWP_Uplink_t *ubwp = calloc(1,sizeof(*ubwp));
config_uplinkBWP(ubwp, bwp_loop, false, uid,
configuration,
servingcellconfigdedicated,
servingcellconfigcommon,
uecap);
asn1cSeqAdd(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id));
*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *servingcellconfigdedicated->uplinkConfig->firstActiveUplinkBWP_Id : 1;
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig));
NR_PUSCH_ServingCellConfig_t *pusch_scc = calloc(1,sizeof(*pusch_scc));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->present = NR_SetupRelease_PUSCH_ServingCellConfig_PR_setup;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->pusch_ServingCellConfig->choice.setup = pusch_scc;
pusch_scc->codeBlockGroupTransmission = NULL;
pusch_scc->rateMatching = NULL;
pusch_scc->xOverhead = NULL;
pusch_scc->ext1=calloc(1,sizeof(*pusch_scc->ext1));
pusch_scc->ext1->maxMIMO_Layers = calloc(1,sizeof(*pusch_scc->ext1->maxMIMO_Layers));
*pusch_scc->ext1->maxMIMO_Layers = 1;
pusch_scc->ext1->processingType2Enabled = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
pdsch_servingcellconfig->xOverhead = NULL;
pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
pdsch_servingcellconfig->pucch_Cell= NULL;
pdsch_servingcellconfig->ext1=calloc(1,sizeof(*pdsch_servingcellconfig->ext1));
pdsch_servingcellconfig->ext1->maxMIMO_Layers = calloc(1,sizeof(*pdsch_servingcellconfig->ext1->maxMIMO_Layers));
*pdsch_servingcellconfig->ext1->maxMIMO_Layers = NR_MAX_SUPPORTED_DL_LAYERS;
pdsch_servingcellconfig->ext1->processingType2Enabled = NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->present = NR_SetupRelease_CSI_MeasConfig_PR_setup;
NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig));
secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0));
ssbresset0->csi_SSB_ResourceSetId = 0;
for (int i=0;i<64;i++) {
if ((bitmap >> (63 - i)) & 0x01) {
NR_SSB_Index_t *ssbres = NULL;
asn1cCallocOne(ssbres, i);
asn1cSeqAdd(&ssbresset0->csi_SSB_ResourceList.list, ssbres);
}
}
asn1cSeqAdd(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0);
for (int bwp_loop = 0; bwp_loop < n_dl_bwp; bwp_loop++) {
NR_BWP_Downlink_t *bwp = secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list.array[bwp_loop];
int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
config_csirs(servingcellconfigcommon, csi_MeasConfig, uid, dl_antenna_ports, curr_bwp, do_csirs, bwp_loop);
config_csiim(do_csirs, dl_antenna_ports, curr_bwp, csi_MeasConfig, bwp_loop);
if (do_csirs) {
NR_CSI_ResourceConfig_t *csires = calloc(1,sizeof(*csires));
csires->csi_ResourceConfigId = bwp->bwp_Id;
csires->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList = calloc(1,sizeof(*csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList));
NR_NZP_CSI_RS_ResourceSetId_t *nzp0 = calloc(1,sizeof(*nzp0));
*nzp0 = bwp_loop;
asn1cSeqAdd(&csires->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0);
csires->bwp_Id = bwp->bwp_Id;
csires->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires);
}
if (do_csirs && dl_antenna_ports > 1) {
NR_CSI_ResourceConfig_t *csiresim = calloc(1,sizeof(*csiresim));
csiresim->csi_ResourceConfigId = bwp->bwp_Id+10;
csiresim->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_csi_IM_ResourceSetList;
csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList = calloc(1,sizeof(*csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList));
NR_CSI_IM_ResourceSetId_t *csiim00 = calloc(1,sizeof(*csiim00));
*csiim00 = bwp_loop;
asn1cSeqAdd(&csiresim->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00);
csiresim->bwp_Id = bwp->bwp_Id;
csiresim->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csiresim);
}
NR_CSI_ResourceConfig_t *ssbres = calloc(1,sizeof(*ssbres));
ssbres->csi_ResourceConfigId = bwp->bwp_Id+20;
ssbres->csi_RS_ResourceSetList.present = NR_CSI_ResourceConfig__csi_RS_ResourceSetList_PR_nzp_CSI_RS_SSB;
ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB = calloc(1,sizeof(*ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB));
ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList = calloc(1,sizeof(*ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList));
NR_CSI_SSB_ResourceSetId_t *ssbres00 = calloc(1,sizeof(*ssbres00));
*ssbres00 = 0;
asn1cSeqAdd(&ssbres->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00);
ssbres->bwp_Id = bwp->bwp_Id;
ssbres->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
asn1cSeqAdd(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,ssbres);
NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1));
pucchcsires1->uplinkBandwidthPartId = bwp->bwp_Id;
pucchcsires1->pucch_Resource=2;
config_csi_meas_report(csi_MeasConfig, servingcellconfigcommon, pucchcsires1, bwp->bwp_Dedicated->pdsch_Config, pdschap, NR_MAX_SUPPORTED_DL_LAYERS, bwp->bwp_Id, uid);
config_rsrp_meas_report(csi_MeasConfig, servingcellconfigcommon, pucchcsires1, do_csirs, bwp->bwp_Id + 10, uid);
}
secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id=0;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->dummy1=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking=NULL;
secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO=NULL;
*servingcellconfigdedicated = *secondaryCellGroup->spCellConfig->spCellConfigDedicated;
if ( LOG_DEBUGFLAG(DEBUG_ASN1) ) {
xer_fprint(stdout, &asn_DEF_NR_SpCellConfig, (void *)secondaryCellGroup->spCellConfig);
}
}
#include "MESSAGES/asn1_msg.h"
void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
NR_ServingCellConfig_t *servingcellconfigdedicated,
......@@ -416,17 +60,6 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n");
// radioBearerConfig
reconfig->radioBearerConfig=NULL;
// secondaryCellGroup
fill_default_secondaryCellGroup(servingcellconfigcommon,
servingcellconfigdedicated,
secondaryCellGroup,
uecap,
1,
1,
configuration,
uid);
xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);
char scg_buffer[1024];
asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)secondaryCellGroup, scg_buffer, 1024);
......@@ -443,54 +76,6 @@ void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon
reconfig->nonCriticalExtension = NULL;
}
void fill_default_rbconfig(NR_RadioBearerConfig_t *rbconfig,
int eps_bearer_id, int rb_id,
e_NR_CipheringAlgorithm ciphering_algorithm,
e_NR_SecurityConfig__keyToUse key_to_use) {
rbconfig->srb_ToAddModList = NULL;
rbconfig->srb3_ToRelease = NULL;
rbconfig->drb_ToAddModList = calloc(1,sizeof(*rbconfig->drb_ToAddModList));
NR_DRB_ToAddMod_t *drb_ToAddMod = calloc(1,sizeof(*drb_ToAddMod));
drb_ToAddMod->cnAssociation = calloc(1,sizeof(*drb_ToAddMod->cnAssociation));
drb_ToAddMod->cnAssociation->present = NR_DRB_ToAddMod__cnAssociation_PR_eps_BearerIdentity;
drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= eps_bearer_id;
drb_ToAddMod->drb_Identity = rb_id;
drb_ToAddMod->reestablishPDCP = NULL;
drb_ToAddMod->recoverPDCP = NULL;
drb_ToAddMod->pdcp_Config = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config));
drb_ToAddMod->pdcp_Config->drb = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb));
drb_ToAddMod->pdcp_Config->drb->discardTimer = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->discardTimer));
*drb_ToAddMod->pdcp_Config->drb->discardTimer=NR_PDCP_Config__drb__discardTimer_infinity;
drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL));
*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeUL = NR_PDCP_Config__drb__pdcp_SN_SizeUL_len18bits;
drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL));
*drb_ToAddMod->pdcp_Config->drb->pdcp_SN_SizeDL = NR_PDCP_Config__drb__pdcp_SN_SizeDL_len18bits;
drb_ToAddMod->pdcp_Config->drb->headerCompression.present = NR_PDCP_Config__drb__headerCompression_PR_notUsed;
drb_ToAddMod->pdcp_Config->drb->headerCompression.choice.notUsed = 0;
drb_ToAddMod->pdcp_Config->drb->integrityProtection=NULL;
drb_ToAddMod->pdcp_Config->drb->statusReportRequired=NULL;
drb_ToAddMod->pdcp_Config->drb->outOfOrderDelivery=NULL;
drb_ToAddMod->pdcp_Config->moreThanOneRLC = NULL;
drb_ToAddMod->pdcp_Config->t_Reordering = calloc(1,sizeof(*drb_ToAddMod->pdcp_Config->t_Reordering));
*drb_ToAddMod->pdcp_Config->t_Reordering = NR_PDCP_Config__t_Reordering_ms100;
drb_ToAddMod->pdcp_Config->ext1 = NULL;
asn1cSeqAdd(&rbconfig->drb_ToAddModList->list,drb_ToAddMod);
rbconfig->drb_ToReleaseList = NULL;
rbconfig->securityConfig = calloc(1,sizeof(*rbconfig->securityConfig));
rbconfig->securityConfig->securityAlgorithmConfig = calloc(1,sizeof(*rbconfig->securityConfig->securityAlgorithmConfig));
rbconfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm = ciphering_algorithm;
rbconfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm=NULL;
rbconfig->securityConfig->keyToUse = calloc(1,sizeof(*rbconfig->securityConfig->keyToUse));
*rbconfig->securityConfig->keyToUse = key_to_use;
// xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)rbconfig);
}
/* Function to set or overwrite PTRS DL RRC parameters */
void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, int *ptrsNrb, int *ptrsMcs, int *epre_Ratio, int * reOffset)
{
......
......@@ -413,7 +413,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, ENB_FLAG_YES, mac->crnti, 0, 0, 0);
xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)RadioBearerConfig);
LOG_D(NR_RRC, "Calling fill_default_rbconfig_ue at %d with: e_rab_id = %ld, drbID = %ld, cipher_algo = %ld, key = %ld \n",
LOG_D(NR_RRC, "Calling nr_rrc_ue_process_RadioBearerConfig() at %d with: e_rab_id = %ld, drbID = %ld, cipher_algo = %ld, key = %ld \n",
__LINE__, RadioBearerConfig->drb_ToAddModList->list.array[0]->cnAssociation->choice.eps_BearerIdentity,
RadioBearerConfig->drb_ToAddModList->list.array[0]->drb_Identity,
RadioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm,
......
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