nr_ue_dci_configuration.c 20.7 KB
Newer Older
Raymond Knopp's avatar
Raymond Knopp committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * 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 nr_ue_dci_configuration.c
 * \brief functions for generating dci search procedures based on RRC Serving Cell Group Configuration
cig's avatar
cig committed
24
 * \author R. Knopp, G. Casati
Raymond Knopp's avatar
Raymond Knopp committed
25
 * \date 2020
cig's avatar
cig committed
26 27 28
 * \version 0.2
 * \company Eurecom, Fraunhofer IIS
 * \email: knopp@eurecom.fr, guido.casati@iis.fraunhofer.de
Raymond Knopp's avatar
Raymond Knopp committed
29 30 31 32 33 34 35 36 37
 * \note
 * \warning
 */

#include "mac_proto.h"
#include "mac_defs.h"
#include "assertions.h"
#include "LAYER2/NR_MAC_UE/mac_extern.h"
#include "mac_defs.h"
cig's avatar
cig committed
38
#include "common/utils/nr/nr_common.h"
cig's avatar
cig committed
39
#include "executables/softmodem-common.h"
Raymond Knopp's avatar
Raymond Knopp committed
40
#include <stdio.h>
41
#include "nfapi_nr_interface.h"
Raymond Knopp's avatar
Raymond Knopp committed
42 43 44 45 46 47 48 49

#ifdef NR_PDCCH_DCI_TOOLS_DEBUG
#define LOG_DCI_D(a...) printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) ->" a)
#else 
#define LOG_DCI_D(a...)
#endif
#define LOG_DCI_PARM(a...) LOG_D(PHY,"\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_generate_ue_ul_dlsch_params_from_dci)" a)

50
//#define DEBUG_DCI
51

Raymond Knopp's avatar
Raymond Knopp committed
52 53
void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15) {

Eurecom's avatar
Eurecom committed
54
  LOG_D(NR_MAC,"Filling search candidates for DCI\n");
55

56
  uint8_t aggregation;
57 58
  uint8_t number_of_candidates=0;
  int i=0;
Eurecom's avatar
Eurecom committed
59
  rel15->number_of_candidates=0;
60
  for (int maxL=16;maxL>0;maxL>>=1) {
61 62 63
    find_aggregation_candidates(&aggregation,
                                &number_of_candidates,
                                ss,maxL);
64

Eurecom's avatar
Eurecom committed
65 66 67 68 69 70 71
    if (number_of_candidates>0) {
      LOG_D(NR_MAC,"L %d, number of candidates %d, aggregation %d\n",maxL,number_of_candidates,aggregation);
      rel15->number_of_candidates += number_of_candidates;
      for (; i<rel15->number_of_candidates; i++) {
        rel15->CCE[i] = i*aggregation;
        rel15->L[i] = aggregation;
      }
72
    }
73
  }
Raymond Knopp's avatar
Raymond Knopp committed
74 75
}

76
void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15, fapi_nr_dl_config_request_t *dl_config, int rnti_type, int ss_id){
cig's avatar
cig committed
77

cig's avatar
cig committed
78
  uint16_t monitoringSymbolsWithinSlot = 0;
79
  uint8_t coreset_id = 1;
cig's avatar
cig committed
80
  int sps = 0;
81 82

  AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n");
83

84
  NR_BWP_Id_t bwp_id = mac->DL_BWP_Id;
85
  NR_ServingCellConfigCommon_t *scc = mac->scc;
86 87 88 89 90 91 92 93 94
  NR_ServingCellConfigCommonSIB_t *scc_SIB = mac->scc_SIB;
  NR_BWP_DownlinkCommon_t *bwp_Common=NULL;
  NR_BWP_DownlinkCommon_t *initialDownlinkBWP=NULL;
  NR_BWP_UplinkCommon_t *initialUplinkBWP=NULL;

  if (scc!=NULL || scc_SIB != NULL) {
    initialDownlinkBWP =  scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
    initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP;
  }
95
  bwp_Common = bwp_id>0 ? mac->DLbwp[bwp_id-1]->bwp_Common : NULL;
96

97
  NR_SearchSpace_t *ss;
98
  NR_ControlResourceSet_t *coreset;
99
  if(ss_id>=0) {
100 101
    ss = mac->SSpace[bwp_id][coreset_id - 1][ss_id];
    coreset = mac->coreset[bwp_id][coreset_id - 1];
102
    rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG;
103 104
  } else {
    ss = mac->search_space_zero;
105
    coreset = mac->coreset0;
rmagueta's avatar
rmagueta committed
106 107 108 109 110
    if(rnti_type == NR_RNTI_SI) {
      rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_MIB_SIB1;
    } else {
      rel15->coreset.CoreSetType = NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG_CSET_0;
    }
111
  }
112 113

  rel15->coreset.duration = coreset->duration;
114

115 116
  for (int i = 0; i < 6; i++)
    rel15->coreset.frequency_domain_resource[i] = coreset->frequencyDomainResources.buf[i];
117 118
  rel15->coreset.CceRegMappingType = coreset->cce_REG_MappingType.present ==
    NR_ControlResourceSet__cce_REG_MappingType_PR_interleaved ? FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED : FAPI_NR_CCE_REG_MAPPING_TYPE_NON_INTERLEAVED;
119 120 121 122
  if (rel15->coreset.CceRegMappingType == FAPI_NR_CCE_REG_MAPPING_TYPE_INTERLEAVED) {
    struct NR_ControlResourceSet__cce_REG_MappingType__interleaved *interleaved = coreset->cce_REG_MappingType.choice.interleaved;
    rel15->coreset.RegBundleSize = (interleaved->reg_BundleSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__reg_BundleSize_n6) ? 6 : (2 + interleaved->reg_BundleSize);
    rel15->coreset.InterleaverSize = (interleaved->interleaverSize == NR_ControlResourceSet__cce_REG_MappingType__interleaved__interleaverSize_n6) ? 6 : (2 + interleaved->interleaverSize);
123
    rel15->coreset.ShiftIndex = interleaved->shiftIndex != NULL ? *interleaved->shiftIndex : mac->physCellId;
124 125 126 127
  } else {
    rel15->coreset.RegBundleSize = 0;
    rel15->coreset.InterleaverSize = 0;
    rel15->coreset.ShiftIndex = 0;
cig's avatar
cig committed
128
  }
129

130 131 132 133 134
  rel15->coreset.precoder_granularity = coreset->precoderGranularity;

  // Scrambling RNTI
  if (coreset->pdcch_DMRS_ScramblingID) {
    rel15->coreset.pdcch_dmrs_scrambling_id = *coreset->pdcch_DMRS_ScramblingID;
cig's avatar
cig committed
135
    rel15->coreset.scrambling_rnti = mac->crnti;
136
  } else {
137
    rel15->coreset.pdcch_dmrs_scrambling_id = mac->physCellId;
138
    rel15->coreset.scrambling_rnti = 0;
cig's avatar
cig committed
139 140
  }

141 142 143 144
  // loop over RNTI type and configure resource allocation for DCI
  switch(rnti_type) {
    case NR_RNTI_C:
    // we use DL BWP dedicated
145 146 147
      sps = bwp_Common ?
	      (bwp_Common->genericParameters.cyclicPrefix ? 12 : 14) :
        initialDownlinkBWP->genericParameters.cyclicPrefix ? 12 : 14;
148 149 150
    // for SPS=14 8 MSBs in positions 13 down to 6
    monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
    rel15->rnti = mac->crnti;
151 152 153 154 155 156 157 158 159
    if (!bwp_Common) {
      rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
      rel15->BWPStart = NRRIV2PRBOFFSET(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
    }
    else {
      rel15->BWPSize = NRRIV2BW(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
      rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
      rel15->SubcarrierSpacing = bwp_Common->genericParameters.subcarrierSpacing;
    }
160
    for (int i = 0; i < rel15->num_dci_options; i++) {
Eurecom's avatar
Eurecom committed
161
      rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_C, rel15->BWPSize, bwp_id);
162
    }
163 164 165 166 167
    break;
    case NR_RNTI_RA:
    // we use the initial DL BWP
    sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
    monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
168
    rel15->rnti = mac->ra.ra_rnti;
rmagueta's avatar
rmagueta committed
169
    if (get_softmodem_params()->sa) {
170 171
      rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs;
      rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb;
rmagueta's avatar
rmagueta committed
172
    } else { // NSA mode is not using the Initial BWP
173
      rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
rmagueta's avatar
rmagueta committed
174 175
      rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
    }
176
    rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
Eurecom's avatar
Eurecom committed
177
    rel15->dci_length_options[0] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[0]], rel15->dci_format_options[0], NR_RNTI_RA, rel15->BWPSize, bwp_id);
178 179 180 181 182 183
    break;
    case NR_RNTI_P:
    break;
    case NR_RNTI_CS:
    break;
    case NR_RNTI_TC:
184 185 186
      // we use the initial DL BWP
      sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
      monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
187
      rel15->rnti = mac->ra.t_crnti;
188 189
      rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs;
      rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb;
190
      rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
191 192 193
      for (int i = 0; i < rel15->num_dci_options; i++) {
        rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_TC, rel15->BWPSize, bwp_id);
      }
194 195 196 197
    break;
    case NR_RNTI_SP_CSI:
    break;
    case NR_RNTI_SI:
198
      // we use DL BWP dedicated
199 200
      if (bwp_Common) sps = bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12;
      else sps=14; // note: normally this would be found with SSS detection
rmagueta's avatar
rmagueta committed
201

202 203
      // for SPS=14 8 MSBs in positions 13 down to 6
      monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rmagueta's avatar
rmagueta committed
204

rmagueta's avatar
rmagueta committed
205
      rel15->rnti = SI_RNTI; // SI-RNTI - 3GPP TS 38.321 Table 7.1-1: RNTI values
206 207
      rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs;
      rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb;
208 209 210 211 212

      if(mac->frequency_range == FR1)
        rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon;
      else
        rel15->SubcarrierSpacing = mac->mib->subCarrierSpacingCommon + 2;
rmagueta's avatar
rmagueta committed
213

214
      for (int i = 0; i < rel15->num_dci_options; i++) {
Eurecom's avatar
Eurecom committed
215
        rel15->dci_length_options[i] = nr_dci_size(initialDownlinkBWP,initialUplinkBWP, mac->cg, &mac->def_dci_pdu_rel15[rel15->dci_format_options[i]], rel15->dci_format_options[i], NR_RNTI_SI, rel15->BWPSize, 0);
216
      }
217 218 219 220 221 222 223 224 225 226 227 228 229
    break;
    case NR_RNTI_SFI:
    break;
    case NR_RNTI_INT:
    break;
    case NR_RNTI_TPC_PUSCH:
    break;
    case NR_RNTI_TPC_PUCCH:
    break;
    case NR_RNTI_TPC_SRS:
    break;
    default:
    break;
cig's avatar
cig committed
230
  }
231 232 233 234
  for (int i = 0; i < sps; i++) {
    if ((monitoringSymbolsWithinSlot >> (sps - 1 - i)) & 1) {
      rel15->coreset.StartSymbolIndex = i;
      break;
Raymond Knopp's avatar
Raymond Knopp committed
235
    }
236 237 238 239 240 241 242
  }
  #ifdef DEBUG_DCI
    LOG_D(MAC, "[DCI_CONFIG] Configure DCI PDU: rnti_type %d BWPSize %d BWPStart %d rel15->SubcarrierSpacing %d rel15->dci_format %d rel15->dci_length %d sps %d monitoringSymbolsWithinSlot %d \n",
      rnti_type,
      rel15->BWPSize,
      rel15->BWPStart,
      rel15->SubcarrierSpacing,
243 244
      rel15->dci_format_options[0],
      rel15->dci_length_options[0],
245 246 247 248 249
      sps,
      monitoringSymbolsWithinSlot);
  #endif
  // add DCI
  dl_config->dl_config_list[dl_config->number_pdus].pdu_type = FAPI_NR_DL_CONFIG_TYPE_DCI;
cig's avatar
cig committed
250
  dl_config->number_pdus += 1;
251
}
cig's avatar
cig committed
252

253
void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl_config, frame_t frame, int slot) {
254

255
  RA_config_t *ra = &mac->ra;
256 257
  int ss_id;

258
  uint8_t bwp_id = (mac->cg) ? mac->DL_BWP_Id : 0, coreset_id = (mac->cg) ? 1 : 0;
259
  //NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
260 261
  NR_BWP_DownlinkDedicated_t *bwpd  = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Dedicated : mac->cg->spCellConfig->spCellConfigDedicated->initialDownlinkBWP;
  NR_BWP_DownlinkCommon_t *bwp_Common = (bwp_id>0) ? mac->DLbwp[bwp_id-1]->bwp_Common : &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
262

263
  LOG_D(NR_MAC, "[DCI_CONFIG] ra_rnti %p (%x) crnti %p (%x) t_crnti %p (%x)\n", &ra->ra_rnti, ra->ra_rnti, &mac->crnti, mac->crnti, &ra->t_crnti, ra->t_crnti);
264

265 266 267
    // loop over all available SS for CORESET ID 1
  if (bwpd) {
      for (ss_id = 0; ss_id < FAPI_NR_MAX_SS_PER_CORESET && mac->SSpace[bwp_id][coreset_id - 1][ss_id] != NULL; ss_id++){
268
	LOG_D(NR_MAC, "[DCI_CONFIG] ss_id %d\n",ss_id);
269
	NR_SearchSpace_t *ss = mac->SSpace[bwp_id][coreset_id - 1][ss_id];
270 271 272 273 274 275
	fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15;
	NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon;
	struct NR_PhysicalCellGroupConfig *phy_cgc = mac->cg->physicalCellGroupConfig;
	switch (ss->searchSpaceType->present){
	case NR_SearchSpace__searchSpaceType_PR_common:
	  // this is for CSSs, we use BWP common and pdcch_ConfigCommon
276

277 278 279 280 281
	  // Fetch configuration for searchSpaceZero
	  // note: The search space with the SearchSpaceId = 0 identifies the search space configured via PBCH (MIB) and in ServingCellConfigCommon (searchSpaceZero).
	  if (pdcch_ConfigCommon->choice.setup->searchSpaceZero){
	    if (pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 == NULL){
	      pdcch_ConfigCommon->choice.setup->searchSpaceSIB1=calloc(1,sizeof(*pdcch_ConfigCommon->choice.setup->searchSpaceSIB1));
282
	    }
283
	    *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1 = 0;
284
	    LOG_D(NR_MAC, "[DCI_CONFIG] Configure SearchSpace#0 of the initial BWP\n");
285
	  }
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
	  if (ss->searchSpaceType->choice.common->dci_Format0_0_AndFormat1_0){
	    // check available SS IDs
	    if (pdcch_ConfigCommon->choice.setup->ra_SearchSpace){
	      if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->ra_SearchSpace){
		switch(ra->ra_state){
		case WAIT_RAR:
		  LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg2)\n");
		  rel15->num_dci_options = 1;
		  rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
		  if (get_softmodem_params()->sa) {
		    config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, -1);
		  } else {
		    config_dci_pdu(mac, rel15, dl_config, NR_RNTI_RA, ss_id);
		  }
		  fill_dci_search_candidates(ss, rel15);
		  break;
		case WAIT_CONTENTION_RESOLUTION:
		  LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type1-PDCCH common random access search space (RA-Msg4)\n");
		  rel15->num_dci_options = 1;
		  rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
		  config_dci_pdu(mac, rel15, dl_config, NR_RNTI_TC, -1);
		  fill_dci_search_candidates(ss, rel15);
		  break;
		default:
		  break;
		}
	      }
313
	    }
314 315 316
	    if (pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){
	      if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){
		// Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG
317
		//LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet...");
318
	      }
319
	    }
320 321 322
	    if (pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){
	      if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceOtherSystemInformation){
		// Configure monitoring of PDCCH candidates in Type0-PDCCH common search space on the MCG
323
		//LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet...");
324 325
	      }
	    }
326 327 328
	    if (pdcch_ConfigCommon->choice.setup->pagingSearchSpace){
	      if (ss->searchSpaceId == *pdcch_ConfigCommon->choice.setup->pagingSearchSpace){
		// Configure monitoring of PDCCH candidates in Type2-PDCCH common search space on the MCG
329
		//LOG_W(MAC, "[DCI_CONFIG] This seach space should not be configured yet...");
330
	      }
331 332 333
	    }
	    if (phy_cgc){
	      if (phy_cgc->cs_RNTI){
334
		LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n");
335
		LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n");
336 337 338 339
	      }
	      if (phy_cgc->ext1){
		if (phy_cgc->ext1->mcs_C_RNTI){
		  LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n");
340
		  LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...\n");
341 342 343
		}
	      }
	    }
344 345 346 347
	  } // end DCI 00 and 01
	  // DCI 2_0
	  if (ss->searchSpaceType->choice.common->dci_Format2_0){
	    LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_0 with CRC scrambled by SFI-RNTI \n");
348
	    LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n");
349 350 351 352
	  }
	  // DCI 2_1
	  if (ss->searchSpaceType->choice.common->dci_Format2_1){
	    LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_1 with CRC scrambled by INT-RNTI \n");
353
	    LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n");
354 355 356 357
	  }
	  // DCI 2_2
	  if (ss->searchSpaceType->choice.common->dci_Format2_2){
	    LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_2 with CRC scrambled by TPC-RNTI \n");
358
	    LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n");
359
	  }
360 361 362
	  // DCI 2_3
	  if (ss->searchSpaceType->choice.common->dci_Format2_3){
	    LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in Type3-PDCCH common search space for DCI format 2_3 with CRC scrambled by TPC-SRS-RNTI \n");
363
	    LOG_W(MAC, "[DCI_CONFIG] This format should not be configured yet...\n");
364
	  }
365

366 367 368
	  break;
	case NR_SearchSpace__searchSpaceType_PR_ue_Specific:
	  // this is an USS
369
	  if (ss->searchSpaceType->choice.ue_Specific &&
370 371
	      ss->searchSpaceType->choice.ue_Specific->dci_Formats == NR_SearchSpace__searchSpaceType__ue_Specific__dci_Formats_formats0_1_And_1_1 &&
	      (ra->ra_state == RA_SUCCEEDED || get_softmodem_params()->phy_test) &&
372
              mac->crnti > 0) {
373
	      // Monitors DCI 01 and 11 scrambled with C-RNTI, or CS-RNTI(s), or SP-CSI-RNTI
374
            LOG_D(NR_MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in the user specific search space\n");
375 376 377 378 379 380 381
            rel15->num_dci_options = 2;
            rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_1;
            rel15->dci_format_options[1] = NR_UL_DCI_FORMAT_0_1;
            config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C, ss_id);
            fill_dci_search_candidates(ss, rel15);

//#ifdef DEBUG_DCI
382
		LOG_D(NR_MAC, "[DCI_CONFIG] ss %d ue_Specific %p searchSpaceType->present %d dci_Formats %d\n",
383 384
		      ss_id,
		      ss->searchSpaceType->choice.ue_Specific,
385 386 387 388 389 390
		      (int)ss->searchSpaceType->present,
		      (int)ss->searchSpaceType->choice.ue_Specific->dci_Formats);
//#endif
	  }
	  if (phy_cgc){
            if (phy_cgc->cs_RNTI){
391 392
		  LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by CS-RNTI...\n");
		  LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...");
393 394
            }
            if (phy_cgc->sp_CSI_RNTI){
395 396
		  LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by SP-CSI-RNTI...\n");
		  LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...");
397 398 399
            }
	    if (phy_cgc->ext1 &&
		phy_cgc->ext1->mcs_C_RNTI){
400 401
		    LOG_D(MAC, "[DCI_CONFIG] Configure monitoring of PDCCH candidates in user specific search space for dci_Format0_0_AndFormat1_0 with CRC scrambled by MCS-C-RNTI...\n");
		    LOG_W(MAC, "[DCI_CONFIG] This RNTI should not be configured yet...");
402
            }
403 404 405 406 407
	  }
	  break;
	default:
	  AssertFatal(1 == 0, "[DCI_CONFIG] Unrecognized search space type...");
	  break;
408 409
	} // switch searchspace
      } // for ss_id
Raymond Knopp's avatar
Raymond Knopp committed
410
  }
411 412 413 414
  else {

    AssertFatal(1==0,"Handle DCI searching when CellGroup without dedicated BWP\n");
  }
415 416
  // Search space 0, CORESET ID 0

417
  NR_SetupRelease_PDCCH_ConfigCommon_t *pdcch_ConfigCommon = bwp_Common->pdcch_ConfigCommon;
418

419 420
  if (pdcch_ConfigCommon &&
      pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){
421 422 423 424 425 426 427 428 429 430 431 432 433

    NR_SearchSpace_t *ss0 = mac->search_space_zero;
    fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15;

    if (ss0->searchSpaceId == *pdcch_ConfigCommon->choice.setup->searchSpaceSIB1){
      if( (frame%2 == mac->type0_PDCCH_CSS_config.sfn_c) && (slot == mac->type0_PDCCH_CSS_config.n_0) ){
        rel15->num_dci_options = 1;
        rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
        config_dci_pdu(mac, rel15, dl_config, NR_RNTI_SI, -1);
        fill_dci_search_candidates(ss0, rel15);
      }
    }
  }
434 435
  else { // use coreset0/ss0
    NR_SearchSpace_t *ss0 = mac->search_space_zero;
francescomani's avatar
francescomani committed
436 437 438 439 440 441 442 443
    if(ss0) {
      fapi_nr_dl_config_dci_dl_pdu_rel15_t *rel15 = &dl_config->dl_config_list[0].dci_config_pdu.dci_config_rel15;
      rel15->num_dci_options = 1;
      rel15->dci_format_options[0] = NR_DL_DCI_FORMAT_1_0;
      config_dci_pdu(mac, rel15, dl_config, NR_RNTI_C , -1);
      fill_dci_search_candidates(ss0, rel15);
      dl_config->number_pdus = 1;
    }
444
  }
Raymond Knopp's avatar
Raymond Knopp committed
445
}