rrc_gNB_reconfig.c 107 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

/*! \file rrc_gNB_reconfig.c
 * \brief rrc gNB RRCreconfiguration support routines
 * \author Raymond Knopp
 * \date 2019
 * \version 1.0
 * \company Eurecom
 * \email: raymond.knopp@eurecom.fr
 */
30
#ifndef RRC_GNB_NSA_C
31 32
#define RRC_GNB_NSA_C

33
#include "NR_ServingCellConfigCommon.h"
34
#include "NR_ServingCellConfig.h"
35
#include "NR_RRCReconfiguration.h"
36 37 38 39 40 41 42 43 44
#include "NR_RRCReconfiguration-IEs.h"
#include "NR_CellGroupConfig.h"
#include "NR_MAC-CellGroupConfig.h"
#include "NR_BSR-Config.h"
#include "NR_PDSCH-ServingCellConfig.h"
#include "NR_RLC-BearerConfig.h"
#include "BOOLEAN.h"
#include "assertions.h"
#include "common/utils/nr/nr_common.h"
Francesco Mani's avatar
Francesco Mani committed
45
#include "SIMULATION/TOOLS/sim.h"
46
#include "executables/softmodem-common.h"
47
#include "LAYER2/nr_rlc/nr_rlc_oai_api.h"
Eurecom's avatar
Eurecom committed
48
#include "LAYER2/NR_MAC_COMMON/nr_mac.h"
49 50
#define false 0
#define true 1
51

52
/*
53 54 55
void fill_default_initialDownlinkBWP(NR_BWP_Downlink_t *bwp, NR_ServingCellConfigCommon_t *servingcellconfigcommon) {
  bwp->bwp_Id = 0;
  bwp->bwp_Common=calloc(1,sizeof(*bwp->bwp_Common));
Laurent THOMAS's avatar
Laurent THOMAS committed
56
  *bwp->bwp_Common = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP;
57 58
}

59 60 61 62 63 64 65 66
void fill_default_coresetZero(NR_ControlResourceSet_t *coreset0, 
                              NR_MIB_t *mib,
                              int ssb_subcarrier_offset, 
			      int ssbSubcarrierSpacing,
			      int ssb_start_symbol,
                              int frequency_range,
			      int ssboffset_pointa,
			      int physCellId) {
67

68 69
  NR_Type0_PDCCH_CSS_config_t type0_PDCCH_CSS_config;
  int num_slot_per_frame = 10*(1<<ssbSubcarrierSpacing);
Eurecom's avatar
Eurecom committed
70 71
  LOG_I(NR_RRC,"num_slot_per_frame %d, ssb_subcarrier_offset %d,ssb_start_symbol %d, ssbSubcarrierSpacing %d, frequency_range %d, ssboffset_pointa %d\n",
	num_slot_per_frame,ssb_subcarrier_offset,ssb_start_symbol,ssbSubcarrierSpacing,frequency_range,ssboffset_pointa);
72 73 74 75 76 77 78 79 80 81 82
  get_type0_PDCCH_CSS_config_parameters(&type0_PDCCH_CSS_config,
                                        0,
                                        mib,
                                        num_slot_per_frame,
                                        ssb_subcarrier_offset,
                                        ssb_start_symbol,
                                        ssbSubcarrierSpacing,
                                        frequency_range,
                                        0,
                                        ssboffset_pointa);
                                        
83 84 85
  coreset0->controlResourceSetId = 0;

  if(coreset0->frequencyDomainResources.buf == NULL) coreset0->frequencyDomainResources.buf = calloc(1,6);
86

87
  coreset0->frequencyDomainResources.buf[0] = type0_PDCCH_CSS_config.num_rbs==48 ? 0xff : 0xf0;
88 89 90 91 92 93 94
  coreset0->frequencyDomainResources.buf[1] = 0;
  coreset0->frequencyDomainResources.buf[2] = 0;
  coreset0->frequencyDomainResources.buf[3] = 0;
  coreset0->frequencyDomainResources.buf[4] = 0;
  coreset0->frequencyDomainResources.buf[5] = 0;
  coreset0->frequencyDomainResources.size = 6;
  coreset0->frequencyDomainResources.bits_unused = 3;
95 96 97 98 99 100 101 102

  int firstrb_cs0 = ssboffset_pointa-type0_PDCCH_CSS_config.rb_offset;

  LOG_I(RRC,"CS0: ssboffset_pointa %d, first_cs0_rb %d, num_cs0_rbs %d, cs0_duration %d: %x\n",ssboffset_pointa,firstrb_cs0,type0_PDCCH_CSS_config.num_rbs,type0_PDCCH_CSS_config.num_symbols,
	coreset0->frequencyDomainResources.buf[0]);

  coreset0->duration = type0_PDCCH_CSS_config.num_symbols;

103
  coreset0->cce_REG_MappingType.present=NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved;
104
  coreset0->cce_REG_MappingType.choice.interleaved=calloc(1,sizeof(*coreset0->cce_REG_MappingType.choice.interleaved));
105
  coreset0->cce_REG_MappingType.choice.interleaved->reg_BundleSize = NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6;
106
  coreset0->cce_REG_MappingType.choice.interleaved->interleaverSize = NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n2;
107 108
  coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex = calloc(1,sizeof(*coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex));
  *coreset0->cce_REG_MappingType.choice.interleaved->shiftIndex = physCellId;
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  coreset0->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle;

  if(coreset0->tci_StatesPDCCH_ToAddList == NULL) coreset0->tci_StatesPDCCH_ToAddList = calloc(1,sizeof(*coreset0->tci_StatesPDCCH_ToAddList));

  NR_TCI_StateId_t *tci[8];
  for (int i=0;i<8;i++) {
    tci[i]=calloc(1,sizeof(*tci[i]));
    *tci[i] = i;
    ASN_SEQUENCE_ADD(&coreset0->tci_StatesPDCCH_ToAddList->list,tci[i]);
  }
  coreset0->tci_StatesPDCCH_ToReleaseList = NULL;
  coreset0->tci_PresentInDCI = NULL;
  coreset0->pdcch_DMRS_ScramblingID = NULL;

}

void fill_default_searchSpaceZero(NR_SearchSpace_t *ss0) {

  if(ss0->controlResourceSetId == NULL) ss0->controlResourceSetId=calloc(1,sizeof(*ss0->controlResourceSetId));
  if(ss0->monitoringSymbolsWithinSlot == NULL) ss0->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss0->monitoringSymbolsWithinSlot));
  if(ss0->monitoringSymbolsWithinSlot->buf == NULL) ss0->monitoringSymbolsWithinSlot->buf = calloc(1,2);
  if(ss0->nrofCandidates == NULL) ss0->nrofCandidates = calloc(1,sizeof(*ss0->nrofCandidates));
  if(ss0->searchSpaceType == NULL) ss0->searchSpaceType = calloc(1,sizeof(*ss0->searchSpaceType));
  if(ss0->searchSpaceType->choice.common == NULL) ss0->searchSpaceType->choice.common=calloc(1,sizeof(*ss0->searchSpaceType->choice.common));
  if(ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 == NULL) ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss0->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0));

  ss0->searchSpaceId = 0;
  *ss0->controlResourceSetId = 0;
  ss0->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss0->monitoringSlotPeriodicityAndOffset));
  ss0->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
  ss0->duration=NULL;

  // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed
  ss0->monitoringSymbolsWithinSlot->buf[1] = 0;
rmagueta's avatar
rmagueta committed
143
  ss0->monitoringSymbolsWithinSlot->buf[0] = (1<<7);
144 145 146
  ss0->monitoringSymbolsWithinSlot->size = 2;
  ss0->monitoringSymbolsWithinSlot->bits_unused = 2;

rmagueta's avatar
rmagueta committed
147
  // FIXME: update values from TS38.213 Section 10.1 Table 10.1-1: CCE aggregation levels and maximum number of PDCCH candidates per CCE aggregation level for CSS sets configured by searchSpaceSIB1
148 149
  ss0->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
  ss0->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
150
  ss0->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2;
rmagueta's avatar
rmagueta committed
151
  ss0->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
152 153 154 155
  ss0->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;

  ss0->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common;
}
156

157
*/
158
void fill_default_secondaryCellGroup(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
159
                                     NR_ServingCellConfig_t *servingcellconfigdedicated,
160 161 162
                                     NR_CellGroupConfig_t *secondaryCellGroup,
                                     int scg_id,
                                     int servCellIndex,
163 164
                                     int dl_antenna_ports,
                                     int do_csirs,
165 166
                                     int initial_csi_index,
                                     int uid) {
167 168
  AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n");
  AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n");
169

170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
  uint64_t bitmap=0;
  switch (servingcellconfigcommon->ssb_PositionsInBurst->present) {
    case 1 :
      bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.shortBitmap.buf[0])<<56;
      break;
    case 2 :
      bitmap = ((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.mediumBitmap.buf[0])<<56;
      break;
    case 3 :
      for (int i=0; i<8; i++) {
        bitmap |= (((uint64_t) servingcellconfigcommon->ssb_PositionsInBurst->choice.longBitmap.buf[i])<<((7-i)*8));
      }
      break;
    default:
      AssertFatal(1==0,"SSB bitmap size value %d undefined (allowed values 1,2,3) \n", servingcellconfigcommon->ssb_PositionsInBurst->present);
  }
186

187 188
  memset(secondaryCellGroup,0,sizeof(NR_CellGroupConfig_t));
  secondaryCellGroup->cellGroupId = scg_id;
Cedric Roux's avatar
Cedric Roux committed
189
  NR_RLC_BearerConfig_t *RLC_BearerConfig = calloc(1,sizeof(*RLC_BearerConfig));
190
  nr_rlc_bearer_init(RLC_BearerConfig, NR_RLC_BearerConfig__servedRadioBearer_PR_drb_Identity);
191
  if (get_softmodem_params()->do_ra || get_softmodem_params()->sa)
192 193 194 195
    nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_um_Bi_Directional);
  else
    nr_drb_config(RLC_BearerConfig->rlc_Config, NR_RLC_Config_PR_am);
  nr_rlc_bearer_init_ul_spec(RLC_BearerConfig->mac_LogicalChannelConfig);
196

Cedric Roux's avatar
Cedric Roux committed
197
  secondaryCellGroup->rlc_BearerToAddModList = calloc(1,sizeof(*secondaryCellGroup->rlc_BearerToAddModList));
198
  ASN_SEQUENCE_ADD(&secondaryCellGroup->rlc_BearerToAddModList->list, RLC_BearerConfig);
rmagueta's avatar
rmagueta committed
199

Cedric Roux's avatar
Cedric Roux committed
200
  secondaryCellGroup->mac_CellGroupConfig=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig));
201
  secondaryCellGroup->mac_CellGroupConfig->drx_Config = NULL;
imad's avatar
imad committed
202 203 204 205 206
  secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig));
  secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList));
  NR_SchedulingRequestToAddMod_t *SchedulingRequestConf = calloc(1,sizeof(*SchedulingRequestConf));
  SchedulingRequestConf->schedulingRequestId = 0;  //Could be changed
  SchedulingRequestConf->sr_ProhibitTimer = calloc(1,sizeof(*SchedulingRequestConf->sr_ProhibitTimer));
imad's avatar
imad committed
207
  *SchedulingRequestConf->sr_ProhibitTimer = NR_SchedulingRequestToAddMod__sr_ProhibitTimer_ms16;
imad's avatar
imad committed
208 209 210 211
  SchedulingRequestConf->sr_TransMax = NR_SchedulingRequestToAddMod__sr_TransMax_n32;
  ASN_SEQUENCE_ADD(&secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToAddModList->list,SchedulingRequestConf);
  secondaryCellGroup->mac_CellGroupConfig->schedulingRequestConfig->schedulingRequestToReleaseList = NULL;

Cedric Roux's avatar
Cedric Roux committed
212
  secondaryCellGroup->mac_CellGroupConfig->bsr_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->bsr_Config));
213 214
  secondaryCellGroup->mac_CellGroupConfig->bsr_Config->periodicBSR_Timer = NR_BSR_Config__periodicBSR_Timer_sf10;
  secondaryCellGroup->mac_CellGroupConfig->bsr_Config->retxBSR_Timer     = NR_BSR_Config__retxBSR_Timer_sf160;
Cedric Roux's avatar
Cedric Roux committed
215
  secondaryCellGroup->mac_CellGroupConfig->tag_Config=calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config));
216
  secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToReleaseList = NULL;
Cedric Roux's avatar
Cedric Roux committed
217 218
  secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList  = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList));
  struct NR_TAG *tag=calloc(1,sizeof(*tag));
219 220
  tag->tag_Id             = 0;
  tag->timeAlignmentTimer = NR_TimeAlignmentTimer_infinity;
221
  ASN_SEQUENCE_ADD(&secondaryCellGroup->mac_CellGroupConfig->tag_Config->tag_ToAddModList->list,tag);
Cedric Roux's avatar
Cedric Roux committed
222
  secondaryCellGroup->mac_CellGroupConfig->phr_Config  = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->phr_Config));
223
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->present = NR_SetupRelease_PHR_Config_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
224
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup  = calloc(1,sizeof(*secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup));
225 226 227 228 229 230 231 232 233
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_PeriodicTimer = NR_PHR_Config__phr_PeriodicTimer_sf20;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_ProhibitTimer = NR_PHR_Config__phr_ProhibitTimer_sf0;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_Tx_PowerFactorChange = NR_PHR_Config__phr_Tx_PowerFactorChange_dB3;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->multiplePHR=false;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->dummy=false;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_Type2OtherCell = false;
  secondaryCellGroup->mac_CellGroupConfig->phr_Config->choice.setup->phr_ModeOtherCG = NR_PHR_Config__phr_ModeOtherCG_real;
  secondaryCellGroup->mac_CellGroupConfig->skipUplinkTxDynamic=false;
  secondaryCellGroup->mac_CellGroupConfig->ext1 = NULL;
Cedric Roux's avatar
Cedric Roux committed
234
  secondaryCellGroup->physicalCellGroupConfig = calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig));
235 236
  secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUCCH=NULL;
  secondaryCellGroup->physicalCellGroupConfig->harq_ACK_SpatialBundlingPUSCH=NULL;
Cedric Roux's avatar
Cedric Roux committed
237
  secondaryCellGroup->physicalCellGroupConfig->p_NR_FR1=calloc(1,sizeof(*secondaryCellGroup->physicalCellGroupConfig->p_NR_FR1));
238
  *secondaryCellGroup->physicalCellGroupConfig->p_NR_FR1=20;
239
  secondaryCellGroup->physicalCellGroupConfig->pdsch_HARQ_ACK_Codebook=NR_PhysicalCellGroupConfig__pdsch_HARQ_ACK_Codebook_dynamic;
240 241 242 243 244 245
  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;
Cedric Roux's avatar
Cedric Roux committed
246 247
  secondaryCellGroup->spCellConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig));
  secondaryCellGroup->spCellConfig->servCellIndex = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->servCellIndex));
248
  *secondaryCellGroup->spCellConfig->servCellIndex = servCellIndex;
Cedric Roux's avatar
Cedric Roux committed
249
  secondaryCellGroup->spCellConfig->reconfigurationWithSync=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->reconfigurationWithSync));
250
  secondaryCellGroup->spCellConfig->reconfigurationWithSync->spCellConfigCommon=servingcellconfigcommon;
rmagueta's avatar
rmagueta committed
251
  secondaryCellGroup->spCellConfig->reconfigurationWithSync->newUE_Identity=(get_softmodem_params()->phy_test==1) ? 0x1234 : (taus()&0xffff);
252 253 254
  secondaryCellGroup->spCellConfig->reconfigurationWithSync->t304=NR_ReconfigurationWithSync__t304_ms2000;
  secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated = NULL;
  secondaryCellGroup->spCellConfig->reconfigurationWithSync->ext1                 = NULL;
255 256

  // For 2-step contention-free random access procedure
257 258 259 260 261 262 263 264 265 266 267 268 269 270
  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;
271

272 273 274 275 276 277
    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;
278
        ssbElem[n_ssb]->ra_PreambleIndex = 63 - (uid % 64);
279 280 281
        ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->resources.choice.ssb->ssb_ResourceList.list,ssbElem[n_ssb]);
        n_ssb++;
      }
282
    }
283

284 285
    secondaryCellGroup->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink->cfra->ext1 = NULL;
  }
286

287
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants));
288
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->present = NR_SetupRelease_RLF_TimersAndConstants_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
289
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup));
290 291
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->t310 = NR_RLF_TimersAndConstants__t310_ms4000;
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n310 = NR_RLF_TimersAndConstants__n310_n20;
292
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->n311 = NR_RLF_TimersAndConstants__n311_n1;
Cedric Roux's avatar
Cedric Roux committed
293
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1 = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1));
294
  secondaryCellGroup->spCellConfig->rlf_TimersAndConstants->choice.setup->ext1->t311 = NR_RLF_TimersAndConstants__ext1__t311_ms30000;
295
  secondaryCellGroup->spCellConfig->rlmInSyncOutOfSyncThreshold                   = NULL;
296 297 298 299 300
  if (servingcellconfigdedicated) {
    secondaryCellGroup->spCellConfig->spCellConfigDedicated = servingcellconfigdedicated;
  } else {
    secondaryCellGroup->spCellConfig->spCellConfigDedicated = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated));
  }
301
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->tdd_UL_DL_ConfigurationDedicated = NULL;
Cedric Roux's avatar
Cedric Roux committed
302
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP));
303
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdcch_Config=NULL;
Cedric Roux's avatar
Cedric Roux committed
304
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config));
305
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup;
306 307
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup = calloc(1,
      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup));
308
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL;
309 310
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,
      sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA));
311
  secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
312
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
313

314 315 316 317 318
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
319

Cedric Roux's avatar
Cedric Roux committed
320
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
321
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
322

323

324
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList));
325

326
 int n_ssb = 0;
327 328 329
 NR_TCI_State_t *tcic[64];
 for (int i=0;i<64;i++) {
   if ((bitmap>>(63-i))&0x01){
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
     tcic[i]=calloc(1,sizeof(*tcic[i]));
     tcic[i]->tci_StateId=n_ssb;
     tcic[i]->qcl_Type1.cell=NULL;
     tcic[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcic[i]->qcl_Type1.bwp_Id));
     *tcic[i]->qcl_Type1.bwp_Id=1;
     tcic[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
     tcic[i]->qcl_Type1.referenceSignal.choice.ssb = i;
     tcic[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
     ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcic[i]);
     n_ssb++;
   }
 }


#if 0

Cedric Roux's avatar
Cedric Roux committed
346
 NR_TCI_State_t*tci0=calloc(1,sizeof(*tci0));
347 348
 tci0->tci_StateId=0;
 tci0->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
349
 tci0->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci0->qcl_Type1.bwp_Id));
350 351 352 353
 *tci0->qcl_Type1.bwp_Id=1;
 tci0->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci0->qcl_Type1.referenceSignal.choice.csi_rs = 2;
 tci0->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
354
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci0);
355

Cedric Roux's avatar
Cedric Roux committed
356
 NR_TCI_State_t*tci1=calloc(1,sizeof(*tci1));
357 358
 tci1->tci_StateId=1;
 tci1->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
359
 tci1->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci1->qcl_Type1.bwp_Id));
360 361 362 363
 *tci1->qcl_Type1.bwp_Id=1;
 tci1->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci1->qcl_Type1.referenceSignal.choice.csi_rs = 6;
 tci1->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
364
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci1);
365

Cedric Roux's avatar
Cedric Roux committed
366
 NR_TCI_State_t*tci2=calloc(1,sizeof(*tci2));
367 368
 tci2->tci_StateId=2;
 tci2->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
369
 tci2->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci2->qcl_Type1.bwp_Id));
370 371 372 373
 *tci2->qcl_Type1.bwp_Id=1;
 tci2->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci2->qcl_Type1.referenceSignal.choice.csi_rs = 10;
 tci2->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
374
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci2);
375

Cedric Roux's avatar
Cedric Roux committed
376
 NR_TCI_State_t *tci3=calloc(1,sizeof(*tci3));
377 378
 tci3->tci_StateId=3;
 tci3->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
379
 tci3->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci3->qcl_Type1.bwp_Id));
380 381 382 383
 *tci3->qcl_Type1.bwp_Id=1;
 tci3->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci3->qcl_Type1.referenceSignal.choice.csi_rs = 14;
 tci3->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
384
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci3);
385

Cedric Roux's avatar
Cedric Roux committed
386
 NR_TCI_State_t*tci4=calloc(1,sizeof(*tci4));
387 388
 tci4->tci_StateId=4;
 tci4->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
389
 tci4->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci4->qcl_Type1.bwp_Id));
390 391 392 393
 *tci4->qcl_Type1.bwp_Id=1;
 tci4->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci4->qcl_Type1.referenceSignal.choice.csi_rs = 18;
 tci4->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
394
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci4);
395

Cedric Roux's avatar
Cedric Roux committed
396
 NR_TCI_State_t*tci5=calloc(1,sizeof(*tci5));
397 398
 tci5->tci_StateId=5;
 tci5->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
399
 tci5->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci5->qcl_Type1.bwp_Id));
400 401 402 403
 *tci5->qcl_Type1.bwp_Id=1;
 tci5->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci5->qcl_Type1.referenceSignal.choice.csi_rs = 22;
 tci5->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
404
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci5);
405

Cedric Roux's avatar
Cedric Roux committed
406
 NR_TCI_State_t*tci6=calloc(1,sizeof(*tci6));
407 408
 tci6->tci_StateId=6;
 tci6->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
409
 tci6->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci6->qcl_Type1.bwp_Id));
410 411 412 413
 *tci6->qcl_Type1.bwp_Id=1;
 tci6->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci6->qcl_Type1.referenceSignal.choice.csi_rs = 26;
 tci6->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
414
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci6);
415

Cedric Roux's avatar
Cedric Roux committed
416
 NR_TCI_State_t*tci7=calloc(1,sizeof(*tci7));
417 418
 tci7->tci_StateId=7;
 tci7->qcl_Type1.cell=NULL;
Cedric Roux's avatar
Cedric Roux committed
419
 tci7->qcl_Type1.bwp_Id=calloc(1,sizeof(*tci7->qcl_Type1.bwp_Id));
420 421 422 423
 *tci7->qcl_Type1.bwp_Id=1;
 tci7->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_csi_rs;
 tci7->qcl_Type1.referenceSignal.choice.csi_rs = 30;
 tci7->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeA;
424
 ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tci7);
425

426
#endif
427 428 429

 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
430
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
431 432 433 434 435 436 437
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
438 439 440 441 442 443
 if (!get_softmodem_params()->use_256qam_table) {
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table=NULL;
 } else {
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table));
   *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->mcs_Table = NR_PDSCH_Config__mcs_Table_qam256;
 }
Cedric Roux's avatar
Cedric Roux committed
444
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
445 446
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
Cedric Roux's avatar
Cedric Roux committed
447
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
448
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
Cedric Roux's avatar
Cedric Roux committed
449
   calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
450 451 452 453 454 455 456 457
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
458
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
459

460 461
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = NULL;
#if 0
Cedric Roux's avatar
Cedric Roux committed
462
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig));
463 464
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;

Cedric Roux's avatar
Cedric Roux committed
465
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup));
466 467
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
Cedric Roux's avatar
Cedric Roux committed
468
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
469
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
Cedric Roux's avatar
Cedric Roux committed
470
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
471
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->initialDownlinkBWP->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
472
#endif
473 474

 secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToReleaseList= NULL;
475
 
476 477 478 479 480
 NR_BWP_Downlink_t *bwp = NULL;
 if (servingcellconfigdedicated) {
   bwp=servingcellconfigdedicated->downlinkBWP_ToAddModList->list.array[0];
 } else {
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList));
481

482 483
   bwp=calloc(1,sizeof(*bwp));
 }
484
 bwp->bwp_Id=1;
Cedric Roux's avatar
Cedric Roux committed
485
 bwp->bwp_Common=calloc(1,sizeof(*bwp->bwp_Common));
486
 // copy common BWP size from initial BWP except for bandwdith
487 488
 memcpy((void*)&bwp->bwp_Common->genericParameters,
	&servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->genericParameters,
489
	sizeof(bwp->bwp_Common->genericParameters));
490
 bwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->downlinkConfigCommon->frequencyInfoDL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
491

492
 
Cedric Roux's avatar
Cedric Roux committed
493
 bwp->bwp_Common->pdcch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon));
494
 bwp->bwp_Common->pdcch_ConfigCommon->present = NR_SetupRelease_PDCCH_ConfigCommon_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
495
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup));
496
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->controlResourceSetZero=NULL;
497
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet));
498

499 500
 int curr_bwp = NRRIV2BW(bwp->bwp_Common->genericParameters.locationAndBandwidth,275);

501 502
 NR_ControlResourceSet_t *coreset = calloc(1,sizeof(*coreset));
 coreset->controlResourceSetId=1;
503 504
 // frequency domain resources depends on BWP size
 // options are 24, 48 or 96
505
 coreset->frequencyDomainResources.buf = calloc(1,6);
506 507 508 509
 if (curr_bwp < 48)
   coreset->frequencyDomainResources.buf[0] = 0xf0;
 else
   coreset->frequencyDomainResources.buf[0] = 0xff;
510
 if (curr_bwp < 96)
511 512 513
   coreset->frequencyDomainResources.buf[1] = 0;
 else
   coreset->frequencyDomainResources.buf[1] = 0xff;
514 515 516 517 518 519 520
 coreset->frequencyDomainResources.buf[2] = 0;
 coreset->frequencyDomainResources.buf[3] = 0;
 coreset->frequencyDomainResources.buf[4] = 0;
 coreset->frequencyDomainResources.buf[5] = 0;
 coreset->frequencyDomainResources.size = 6;
 coreset->frequencyDomainResources.bits_unused = 3;
 coreset->duration=1;
521
 coreset->cce_REG_MappingType.present = NR_ControlResourceSet__cce_REG_MappingType_PR_nonInterleaved;
522 523 524
 coreset->precoderGranularity = NR_ControlResourceSet__precoderGranularity_sameAsREG_bundle;

 coreset->tci_StatesPDCCH_ToAddList=calloc(1,sizeof(*coreset->tci_StatesPDCCH_ToAddList));
525 526 527
 NR_TCI_StateId_t *tci[64];
 for (int i=0;i<64;i++) {
   if ((bitmap>>(63-i))&0x01){
528 529 530 531
     tci[i]=calloc(1,sizeof(*tci[i]));
     *tci[i] = i;
     ASN_SEQUENCE_ADD(&coreset->tci_StatesPDCCH_ToAddList->list,tci[i]);
   }
532 533 534 535
 }
 coreset->tci_StatesPDCCH_ToReleaseList = NULL;
 coreset->tci_PresentInDCI = NULL;
 coreset->pdcch_DMRS_ScramblingID = NULL;
536

537 538 539
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonControlResourceSet = coreset;

 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceZero=NULL;
540
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=NULL;
Cedric Roux's avatar
Cedric Roux committed
541
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList));
542

Cedric Roux's avatar
Cedric Roux committed
543
 NR_SearchSpace_t *ss=calloc(1,sizeof(*ss));
544
 ss->searchSpaceId = 1;
Cedric Roux's avatar
Cedric Roux committed
545
 ss->controlResourceSetId=calloc(1,sizeof(*ss->controlResourceSetId));
546
 *ss->controlResourceSetId=1;
Cedric Roux's avatar
Cedric Roux committed
547
 ss->monitoringSlotPeriodicityAndOffset = calloc(1,sizeof(*ss->monitoringSlotPeriodicityAndOffset));
548 549
 ss->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
 ss->duration=NULL; 
Cedric Roux's avatar
Cedric Roux committed
550
 ss->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss->monitoringSymbolsWithinSlot));
551 552 553
 ss->monitoringSymbolsWithinSlot->buf = calloc(1,2);
 // should be '1100 0000 0000 00'B (LSB first!), first two symols in slot, adjust if needed
 ss->monitoringSymbolsWithinSlot->buf[1] = 0;
554
 ss->monitoringSymbolsWithinSlot->buf[0] = (1<<7) | (1<<6);
555 556
 ss->monitoringSymbolsWithinSlot->size = 2;
 ss->monitoringSymbolsWithinSlot->bits_unused = 2;
Cedric Roux's avatar
Cedric Roux committed
557
 ss->nrofCandidates = calloc(1,sizeof(*ss->nrofCandidates));
558 559 560 561 562
 ss->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
 ss->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
 ss->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
 ss->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
 ss->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
Cedric Roux's avatar
Cedric Roux committed
563
 ss->searchSpaceType = calloc(1,sizeof(*ss->searchSpaceType));
564
 ss->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_common;
Cedric Roux's avatar
Cedric Roux committed
565 566
 ss->searchSpaceType->choice.common=calloc(1,sizeof(*ss->searchSpaceType->choice.common));
 ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0 = calloc(1,sizeof(*ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0));
567 568

 ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList->list,ss);
569

francescomani's avatar
francescomani committed
570 571 572 573 574
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=NULL;
 if(get_softmodem_params()->sa) {
   bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1));
   *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=0;
 }
575 576
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation=NULL;
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->pagingSearchSpace=NULL;
Cedric Roux's avatar
Cedric Roux committed
577
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=calloc(1,sizeof(*bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace));
578
 *bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace=1;
579
 bwp->bwp_Common->pdcch_ConfigCommon->choice.setup->ext1=NULL;
580

Cedric Roux's avatar
Cedric Roux committed
581
 bwp->bwp_Common->pdsch_ConfigCommon=calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon));
582
 bwp->bwp_Common->pdsch_ConfigCommon->present = NR_SetupRelease_PDSCH_ConfigCommon_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
583 584
 bwp->bwp_Common->pdsch_ConfigCommon->choice.setup = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup));
 bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList = calloc(1,sizeof(*bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList));
585 586

 // copy PDSCH TimeDomainResourceAllocation from InitialBWP
587
 
588
 NR_PDSCH_TimeDomainResourceAllocation_t *pdschi;
589
 for (int i=0;i<servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count;i++) {
590
   pdschi= calloc(1,sizeof(*pdschi));
591 592 593 594
   AssertFatal(servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0!=NULL,"element %d is null\n",i);
 
   pdschi->k0 = calloc(1,sizeof(*pdschi->k0));
   *pdschi->k0 = *servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->k0;
595 596 597 598 599
   pdschi->mappingType = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->mappingType;
   pdschi->startSymbolAndLength = servingcellconfigcommon->downlinkConfigCommon->initialDownlinkBWP->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[i]->startSymbolAndLength;
   ASN_SEQUENCE_ADD(&bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list,pdschi);
 }

600 601 602
 if (!servingcellconfigdedicated) {
   bwp->bwp_Dedicated=calloc(1,sizeof(*bwp->bwp_Dedicated));
 }
Cedric Roux's avatar
Cedric Roux committed
603
 bwp->bwp_Dedicated->pdcch_Config=calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config));
604
 bwp->bwp_Dedicated->pdcch_Config->present = NR_SetupRelease_PDCCH_Config_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
605 606
 bwp->bwp_Dedicated->pdcch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup));
 bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList));
607

608
 ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->controlResourceSetToAddModList->list,
609
		  coreset);
610

Cedric Roux's avatar
Cedric Roux committed
611
 bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList = calloc(1,sizeof(*bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList));
612

Cedric Roux's avatar
Cedric Roux committed
613
 NR_SearchSpace_t *ss2 = calloc(1,sizeof(*ss2));
614 615

 ss2->searchSpaceId=2;
Cedric Roux's avatar
Cedric Roux committed
616
 ss2->controlResourceSetId=calloc(1,sizeof(*ss2->controlResourceSetId));
617 618 619 620 621
 *ss2->controlResourceSetId=1;
 ss2->monitoringSlotPeriodicityAndOffset=calloc(1,sizeof(*ss2->monitoringSlotPeriodicityAndOffset));
 ss2->monitoringSlotPeriodicityAndOffset->present = NR_SearchSpace__monitoringSlotPeriodicityAndOffset_PR_sl1;
 ss2->monitoringSlotPeriodicityAndOffset->choice.sl1=(NULL_t)0;
 ss2->duration=NULL;
Cedric Roux's avatar
Cedric Roux committed
622
 ss2->monitoringSymbolsWithinSlot = calloc(1,sizeof(*ss2->monitoringSymbolsWithinSlot));
623 624 625
 ss2->monitoringSymbolsWithinSlot->buf = calloc(1,2);
 ss2->monitoringSymbolsWithinSlot->size = 2;
 ss2->monitoringSymbolsWithinSlot->bits_unused = 2;
626 627
 ss2->monitoringSymbolsWithinSlot->buf[0]=0xc0;
 ss2->monitoringSymbolsWithinSlot->buf[1]=0x0;
628 629 630
 ss2->nrofCandidates=calloc(1,sizeof(*ss2->nrofCandidates));
 ss2->nrofCandidates->aggregationLevel1 = NR_SearchSpace__nrofCandidates__aggregationLevel1_n0;
 ss2->nrofCandidates->aggregationLevel2 = NR_SearchSpace__nrofCandidates__aggregationLevel2_n0;
631 632 633 634 635 636
 if (curr_bwp < 48)
   ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n1;
 else if (curr_bwp < 96)
   ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n2;
 else
   ss2->nrofCandidates->aggregationLevel4 = NR_SearchSpace__nrofCandidates__aggregationLevel4_n4;
637 638 639 640 641
 ss2->nrofCandidates->aggregationLevel8 = NR_SearchSpace__nrofCandidates__aggregationLevel8_n0;
 ss2->nrofCandidates->aggregationLevel16 = NR_SearchSpace__nrofCandidates__aggregationLevel16_n0;
 ss2->searchSpaceType=calloc(1,sizeof(*ss2->searchSpaceType));
 ss2->searchSpaceType->present = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
 ss2->searchSpaceType->choice.ue_Specific = calloc(1,sizeof(*ss2->searchSpaceType->choice.ue_Specific));
642
 ss2->searchSpaceType->choice.ue_Specific->dci_Formats=NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1;
643 644 645 646 647 648

 ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToAddModList->list,
		  ss2);


 bwp->bwp_Dedicated->pdcch_Config->choice.setup->searchSpacesToReleaseList = NULL;
649

650 651
 if (!servingcellconfigdedicated) {
  bwp->bwp_Dedicated->pdsch_Config = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config));
652 653

  bwp->bwp_Dedicated->pdsch_Config->present = NR_SetupRelease_PDSCH_Config_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
654 655
  bwp->bwp_Dedicated->pdsch_Config->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup));
  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA));
656
  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->present= NR_SetupRelease_DMRS_DownlinkConfig_PR_setup;
657

658 659 660
  bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup));
 }
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->dataScramblingIdentityPDSCH = NULL;
661

662
 if (dl_antenna_ports > 1)// for MIMO, we use DMRS Config Type 2
663 664 665
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type));
 else
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type=NULL;
666 667 668
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->maxLength=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID0=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->scramblingID1=NULL;
669 670 671
 if (!servingcellconfigdedicated) {
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=NULL;
 }
Cedric Roux's avatar
Cedric Roux committed
672
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition));
673
 *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_AdditionalPosition = NR_DMRS_DownlinkConfig__dmrs_AdditionalPosition_pos0;
674

675 676 677
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList));

 n_ssb = 0;
678 679 680
 NR_TCI_State_t *tcid[64];
 for (int i=0;i<64;i++) {
   if ((bitmap>>(63-i))&0x01){
681 682 683 684 685 686 687 688 689 690 691 692 693 694
     tcid[i]=calloc(1,sizeof(*tcid[i]));
     tcid[i]->tci_StateId=n_ssb;
     tcid[i]->qcl_Type1.cell=NULL;
     tcid[i]->qcl_Type1.bwp_Id=calloc(1,sizeof(*tcid[i]->qcl_Type1.bwp_Id));
     *tcid[i]->qcl_Type1.bwp_Id=1;
     tcid[i]->qcl_Type1.referenceSignal.present = NR_QCL_Info__referenceSignal_PR_ssb;
     tcid[i]->qcl_Type1.referenceSignal.choice.ssb = i;
     tcid[i]->qcl_Type1.qcl_Type=NR_QCL_Info__qcl_Type_typeC;
     ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToAddModList->list,tcid[i]);
     n_ssb++;
   }
 }


695 696
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
697
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
698 699 700 701 702 703 704
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
705 706 707 708 709 710
 if (!get_softmodem_params()->use_256qam_table) {
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
 } else {
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table));
   *bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NR_PDSCH_Config__mcs_Table_qam256;
 }
Cedric Roux's avatar
Cedric Roux committed
711
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
712 713
 *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
Cedric Roux's avatar
Cedric Roux committed
714
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
715
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
Cedric Roux's avatar
Cedric Roux committed
716
   calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
717 718 719 720 721 722 723 724 725 726 727
 *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;

 bwp->bwp_Dedicated->pdsch_Config->choice.setup->tci_StatesToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->vrb_ToPRB_Interleaver=NULL;
728
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->resourceAllocation=NR_PDSCH_Config__resourceAllocation_resourceAllocationType1;
729 730 731 732 733 734 735
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_TimeDomainAllocationList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->pdsch_AggregationFactor=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup1=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rateMatchPatternGroup2=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->rbg_Size=NR_PDSCH_Config__rbg_Size_config1;
736 737 738 739 740 741
 if (!get_softmodem_params()->use_256qam_table) {
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table=NULL;
 } else {
   bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table));
   *bwp->bwp_Dedicated->pdsch_Config->choice.setup->mcs_Table = NR_PDSCH_Config__mcs_Table_qam256;
 }
Cedric Roux's avatar
Cedric Roux committed
742
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI));
743 744
 *bwp->bwp_Dedicated->pdsch_Config->choice.setup->maxNrofCodeWordsScheduledByDCI = NR_PDSCH_Config__maxNrofCodeWordsScheduledByDCI_n1;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.present = NR_PDSCH_Config__prb_BundlingType_PR_staticBundling;
Cedric Roux's avatar
Cedric Roux committed
745
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling));
746
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize =
Cedric Roux's avatar
Cedric Roux committed
747
   calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize));
748 749 750 751 752 753 754 755
 *bwp->bwp_Dedicated->pdsch_Config->choice.setup->prb_BundlingType.choice.staticBundling->bundleSize = NR_PDSCH_Config__prb_BundlingType__staticBundling__bundleSize_wideband;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->zp_CSI_RS_ResourceToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->aperiodic_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToAddModList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->sp_ZP_CSI_RS_ResourceSetsToReleaseList=NULL;
 bwp->bwp_Dedicated->pdsch_Config->choice.setup->p_ZP_CSI_RS_ResourceSet=NULL;
756
 bwp->bwp_Dedicated->sps_Config = NULL; //calloc(1,sizeof(struct NR_SetupRelease_SPS_Config));
757

758 759
 bwp->bwp_Dedicated->radioLinkMonitoringConfig = NULL;
#if 0
Cedric Roux's avatar
Cedric Roux committed
760
 bwp->bwp_Dedicated->radioLinkMonitoringConfig = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig));
761 762
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->present = NR_SetupRelease_RadioLinkMonitoringConfig_PR_setup;

Cedric Roux's avatar
Cedric Roux committed
763
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup));
764 765
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToAddModList=NULL;
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->failureDetectionResourcesToReleaseList=NULL;
Cedric Roux's avatar
Cedric Roux committed
766
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount));
767
 *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureInstanceMaxCount = NR_RadioLinkMonitoringConfig__beamFailureInstanceMaxCount_n3;
Cedric Roux's avatar
Cedric Roux committed
768
 bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = calloc(1,sizeof(*bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer));
769
 *bwp->bwp_Dedicated->radioLinkMonitoringConfig->choice.setup->beamFailureDetectionTimer = NR_RadioLinkMonitoringConfig__beamFailureDetectionTimer_pbfd2;
770
#endif
771
 
772 773 774
 if (!servingcellconfigdedicated) {
   ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList->list,bwp);
 }
775
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id));
776
 
777 778 779
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id=1;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->bwp_InactivityTimer = NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = NULL;
780 781
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = calloc(1, sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id));
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->defaultDownlinkBWP_Id = 1;
782

783 784 785
 if (!servingcellconfigdedicated) {
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig));
 }
786

Cedric Roux's avatar
Cedric Roux committed
787
 NR_BWP_UplinkDedicated_t *initialUplinkBWP = calloc(1,sizeof(*initialUplinkBWP));
788
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP = initialUplinkBWP;
789
 initialUplinkBWP->pucch_Config = NULL;
790
 initialUplinkBWP->pusch_Config = calloc(1,sizeof(*initialUplinkBWP->pusch_Config));
791
 initialUplinkBWP->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
792 793 794 795 796 797
 NR_PUSCH_Config_t *pusch_Config = NULL;
 if (servingcellconfigdedicated) {
   pusch_Config = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0]->bwp_Dedicated->pusch_Config->choice.setup;
 } else {
   pusch_Config = calloc(1,sizeof(*pusch_Config));
 }
798 799
 initialUplinkBWP->pusch_Config->choice.setup = pusch_Config;
 pusch_Config->txConfig=calloc(1,sizeof(*pusch_Config->txConfig));
800 801
 *pusch_Config->txConfig= NR_PUSCH_Config__txConfig_codebook;
 pusch_Config->dmrs_UplinkForPUSCH_MappingTypeA = NULL;
802 803 804 805 806
 if (!servingcellconfigdedicated) {
  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB));
  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->present = NR_SetupRelease_DMRS_UplinkConfig_PR_setup;
  pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup = calloc(1,sizeof(*pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup));
 }
807
 NR_DMRS_UplinkConfig_t *NR_DMRS_UplinkConfig = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup;
808
 NR_DMRS_UplinkConfig->dmrs_Type = NULL;
809 810
 NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = calloc(1,sizeof(*NR_DMRS_UplinkConfig->dmrs_AdditionalPosition));
 *NR_DMRS_UplinkConfig->dmrs_AdditionalPosition = NR_DMRS_UplinkConfig__dmrs_AdditionalPosition_pos0;
811 812 813
 if (!servingcellconfigdedicated) {
   NR_DMRS_UplinkConfig->phaseTrackingRS=NULL;
 }
814 815 816 817 818 819 820
 NR_DMRS_UplinkConfig->maxLength=NULL;
 NR_DMRS_UplinkConfig->transformPrecodingDisabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingDisabled));
 NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID0 = NULL;
 NR_DMRS_UplinkConfig->transformPrecodingDisabled->scramblingID1 = NULL;
 NR_DMRS_UplinkConfig->transformPrecodingEnabled = NULL;
 pusch_Config->pusch_PowerControl = calloc(1,sizeof(*pusch_Config->pusch_PowerControl));
 pusch_Config->pusch_PowerControl->tpc_Accumulation = NULL;
821 822
 pusch_Config->pusch_PowerControl->msg3_Alpha = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->msg3_Alpha));
 *pusch_Config->pusch_PowerControl->msg3_Alpha = NR_Alpha_alpha1;
823
 pusch_Config->pusch_PowerControl->p0_NominalWithoutGrant = NULL;
Cedric Roux's avatar
Cedric Roux committed
824 825
 pusch_Config->pusch_PowerControl->p0_AlphaSets = calloc(1,sizeof(*pusch_Config->pusch_PowerControl->p0_AlphaSets));
 NR_P0_PUSCH_AlphaSet_t *aset = calloc(1,sizeof(*aset));
826 827 828
 aset->p0_PUSCH_AlphaSetId=0;
 aset->p0=calloc(1,sizeof(*aset->p0));
 *aset->p0 = 0;
829
 aset->alpha=calloc(1,sizeof(*aset->alpha));
830
 *aset->alpha=NR_Alpha_alpha1;
831
 ASN_SEQUENCE_ADD(&pusch_Config->pusch_PowerControl->p0_AlphaSets->list,aset);
832
 pusch_Config->pusch_PowerControl->pathlossReferenceRSToAddModList = NULL;
833 834 835 836 837 838 839 840
 pusch_Config->pusch_PowerControl->pathlossReferenceRSToReleaseList = NULL;
 pusch_Config->pusch_PowerControl->twoPUSCH_PC_AdjustmentStates = NULL;
 pusch_Config->pusch_PowerControl->deltaMCS = NULL;
 pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToAddModList = NULL;
 pusch_Config->pusch_PowerControl->sri_PUSCH_MappingToReleaseList = NULL;
 pusch_Config->frequencyHopping=NULL;
 pusch_Config->frequencyHoppingOffsetLists=NULL;
 pusch_Config->resourceAllocation = NR_PUSCH_Config__resourceAllocation_resourceAllocationType1;
841
 pusch_Config->pusch_TimeDomainAllocationList = NULL;
842 843 844
 pusch_Config->pusch_AggregationFactor=NULL;
 pusch_Config->mcs_Table=NULL;
 pusch_Config->mcs_TableTransformPrecoder=NULL;
845 846 847 848 849 850
 pusch_Config->transformPrecoder= NULL;
 /* if msg3_transformprecoding is set in conf file - pusch config should not disable it */
 if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder == NULL) {
    pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder));
    *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_disabled;
 }
851 852 853 854
 pusch_Config->codebookSubset=calloc(1,sizeof(*pusch_Config->codebookSubset));
 *pusch_Config->codebookSubset = NR_PUSCH_Config__codebookSubset_nonCoherent;
 pusch_Config->maxRank=calloc(1,sizeof(*pusch_Config->maxRank));
 *pusch_Config->maxRank= 1;
855 856 857 858
 pusch_Config->rbg_Size=NULL;
 pusch_Config->uci_OnPUSCH=NULL;
 pusch_Config->tp_pi2BPSK=NULL;

859
 /*------------------------------TRANSFORM PRECODING- -----------------------------------------------------------------------*/
860

861 862 863 864 865 866 867 868 869 870 871 872 873 874
 uint8_t transform_precoding = NR_PUSCH_Config__transformPrecoder_disabled;

 // TBD: configure this from .conf file, Dedicated params cannot yet be configured in .conf file.
 // Enable this to test transform precoding enabled from dedicated config.
 /*if (pusch_Config->transformPrecoder == NULL)
    pusch_Config->transformPrecoder=calloc(1,sizeof(*pusch_Config->transformPrecoder));

 *pusch_Config->transformPrecoder = NR_PUSCH_Config__transformPrecoder_enabled;  */
  // END -------

 if (pusch_Config->transformPrecoder == NULL) {
  if (servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon->choice.setup->msg3_transformPrecoder != NULL)
    transform_precoding = NR_PUSCH_Config__transformPrecoder_enabled;
 }
875
 else
876
    transform_precoding = *pusch_Config->transformPrecoder;
877 878


879 880 881 882
 if (transform_precoding == NR_PUSCH_Config__transformPrecoder_enabled ) {
    /* Enable DMRS uplink config for transform precoding enabled */
    NR_DMRS_UplinkConfig->transformPrecodingEnabled = calloc(1,sizeof(*NR_DMRS_UplinkConfig->transformPrecodingEnabled));
    NR_DMRS_UplinkConfig->transformPrecodingEnabled->nPUSCH_Identity = NULL;
883
    NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceGroupHopping = NULL;
884
    NR_DMRS_UplinkConfig->transformPrecodingEnabled->sequenceHopping = NULL;
885
    NR_DMRS_UplinkConfig->transformPrecodingEnabled->ext1 = NULL;
886 887

    LOG_I(RRC,"TRANSFORM PRECODING ENABLED......\n");
888

889 890 891
  }
 /*----------------------------------------------------------------------------------------------------------------------------*/ 

892
 initialUplinkBWP->srs_Config = calloc(1,sizeof(*initialUplinkBWP->srs_Config));
893
 initialUplinkBWP->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
894
 NR_SRS_Config_t *srs_Config = calloc(1,sizeof(*srs_Config));
895
 initialUplinkBWP->srs_Config->choice.setup=srs_Config;
896 897 898 899 900 901 902 903 904 905
 srs_Config->srs_ResourceSetToReleaseList=NULL;
 srs_Config->srs_ResourceSetToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceSetToAddModList));
 NR_SRS_ResourceSet_t *srs_resset0=calloc(1,sizeof(*srs_resset0));
 srs_resset0->srs_ResourceSetId = 0;
 srs_resset0->srs_ResourceIdList=calloc(1,sizeof(*srs_resset0->srs_ResourceIdList));
 NR_SRS_ResourceId_t *srs_resset0_id=calloc(1,sizeof(*srs_resset0_id));
 *srs_resset0_id=0;
 ASN_SEQUENCE_ADD(&srs_resset0->srs_ResourceIdList->list,srs_resset0_id);
 srs_Config->srs_ResourceToReleaseList=NULL;
 srs_resset0->resourceType.present =  NR_SRS_ResourceSet__resourceType_PR_aperiodic;
906 907
 srs_resset0->resourceType.choice.aperiodic = calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic));
 srs_resset0->resourceType.choice.aperiodic->aperiodicSRS_ResourceTrigger=1;
908
 srs_resset0->resourceType.choice.aperiodic->csi_RS=NULL;
Raymond Knopp's avatar
Raymond Knopp committed
909
 srs_resset0->resourceType.choice.aperiodic->slotOffset= calloc(1,sizeof(*srs_resset0->resourceType.choice.aperiodic->slotOffset));
910 911 912
 *srs_resset0->resourceType.choice.aperiodic->slotOffset=2;
 srs_resset0->resourceType.choice.aperiodic->ext1=NULL;
 srs_resset0->usage=NR_SRS_ResourceSet__usage_codebook;
913 914
 srs_resset0->alpha = calloc(1,sizeof(*srs_resset0->alpha));
 *srs_resset0->alpha = NR_Alpha_alpha1;
915 916 917 918 919 920 921 922 923 924
 srs_resset0->p0=calloc(1,sizeof(*srs_resset0->p0));
 *srs_resset0->p0=-80;
 srs_resset0->pathlossReferenceRS=NULL;
 srs_resset0->srs_PowerControlAdjustmentStates=NULL;
 ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceSetToAddModList->list,srs_resset0);
 srs_Config->srs_ResourceToReleaseList=NULL;
 srs_Config->srs_ResourceToAddModList=calloc(1,sizeof(*srs_Config->srs_ResourceToAddModList));
 NR_SRS_Resource_t *srs_res0=calloc(1,sizeof(*srs_res0));
 srs_res0->srs_ResourceId=0;
 srs_res0->nrofSRS_Ports=NR_SRS_Resource__nrofSRS_Ports_port1;
925
 srs_res0->ptrs_PortIndex=NULL;
926 927 928 929 930
 srs_res0->transmissionComb.present=NR_SRS_Resource__transmissionComb_PR_n2; 
 srs_res0->transmissionComb.choice.n2=calloc(1,sizeof(*srs_res0->transmissionComb.choice.n2));
 srs_res0->transmissionComb.choice.n2->combOffset_n2=0;
 srs_res0->transmissionComb.choice.n2->cyclicShift_n2=0;
 srs_res0->resourceMapping.startPosition=2;
931 932
 srs_res0->resourceMapping.nrofSymbols=NR_SRS_Resource__resourceMapping__nrofSymbols_n1;
 srs_res0->resourceMapping.repetitionFactor=NR_SRS_Resource__resourceMapping__repetitionFactor_n1;
933 934
 srs_res0->freqDomainPosition=0;
 srs_res0->freqDomainShift=0;
935
 srs_res0->freqHopping.c_SRS = 0;
936 937
 srs_res0->freqHopping.b_SRS=0;
 srs_res0->freqHopping.b_hop=0;
938 939 940 941 942
 srs_res0->groupOrSequenceHopping=NR_SRS_Resource__groupOrSequenceHopping_neither;
 srs_res0->resourceType.present= NR_SRS_Resource__resourceType_PR_aperiodic;
 srs_res0->resourceType.choice.aperiodic=calloc(1,sizeof(*srs_res0->resourceType.choice.aperiodic));
 srs_res0->sequenceId=40;
 srs_res0->spatialRelationInfo=calloc(1,sizeof(*srs_res0->spatialRelationInfo));
943 944 945
 srs_res0->spatialRelationInfo->servingCellId=NULL;
 srs_res0->spatialRelationInfo->referenceSignal.present=NR_SRS_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
 srs_res0->spatialRelationInfo->referenceSignal.choice.csi_RS_Index=0;
946 947
 ASN_SEQUENCE_ADD(&srs_Config->srs_ResourceToAddModList->list,srs_res0);

948
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToReleaseList = NULL;
949 950 951 952 953 954 955
 NR_BWP_Uplink_t *ubwp = NULL;
 if (servingcellconfigdedicated) {
   ubwp = servingcellconfigdedicated->uplinkConfig->uplinkBWP_ToAddModList->list.array[0];
 } else {
   secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList));
   ubwp = calloc(1,sizeof(*ubwp));
 }
956 957 958 959
 ubwp->bwp_Id=1;
 ubwp->bwp_Common = calloc(1,sizeof(*ubwp->bwp_Common));
 // copy bwp_Common from Initial UL BWP except for bandwidth
 memcpy((void*)&ubwp->bwp_Common->genericParameters,
960 961 962
	(void*)&servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters,
	sizeof(servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->genericParameters));
 ubwp->bwp_Common->genericParameters.locationAndBandwidth=PRBalloc_to_locationandbandwidth(servingcellconfigcommon->uplinkConfigCommon->frequencyInfoUL->scs_SpecificCarrierList.list.array[0]->carrierBandwidth,0);
963 964 965 966 967

 ubwp->bwp_Common->rach_ConfigCommon  = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->rach_ConfigCommon;
 ubwp->bwp_Common->pusch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pusch_ConfigCommon;
 ubwp->bwp_Common->pucch_ConfigCommon = servingcellconfigcommon->uplinkConfigCommon->initialUplinkBWP->pucch_ConfigCommon;
 
968 969 970
 if (!servingcellconfigdedicated) {
   ubwp->bwp_Dedicated = calloc(1,sizeof(*ubwp->bwp_Dedicated));
 }
971 972
 ubwp->bwp_Dedicated->pucch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pucch_Config));
 ubwp->bwp_Dedicated->pucch_Config->present = NR_SetupRelease_PUCCH_Config_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
973
 NR_PUCCH_Config_t *pucch_Config = calloc(1,sizeof(*pucch_Config));
974
 ubwp->bwp_Dedicated->pucch_Config->choice.setup=pucch_Config;
975 976
 pucch_Config->resourceSetToAddModList = calloc(1,sizeof(*pucch_Config->resourceSetToAddModList));
 pucch_Config->resourceSetToReleaseList = NULL;
Cedric Roux's avatar
Cedric Roux committed
977 978
 NR_PUCCH_ResourceSet_t *pucchresset0=calloc(1,sizeof(*pucchresset0));
 NR_PUCCH_ResourceSet_t *pucchresset1=calloc(1,sizeof(*pucchresset1));
979
 pucchresset0->pucch_ResourceSetId = 0;
Cedric Roux's avatar
Cedric Roux committed
980
 NR_PUCCH_ResourceId_t *pucchresset0id0=calloc(1,sizeof(*pucchresset0id0));
981
 *pucchresset0id0=1;
982
 ASN_SEQUENCE_ADD(&pucchresset0->resourceList.list,pucchresset0id0);
983
 pucchresset0->maxPayloadSize=NULL;
984

985
 ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset0);
986

987
 pucchresset1->pucch_ResourceSetId = 1;
Cedric Roux's avatar
Cedric Roux committed
988
 NR_PUCCH_ResourceId_t *pucchresset1id0=calloc(1,sizeof(*pucchresset1id0));
989
 *pucchresset1id0=2;
990
 ASN_SEQUENCE_ADD(&pucchresset1->resourceList.list,pucchresset1id0);
991
 pucchresset1->maxPayloadSize=NULL;
992
 ASN_SEQUENCE_ADD(&pucch_Config->resourceSetToAddModList->list,pucchresset1);
993 994 995

 pucch_Config->resourceToAddModList = calloc(1,sizeof(*pucch_Config->resourceToAddModList));
 pucch_Config->resourceToReleaseList = NULL;
996 997 998 999
 NR_PUCCH_Resource_t *pucchres0=calloc(1,sizeof(*pucchres0));
 NR_PUCCH_Resource_t *pucchres1=calloc(1,sizeof(*pucchres1));
 NR_PUCCH_Resource_t *pucchres2=calloc(1,sizeof(*pucchres2));
 NR_PUCCH_Resource_t *pucchres3=calloc(1,sizeof(*pucchres3));
1000

1001
 pucchres0->pucch_ResourceId=1;
1002
 pucchres0->startingPRB= (8 + uid) % curr_bwp;
1003
 pucchres0->intraSlotFrequencyHopping=NULL;
1004
 pucchres0->secondHopPRB=NULL;
1005 1006 1007 1008 1009
 pucchres0->format.present= NR_PUCCH_Resource__format_PR_format0;
 pucchres0->format.choice.format0=calloc(1,sizeof(*pucchres0->format.choice.format0));
 pucchres0->format.choice.format0->initialCyclicShift=0;
 pucchres0->format.choice.format0->nrofSymbols=1;
 pucchres0->format.choice.format0->startingSymbolIndex=13;
1010
 ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres0);
1011

1012
 pucchres2->pucch_ResourceId=2;
1013
 pucchres2->startingPRB=0;
1014
 pucchres2->intraSlotFrequencyHopping=NULL;
1015
 pucchres2->secondHopPRB=NULL;
1016 1017
 pucchres2->format.present= NR_PUCCH_Resource__format_PR_format2;
 pucchres2->format.choice.format2=calloc(1,sizeof(*pucchres2->format.choice.format2));
1018
 pucchres2->format.choice.format2->nrofPRBs=8;
1019 1020
 pucchres2->format.choice.format2->nrofSymbols=1;
 pucchres2->format.choice.format2->startingSymbolIndex=13;
1021
 ASN_SEQUENCE_ADD(&pucch_Config->resourceToAddModList->list,pucchres2);
1022 1023 1024

 pucch_Config->format2=calloc(1,sizeof(*pucch_Config->format2));
 pucch_Config->format2->present=NR_SetupRelease_PUCCH_FormatConfig_PR_setup;
Cedric Roux's avatar
Cedric Roux committed
1025
 NR_PUCCH_FormatConfig_t *pucchfmt2 = calloc(1,sizeof(*pucchfmt2));
1026
 pucch_Config->format2->choice.setup = pucchfmt2;
1027 1028
 pucchfmt2->interslotFrequencyHopping=NULL;
 pucchfmt2->additionalDMRS=NULL;
1029
 pucchfmt2->maxCodeRate=calloc(1,sizeof(*pucchfmt2->maxCodeRate));
1030
 *pucchfmt2->maxCodeRate=NR_PUCCH_MaxCodeRate_zeroDot35;
1031 1032
 pucchfmt2->nrofSlots=NULL;
 pucchfmt2->pi2BPSK=NULL;
1033 1034
 pucchfmt2->simultaneousHARQ_ACK_CSI=calloc(1,sizeof(*pucchfmt2->simultaneousHARQ_ACK_CSI));
 *pucchfmt2->simultaneousHARQ_ACK_CSI=NR_PUCCH_FormatConfig__simultaneousHARQ_ACK_CSI_true;
imad's avatar
imad committed
1035 1036 1037 1038 1039 1040 1041 1042

 // for scheduling requestresource
 pucch_Config->schedulingRequestResourceToAddModList = calloc(1,sizeof(*pucch_Config->schedulingRequestResourceToAddModList));
 NR_SchedulingRequestResourceConfig_t *schedulingRequestResourceConfig = calloc(1,sizeof(*schedulingRequestResourceConfig));
 schedulingRequestResourceConfig->schedulingRequestResourceId = 1;
 schedulingRequestResourceConfig->schedulingRequestID = 0;
 schedulingRequestResourceConfig->periodicityAndOffset = calloc(1,sizeof(*schedulingRequestResourceConfig->periodicityAndOffset));
 schedulingRequestResourceConfig->periodicityAndOffset->present = NR_SchedulingRequestResourceConfig__periodicityAndOffset_PR_sl10;
1043
 schedulingRequestResourceConfig->periodicityAndOffset->choice.sl10 = 2;
imad's avatar
imad committed
1044 1045 1046 1047
 schedulingRequestResourceConfig->resource = calloc(1,sizeof(*schedulingRequestResourceConfig->resource));
 *schedulingRequestResourceConfig->resource = 1;
 ASN_SEQUENCE_ADD(&pucch_Config->schedulingRequestResourceToAddModList->list,schedulingRequestResourceConfig);

1048 1049
 pucch_Config->schedulingRequestResourceToReleaseList=NULL;
 pucch_Config->multi_CSI_PUCCH_ResourceList=NULL;
1050
 pucch_Config->dl_DataToUL_ACK = calloc(1,sizeof(*pucch_Config->dl_DataToUL_ACK));
1051 1052
 long *delay[8];
 for (int i=0;i<8;i++) {
Cedric Roux's avatar
Cedric Roux committed
1053
   delay[i] = calloc(1,sizeof(*delay[i]));
1054
   *delay[i] = (i<6) ? (i+2) : 0;
1055
   ASN_SEQUENCE_ADD(&pucch_Config->dl_DataToUL_ACK->list,delay[i]);
1056
 }
1057 1058
 pucch_Config->spatialRelationInfoToAddModList = calloc(1,sizeof(*pucch_Config->spatialRelationInfoToAddModList));
 NR_PUCCH_SpatialRelationInfo_t *pucchspatial = calloc(1,sizeof(*pucchspatial));
1059 1060
 pucchspatial->pucch_SpatialRelationInfoId = 1;
 pucchspatial->servingCellId = NULL;
1061 1062 1063 1064 1065 1066 1067 1068
 if(do_csirs) {
   pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_csi_RS_Index;
   pucchspatial->referenceSignal.choice.csi_RS_Index = 0;
 }
 else {
   pucchspatial->referenceSignal.present = NR_PUCCH_SpatialRelationInfo__referenceSignal_PR_ssb_Index;
   pucchspatial->referenceSignal.choice.ssb_Index = 0;
 }
1069
 pucchspatial->pucch_PathlossReferenceRS_Id = 0;
1070
 pucchspatial->p0_PUCCH_Id = 1;
1071
 pucchspatial->closedLoopIndex = NR_PUCCH_SpatialRelationInfo__closedLoopIndex_i0;
1072
 ASN_SEQUENCE_ADD(&pucch_Config->spatialRelationInfoToAddModList->list,pucchspatial);
1073 1074
 pucch_Config->spatialRelationInfoToReleaseList=NULL;
 pucch_Config->pucch_PowerControl=calloc(1,sizeof(*pucch_Config->pucch_PowerControl));
Cedric Roux's avatar
Cedric Roux committed
1075
 pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0));
1076
 *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f0 = 0;
Cedric Roux's avatar
Cedric Roux committed
1077
 pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1));
1078
 *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f1 = 0;
Cedric Roux's avatar
Cedric Roux committed
1079
 pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2));
1080
 *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f2 = 0;
Cedric Roux's avatar
Cedric Roux committed
1081
 pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3));
1082
 *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f3 = 0;
Cedric Roux's avatar
Cedric Roux committed
1083
 pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4));
1084
 *pucch_Config->pucch_PowerControl->deltaF_PUCCH_f4 = 0;
Cedric Roux's avatar
Cedric Roux committed
1085
 pucch_Config->pucch_PowerControl->p0_Set = calloc(1,sizeof(*pucch_Config->pucch_PowerControl->p0_Set));
1086 1087 1088 1089
 NR_P0_PUCCH_t *p00 = calloc(1,sizeof(*p00));
 p00->p0_PUCCH_Id=1;
 p00->p0_PUCCH_Value = 0;
 ASN_SEQUENCE_ADD(&pucch_Config->pucch_PowerControl->p0_Set->list,p00);
1090
 pucch_Config->pucch_PowerControl->pathlossReferenceRSs = NULL;
1091

1092 1093 1094 1095 1096 1097
 if (!servingcellconfigdedicated) {
   // copy pusch_Config from dedicated initialBWP
   ubwp->bwp_Dedicated->pusch_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->pusch_Config));
   ubwp->bwp_Dedicated->pusch_Config->present = NR_SetupRelease_PUSCH_Config_PR_setup;
   ubwp->bwp_Dedicated->pusch_Config->choice.setup = pusch_Config;
 }
1098
 ubwp->bwp_Dedicated->configuredGrantConfig = NULL;
1099 1100 1101 1102
 ubwp->bwp_Dedicated->srs_Config = calloc(1,sizeof(*ubwp->bwp_Dedicated->srs_Config));
 ubwp->bwp_Dedicated->srs_Config->present = NR_SetupRelease_SRS_Config_PR_setup;
 ubwp->bwp_Dedicated->srs_Config->choice.setup = srs_Config;

1103 1104
 ubwp->bwp_Dedicated->beamFailureRecoveryConfig = NULL;

1105 1106 1107
 if (!servingcellconfigdedicated) {
   ASN_SEQUENCE_ADD(&secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList->list,ubwp);
 }
1108

Cedric Roux's avatar
Cedric Roux committed
1109
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id));
1110
 *secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id = 1;
1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123

 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;

1124
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->uplinkConfig->carrierSwitching = NULL;
1125

1126
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->supplementaryUplink=NULL;
1127

1128
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdcch_ServingCellConfig=NULL;
1129

1130
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig=calloc(1,sizeof(*secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig));
Cedric Roux's avatar
Cedric Roux committed
1131
 NR_PDSCH_ServingCellConfig_t *pdsch_servingcellconfig = calloc(1,sizeof(*pdsch_servingcellconfig));
1132 1133
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->present = NR_SetupRelease_PDSCH_ServingCellConfig_PR_setup;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup = pdsch_servingcellconfig;
1134 1135
 pdsch_servingcellconfig->codeBlockGroupTransmission = NULL;
 pdsch_servingcellconfig->xOverhead = NULL;
1136 1137
 pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = calloc(1, sizeof(*pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH));
 *pdsch_servingcellconfig->nrofHARQ_ProcessesForPDSCH = NR_PDSCH_ServingCellConfig__nrofHARQ_ProcessesForPDSCH_n16;
1138
 pdsch_servingcellconfig->pucch_Cell= NULL;
1139 1140 1141 1142
 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;
 pdsch_servingcellconfig->ext1->processingType2Enabled = NULL;
1143
 
1144
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig=NULL;
1145 1146
 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;
1147

Cedric Roux's avatar
Cedric Roux committed
1148
 NR_CSI_MeasConfig_t *csi_MeasConfig = calloc(1,sizeof(*csi_MeasConfig));
1149
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->csi_MeasConfig->choice.setup = csi_MeasConfig;
1150

1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179
 if (do_csirs && dl_antenna_ports > 1) {
   csi_MeasConfig->csi_IM_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceToAddModList));
   NR_CSI_IM_Resource_t *imres0 = calloc(1,sizeof(*imres0));
   imres0->csi_IM_ResourceId = 0;
   imres0->csi_IM_ResourceElementPattern = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern));
   imres0->csi_IM_ResourceElementPattern->present = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern_PR_pattern1;
   imres0->csi_IM_ResourceElementPattern->choice.pattern1 = calloc(1,sizeof(*imres0->csi_IM_ResourceElementPattern->choice.pattern1));
   imres0->csi_IM_ResourceElementPattern->choice.pattern1->subcarrierLocation_p1 = NR_CSI_IM_Resource__csi_IM_ResourceElementPattern__pattern1__subcarrierLocation_p1_s4;
   imres0->csi_IM_ResourceElementPattern->choice.pattern1->symbolLocation_p1 = 6;
   imres0->freqBand = calloc(1,sizeof(*imres0->freqBand));
   imres0->freqBand->startingRB = 0;
   imres0->freqBand->nrofRBs = 108;
   imres0->periodicityAndOffset = calloc(1,sizeof(*imres0->periodicityAndOffset));
   imres0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
   imres0->periodicityAndOffset->choice.slots320 = 0;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceToAddModList->list,imres0);
   csi_MeasConfig->csi_IM_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_IM_ResourceSetToAddModList));
   NR_CSI_IM_ResourceSet_t *imset0 = calloc(1,sizeof(*imset0));
   imset0->csi_IM_ResourceSetId = 0;
   NR_CSI_IM_ResourceId_t *res0 = calloc(1,sizeof(*res0));
   *res0 = 0;
   ASN_SEQUENCE_ADD(&imset0->csi_IM_Resources,res0);
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_IM_ResourceSetToAddModList->list,imset0);
 }
 else {
   csi_MeasConfig->csi_IM_ResourceToAddModList = NULL;
   csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL;
 }

1180
 csi_MeasConfig->csi_IM_ResourceToReleaseList = NULL;
1181
 csi_MeasConfig->csi_IM_ResourceSetToAddModList = NULL;
1182
 csi_MeasConfig->csi_IM_ResourceSetToReleaseList = NULL;
1183

1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
 if (do_csirs) {
   csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList  = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList));
   NR_NZP_CSI_RS_ResourceSet_t *nzpcsirs0 = calloc(1,sizeof(*nzpcsirs0));
   nzpcsirs0->nzp_CSI_ResourceSetId = 0;
   NR_NZP_CSI_RS_ResourceId_t *nzpid0 = calloc(1,sizeof(*nzpid0));
   *nzpid0 = 0;
   ASN_SEQUENCE_ADD(&nzpcsirs0->nzp_CSI_RS_Resources,nzpid0);
   nzpcsirs0->repetition = NULL;
   nzpcsirs0->aperiodicTriggeringOffset = NULL;
   nzpcsirs0->trs_Info = NULL;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList->list,nzpcsirs0);
 }
 else
   csi_MeasConfig->nzp_CSI_RS_ResourceSetToAddModList  = NULL;
1198

1199
 csi_MeasConfig->nzp_CSI_RS_ResourceSetToReleaseList = NULL;
1200

1201
 config_csirs(servingcellconfigcommon, csi_MeasConfig,dl_antenna_ports,do_csirs);
1202

1203 1204
 csi_MeasConfig->csi_SSB_ResourceSetToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_SSB_ResourceSetToAddModList));
 csi_MeasConfig->csi_SSB_ResourceSetToReleaseList = NULL;
1205

1206
 NR_CSI_SSB_ResourceSet_t *ssbresset0 = calloc(1,sizeof(*ssbresset0));
1207
 ssbresset0->csi_SSB_ResourceSetId=0;
1208 1209 1210 1211 1212 1213 1214 1215

 NR_SSB_Index_t *ssbresset[64];
 for (int i=0;i<64;i++) {
   if ((bitmap>>(63-i))&0x01){
     ssbresset[i]=calloc(1,sizeof(*ssbresset[i]));
     *ssbresset[i] = i;
     ASN_SEQUENCE_ADD(&ssbresset0->csi_SSB_ResourceList.list,ssbresset[i]);
   }
1216 1217 1218 1219
 }
 ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_SSB_ResourceSetToAddModList->list,ssbresset0);

 csi_MeasConfig->csi_ResourceConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ResourceConfigToAddModList));
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234

 if (do_csirs) {
   csi_MeasConfig->csi_ResourceConfigToReleaseList = NULL;
   NR_CSI_ResourceConfig_t *csires0 = calloc(1,sizeof(*csires0));
   csires0->csi_ResourceConfigId=0;
   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 = 0;
   ASN_SEQUENCE_ADD(&csires0->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->nzp_CSI_RS_ResourceSetList->list,nzp0);
   csires0->bwp_Id = 1;
   csires0->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires0);
 }
1235

1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247
 NR_CSI_ResourceConfig_t *csires1 = calloc(1,sizeof(*csires1));
 csires1->csi_ResourceConfigId=1;
 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;
 ASN_SEQUENCE_ADD(&csires1->csi_RS_ResourceSetList.choice.nzp_CSI_RS_SSB->csi_SSB_ResourceSetList->list,ssbres00);
 csires1->bwp_Id = 1;
 csires1->resourceType = NR_CSI_ResourceConfig__resourceType_periodic;
 ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires1);

1248 1249 1250 1251 1252 1253 1254 1255 1256 1257
 if (do_csirs && dl_antenna_ports > 1) {
   NR_CSI_ResourceConfig_t *csires2 = calloc(1,sizeof(*csires2));
   csires2->csi_ResourceConfigId=2;
   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 = 0;
   ASN_SEQUENCE_ADD(&csires2->csi_RS_ResourceSetList.choice.csi_IM_ResourceSetList->list,csiim00);
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ResourceConfigToAddModList->list,csires2);
 }
1258

1259 1260
 NR_PUCCH_CSI_Resource_t *pucchcsires1 = calloc(1,sizeof(*pucchcsires1));
 pucchcsires1->uplinkBandwidthPartId=1;
1261
 pucchcsires1->pucch_Resource=2;
1262 1263 1264

 csi_MeasConfig->csi_ReportConfigToAddModList = calloc(1,sizeof(*csi_MeasConfig->csi_ReportConfigToAddModList));
 csi_MeasConfig->csi_ReportConfigToReleaseList = NULL;
1265
 if (do_csirs && dl_antenna_ports > 1) {
1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388
   NR_CSI_ReportConfig_t *csirep1 = calloc(1,sizeof(*csirep1));
   csirep1->reportConfigId=0;
   csirep1->carrier=NULL;
   csirep1->resourcesForChannelMeasurement=0;
   csirep1->csi_IM_ResourcesForInterference=calloc(1,sizeof(*csirep1->csi_IM_ResourcesForInterference));
   *csirep1->csi_IM_ResourcesForInterference=2;
   csirep1->nzp_CSI_RS_ResourcesForInterference=NULL;
   csirep1->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
   csirep1->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep1->reportConfigType.choice.periodic));
   csirep1->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
   csirep1->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 9 + (20 * uid) % 320;
   ASN_SEQUENCE_ADD(&csirep1->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1);
   csirep1->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RI_PMI_CQI;
   csirep1->reportQuantity.choice.cri_RI_PMI_CQI=(NULL_t)0;
   csirep1->reportFreqConfiguration = calloc(1,sizeof(*csirep1->reportFreqConfiguration));
   csirep1->reportFreqConfiguration->cqi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->cqi_FormatIndicator));
   *csirep1->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
   csirep1->reportFreqConfiguration->pmi_FormatIndicator = calloc(1,sizeof(*csirep1->reportFreqConfiguration->pmi_FormatIndicator));
   *csirep1->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
   csirep1->reportFreqConfiguration->csi_ReportingBand = calloc(1,sizeof(*csirep1->reportFreqConfiguration->csi_ReportingBand));
   csirep1->reportFreqConfiguration->csi_ReportingBand->present = NR_CSI_ReportConfig__reportFreqConfiguration__csi_ReportingBand_PR_subbands7;
   csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.size=1;
   csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.bits_unused=1;
   csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf=malloc(1);
   csirep1->reportFreqConfiguration->csi_ReportingBand->choice.subbands7.buf[0]=254;
   csirep1->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
   csirep1->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
   csirep1->codebookConfig=calloc(1,sizeof(*csirep1->codebookConfig));
   csirep1->codebookConfig->codebookType.present = NR_CodebookConfig__codebookType_PR_type1;
   csirep1->codebookConfig->codebookType.choice.type1 = calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1));
   csirep1->codebookConfig->codebookType.choice.type1->subType.present=NR_CodebookConfig__codebookType__type1__subType_PR_typeI_SinglePanel;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel=calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel));
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.present=
     NR_CodebookConfig__codebookType__type1__subType__typeI_SinglePanel__nrOfAntennaPorts_PR_two;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two=
     calloc(1,sizeof(*csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two));
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.size=1;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.bits_unused=2;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf=malloc(1);
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->nrOfAntennaPorts.choice.two->twoTX_CodebookSubsetRestriction.buf[0]=0xfc;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.size=1;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.bits_unused=0;
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf=malloc(1);
   csirep1->codebookConfig->codebookType.choice.type1->subType.choice.typeI_SinglePanel->typeI_SinglePanel_ri_Restriction.buf[0]=0x03;
   csirep1->codebookConfig->codebookType.choice.type1->codebookMode=1;
   csirep1->dummy = NULL;
   csirep1->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
   csirep1->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled));
   //csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS));
   //*csirep1->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1;
   csirep1->cqi_Table = calloc(1,sizeof(*csirep1->cqi_Table));
   *csirep1->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
   csirep1->subbandSize = NR_CSI_ReportConfig__subbandSize_value2;
   csirep1->non_PMI_PortIndication = NULL;
   csirep1->ext1 = NULL;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep1);
 }

 if (do_csirs) {
   NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2));
   csirep2->reportConfigId=1;
   csirep2->carrier=NULL;
   csirep2->resourcesForChannelMeasurement=0;
   csirep2->csi_IM_ResourcesForInterference=NULL;
   csirep2->nzp_CSI_RS_ResourcesForInterference=NULL;
   csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
   csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic));
   csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
   csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320;
   ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1);
   csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_cri_RSRP;
   csirep2->reportQuantity.choice.cri_RSRP=(NULL_t)0;
   csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration));
   csirep2->reportFreqConfiguration->cqi_FormatIndicator = NULL;
   csirep2->reportFreqConfiguration->pmi_FormatIndicator=NULL;
   csirep2->reportFreqConfiguration->csi_ReportingBand=NULL;
   csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
   csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
   csirep2->codebookConfig=NULL;
   csirep2->dummy = NULL;
   csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
   csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled));
   csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS));
   *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1;
   csirep2->cqi_Table = NULL;
   csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
   csirep2->non_PMI_PortIndication = NULL;
   csirep2->ext1 = NULL;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2);
 }
 else{
   NR_CSI_ReportConfig_t *csirep2 = calloc(1,sizeof(*csirep2));
   csirep2->reportConfigId=1;
   csirep2->carrier=NULL;
   csirep2->resourcesForChannelMeasurement=1;
   csirep2->csi_IM_ResourcesForInterference=NULL;
   csirep2->nzp_CSI_RS_ResourcesForInterference=NULL;
   csirep2->reportConfigType.present = NR_CSI_ReportConfig__reportConfigType_PR_periodic;
   csirep2->reportConfigType.choice.periodic = calloc(1,sizeof(*csirep2->reportConfigType.choice.periodic));
   csirep2->reportConfigType.choice.periodic->reportSlotConfig.present=NR_CSI_ReportPeriodicityAndOffset_PR_slots320;
   csirep2->reportConfigType.choice.periodic->reportSlotConfig.choice.slots320 = 29 + (20 * uid) % 320;
   ASN_SEQUENCE_ADD(&csirep2->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list,pucchcsires1);
   csirep2->reportQuantity.present = NR_CSI_ReportConfig__reportQuantity_PR_ssb_Index_RSRP;
   csirep2->reportQuantity.choice.ssb_Index_RSRP=(NULL_t)0;
   csirep2->reportFreqConfiguration = calloc(1,sizeof(*csirep2->reportFreqConfiguration));
   csirep2->reportFreqConfiguration->cqi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__cqi_FormatIndicator_widebandCQI;
   csirep2->reportFreqConfiguration->pmi_FormatIndicator=NR_CSI_ReportConfig__reportFreqConfiguration__pmi_FormatIndicator_widebandPMI;
   csirep2->reportFreqConfiguration->csi_ReportingBand=NULL;
   csirep2->timeRestrictionForChannelMeasurements= NR_CSI_ReportConfig__timeRestrictionForChannelMeasurements_configured;
   csirep2->timeRestrictionForInterferenceMeasurements=NR_CSI_ReportConfig__timeRestrictionForInterferenceMeasurements_configured;
   csirep2->codebookConfig= NULL;
   csirep2->dummy = NULL;
   csirep2->groupBasedBeamReporting.present = NR_CSI_ReportConfig__groupBasedBeamReporting_PR_disabled;
   csirep2->groupBasedBeamReporting.choice.disabled=calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled));
   csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS = calloc(1,sizeof(*csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS));
   *csirep2->groupBasedBeamReporting.choice.disabled->nrofReportedRS=NR_CSI_ReportConfig__groupBasedBeamReporting__disabled__nrofReportedRS_n1;
   csirep2->cqi_Table = calloc(1,sizeof(*csirep2->cqi_Table));
   *csirep2->cqi_Table = NR_CSI_ReportConfig__cqi_Table_table1;
   csirep2->subbandSize = NR_CSI_ReportConfig__subbandSize_value1;
   csirep2->non_PMI_PortIndication = NULL;
   csirep2->ext1 = NULL;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->csi_ReportConfigToAddModList->list,csirep2);
 }
1389

1390 1391 1392 1393 1394 1395
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->sCellDeactivationTimer=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->crossCarrierSchedulingConfig=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->tag_Id=0;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->dummy=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->pathlossReferenceLinking=NULL;
 secondaryCellGroup->spCellConfig->spCellConfigDedicated->servingCellMO=NULL;
1396 1397

}
1398

1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451

void config_csirs(NR_ServingCellConfigCommon_t *servingcellconfigcommon, NR_CSI_MeasConfig_t *csi_MeasConfig, int dl_antenna_ports, int do_csirs) {

 if (do_csirs) {
   csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = calloc(1,sizeof(*csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList));
   NR_NZP_CSI_RS_Resource_t *nzpcsi0 = calloc(1,sizeof(*nzpcsi0));
   nzpcsi0->nzp_CSI_RS_ResourceId = 0;
   NR_CSI_RS_ResourceMapping_t resourceMapping;
   switch (dl_antenna_ports) {
     case 1:
       resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_row2;
       resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t));
       resourceMapping.frequencyDomainAllocation.choice.row2.size = 2;
       resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 4;
       resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=0;
       resourceMapping.frequencyDomainAllocation.choice.row2.buf[1]=16;
       resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p1;
       resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_noCDM;
       break;
     case 2:
       resourceMapping.frequencyDomainAllocation.present = NR_CSI_RS_ResourceMapping__frequencyDomainAllocation_PR_other;
       resourceMapping.frequencyDomainAllocation.choice.row2.buf = calloc(2, sizeof(uint8_t));
       resourceMapping.frequencyDomainAllocation.choice.row2.size = 1;
       resourceMapping.frequencyDomainAllocation.choice.row2.bits_unused = 2;
       resourceMapping.frequencyDomainAllocation.choice.row2.buf[0]=4;
       resourceMapping.nrofPorts = NR_CSI_RS_ResourceMapping__nrofPorts_p2;
       resourceMapping.cdm_Type = NR_CSI_RS_ResourceMapping__cdm_Type_fd_CDM2;
       break;
     default:
       AssertFatal(1==0,"Number of ports not yet supported\n");
   }
   resourceMapping.firstOFDMSymbolInTimeDomain = 6;
   resourceMapping.firstOFDMSymbolInTimeDomain2 = NULL;
   resourceMapping.density.present = NR_CSI_RS_ResourceMapping__density_PR_one;
   resourceMapping.density.choice.one = (NULL_t)0;
   resourceMapping.freqBand.startingRB = 0;
   resourceMapping.freqBand.nrofRBs = 108;
   nzpcsi0->resourceMapping = resourceMapping;
   nzpcsi0->powerControlOffset = 0;
   nzpcsi0->powerControlOffsetSS=calloc(1,sizeof(*nzpcsi0->powerControlOffsetSS));
   *nzpcsi0->powerControlOffsetSS = NR_NZP_CSI_RS_Resource__powerControlOffsetSS_db0;
   nzpcsi0->scramblingID = *servingcellconfigcommon->physCellId;
   nzpcsi0->periodicityAndOffset = calloc(1,sizeof(*nzpcsi0->periodicityAndOffset));
   nzpcsi0->periodicityAndOffset->present = NR_CSI_ResourcePeriodicityAndOffset_PR_slots320;
   nzpcsi0->periodicityAndOffset->choice.slots320 = 0;
   nzpcsi0->qcl_InfoPeriodicCSI_RS = NULL;
   ASN_SEQUENCE_ADD(&csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList->list,nzpcsi0);
 }
 else
   csi_MeasConfig->nzp_CSI_RS_ResourceToAddModList = NULL;
}


1452
void fill_default_reconfig(NR_ServingCellConfigCommon_t *servingcellconfigcommon,
1453
                           NR_ServingCellConfig_t *servingcellconfigdedicated,
1454 1455
                           NR_RRCReconfiguration_IEs_t *reconfig,
                           NR_CellGroupConfig_t *secondaryCellGroup,
1456 1457
                           int dl_antenna_ports,
                           int do_csirs,
1458 1459
                           int initial_csi_index,
                           int uid) {
1460 1461 1462 1463 1464 1465
  AssertFatal(servingcellconfigcommon!=NULL,"servingcellconfigcommon is null\n");
  AssertFatal(reconfig!=NULL,"reconfig is null\n");
  AssertFatal(secondaryCellGroup!=NULL,"secondaryCellGroup is null\n");
  // radioBearerConfig
  reconfig->radioBearerConfig=NULL;
  // secondaryCellGroup
1466 1467 1468 1469 1470
  fill_default_secondaryCellGroup(servingcellconfigcommon,
                                  servingcellconfigdedicated,
                                  secondaryCellGroup,
                                  1,
                                  1,
1471 1472
                                  dl_antenna_ports,
                                  do_csirs,
1473 1474
                                  initial_csi_index,
                                  uid);
1475

1476 1477
  xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void*)secondaryCellGroup);

1478 1479
  char scg_buffer[1024];
  asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)secondaryCellGroup, scg_buffer, 1024);
1480
  AssertFatal (enc_rval.encoded > 0, "ASN1 message encoding failed (%s, %jd)!\n", enc_rval.failed_type->name, enc_rval.encoded);
Cedric Roux's avatar
Cedric Roux committed
1481
  reconfig->secondaryCellGroup = calloc(1,sizeof(*reconfig->secondaryCellGroup));
1482
  OCTET_STRING_fromBuf(reconfig->secondaryCellGroup,
1483 1484
                       (const char *)scg_buffer,
                       (enc_rval.encoded+7)>>3);
1485 1486 1487 1488 1489 1490 1491 1492
  // measConfig
  reconfig->measConfig=NULL;
  // lateNonCriticalExtension
  reconfig->lateNonCriticalExtension = NULL;
  // nonCriticalExtension
  reconfig->nonCriticalExtension = NULL;
}

1493 1494 1495 1496
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) {
Raymond Knopp's avatar
Raymond Knopp committed
1497 1498 1499 1500 1501 1502 1503

  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;
1504 1505
  drb_ToAddMod->cnAssociation->choice.eps_BearerIdentity= eps_bearer_id;
  drb_ToAddMod->drb_Identity = rb_id;
Raymond Knopp's avatar
Raymond Knopp committed
1506 1507 1508 1509 1510
  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));
1511
  *drb_ToAddMod->pdcp_Config->drb->discardTimer=NR_PDCP_Config__drb__discardTimer_infinity;
Raymond Knopp's avatar
Raymond Knopp committed
1512 1513 1514 1515 1516 1517 1518
  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;

1519 1520
  drb_ToAddMod->pdcp_Config->drb->integrityProtection=NULL;
  drb_ToAddMod->pdcp_Config->drb->statusReportRequired=NULL;
Raymond Knopp's avatar
Raymond Knopp committed
1521 1522 1523 1524 1525 1526
  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_ms0;
  drb_ToAddMod->pdcp_Config->ext1 = NULL;
1527

Raymond Knopp's avatar
Raymond Knopp committed
1528
  ASN_SEQUENCE_ADD(&rbconfig->drb_ToAddModList->list,drb_ToAddMod);
Raymond Knopp's avatar
Raymond Knopp committed
1529 1530 1531 1532 1533

  rbconfig->drb_ToReleaseList = NULL;

  rbconfig->securityConfig = calloc(1,sizeof(*rbconfig->securityConfig));
  rbconfig->securityConfig->securityAlgorithmConfig = calloc(1,sizeof(*rbconfig->securityConfig->securityAlgorithmConfig));
1534
  rbconfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm = ciphering_algorithm;
Raymond Knopp's avatar
Raymond Knopp committed
1535 1536
  rbconfig->securityConfig->securityAlgorithmConfig->integrityProtAlgorithm=NULL;
  rbconfig->securityConfig->keyToUse = calloc(1,sizeof(*rbconfig->securityConfig->keyToUse));
1537
  *rbconfig->securityConfig->keyToUse = key_to_use;
1538

1539
//  xer_fprint(stdout, &asn_DEF_NR_RadioBearerConfig, (const void*)rbconfig);
Raymond Knopp's avatar
Raymond Knopp committed
1540
}
1541 1542 1543 1544 1545
/* 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)
{
  int i=0;
  /* check for memory allocation  */
1546
  if(bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS == NULL) {
1547 1548 1549 1550 1551 1552 1553 1554
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS=calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS));
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->present = NR_SetupRelease_PTRS_DownlinkConfig_PR_setup;
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup= calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup));
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity = calloc(1,sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity));
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity = calloc(1, sizeof(*bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity));
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = calloc(1,sizeof(long));
    bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = calloc(1,sizeof(long));
    /* Fill the given values */
1555
    for(i = 0; i < 2; i++) {
1556 1557
      ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list,&ptrsNrb[i]);
    }
1558
    for(i = 0; i < 3; i++) {
1559 1560
      ASN_SEQUENCE_ADD(&bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list,&ptrsMcs[i]);
    }
1561
  }// if memory exist then over write the old values
1562 1563
  else {
    for(i = 0; i < 2; i++) {
1564 1565
      *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->frequencyDensity->list.array[i] = ptrsNrb[i];
    }
1566
    for(i = 0; i < 3; i++) {
1567 1568 1569
      *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->timeDensity->list.array[i] = ptrsMcs[i];
    }
  }
1570

1571 1572 1573
  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->epre_Ratio = *epre_Ratio;
  *bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->phaseTrackingRS->choice.setup->resourceElementOffset = *reOffset;
}
1574
#endif