Commit 1e6db77b authored by francescomani's avatar francescomani

first commit

parent 1a0c0cd1
......@@ -1017,7 +1017,7 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
if(nb_rb_coreset==0) return;
#ifdef DEBUG_PDCCH
printf(PHY, "pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n",
printf("pdcch_channel_estimation: first_carrier_offset %d, BWPStart %d, coreset_start_rb %d, coreset_nb_rb %d\n",
first_carrier_offset, BWPStart, coreset_start_rb, nb_rb_coreset);
#endif
......@@ -1044,7 +1044,6 @@ void nr_pdcch_channel_estimation(PHY_VARS_NR_UE *ue,
int dmrs_ref = 0;
if (coreset->CoreSetType == NFAPI_NR_CSET_CONFIG_PDCCH_CONFIG)
dmrs_ref = BWPStart;
// generate pilot
int pilot[(nb_rb_coreset + dmrs_ref) * 3] __attribute__((aligned(16)));
nr_pdcch_dmrs_rx(ue,Ns,ue->nr_gold_pdcch[gNB_id][Ns][symbol], &pilot[0],2000,(nb_rb_coreset+dmrs_ref));
......
......@@ -911,8 +911,8 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
const double N_TA_max = Ta_max * bw_scaling * tc_factor;
NR_UE_MAC_INST_t *mac = get_mac_inst(0);
NR_BWP_Id_t dl_bwp = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp = mac->UL_BWP_Id;
NR_BWP_Id_t dl_bwp = mac->current_DL_BWP.bwp_id;
NR_BWP_Id_t ul_bwp = mac->current_UL_BWP.bwp_id;
NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL;
if(ul_bwp){
......
......@@ -427,53 +427,6 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
}
/** \brief This function performs some configuration routines according to clause 12 "Bandwidth part operation" 3GPP TS 38.213 version 16.3.0 Release 16
@param NR_UE_MAC_INST_t mac: pointer to local MAC instance
@returns void
*/
void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint32_t *bwp_ind, uint8_t *dci_format)
{
NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated;
int n_ubwp = 0;
if (scd && scd->uplinkConfig &&
scd->uplinkConfig->uplinkBWP_ToAddModList)
n_ubwp = scd->uplinkConfig->uplinkBWP_ToAddModList->list.count;
if (bwp_ind && dci_format){
switch(*dci_format){
case NR_UL_DCI_FORMAT_0_1:
mac->UL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1;
break;
case NR_DL_DCI_FORMAT_1_1:
mac->DL_BWP_Id = n_ubwp < 4 ? *bwp_ind : *bwp_ind + 1;
break;
default:
LOG_E(MAC, "In %s: failed to configure BWP Id from DCI with format %d \n", __FUNCTION__, *dci_format);
}
// configure ss coreset after switching BWP
configure_ss_coreset(mac, scd, mac->DL_BWP_Id);
} else {
if (scd->firstActiveDownlinkBWP_Id)
mac->DL_BWP_Id = *scd->firstActiveDownlinkBWP_Id;
else if (scd->defaultDownlinkBWP_Id)
mac->DL_BWP_Id = *scd->defaultDownlinkBWP_Id;
else
mac->DL_BWP_Id = 0;
if (scd->uplinkConfig && scd->uplinkConfig->firstActiveUplinkBWP_Id)
mac->UL_BWP_Id = *scd->uplinkConfig->firstActiveUplinkBWP_Id;
else
mac->UL_BWP_Id = 0;
}
LOG_D(MAC, "In %s setting DL_BWP_Id %ld UL_BWP_Id %ld \n", __FUNCTION__, mac->DL_BWP_Id, mac->UL_BWP_Id);
}
/** \brief This function is relavant for the UE procedures for control. It loads the search spaces, the BWPs and the CORESETs into the MAC instance and
\brief performs assert checks on the relevant RRC configuration.
@param NR_UE_MAC_INST_t mac: pointer to local MAC instance
......@@ -483,8 +436,7 @@ void config_control_ue(NR_UE_MAC_INST_t *mac){
int bwp_id;
NR_ServingCellConfig_t *scd = mac->cg->spCellConfig->spCellConfigDedicated;
config_bwp_ue(mac, NULL, NULL);
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id;
// configure DLbwp
if (scd->downlinkBWP_ToAddModList) {
......@@ -586,16 +538,94 @@ int nr_rrc_mac_config_req_ue_logicalChannelBearer(
return 0;
}
int nr_rrc_mac_config_req_ue(
module_id_t module_id,
void configure_current_BWP(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfigCommonSIB_t *scc,
NR_CellGroupConfig_t *cell_group_config)
{
NR_DL_BWP_t *DL_BWP = &mac->current_DL_BWP;
NR_UL_BWP_t *UL_BWP = &mac->current_UL_BWP;
if(scc) {
DL_BWP->bwp_id = 0;
UL_BWP->bwp_id = 0;
DL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
if(scc->uplinkConfigCommon)
UL_BWP->genericParameters = scc->uplinkConfigCommon->initialUplinkBWP.genericParameters;
else
UL_BWP->genericParameters = scc->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
}
if(cell_group_config) {
if (cell_group_config->spCellConfig &&
cell_group_config->spCellConfig->spCellConfigDedicated) {
struct NR_ServingCellConfig *spCellConfigDedicated = cell_group_config->spCellConfig->spCellConfigDedicated;
if (spCellConfigDedicated->firstActiveDownlinkBWP_Id)
DL_BWP->bwp_id = *spCellConfigDedicated->firstActiveDownlinkBWP_Id;
if (spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id)
UL_BWP->bwp_id = *spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id;
NR_BWP_Downlink_t *bwp_downlink = NULL;
const struct NR_ServingCellConfig__downlinkBWP_ToAddModList *bwpList = spCellConfigDedicated->downlinkBWP_ToAddModList;
if (bwpList && DL_BWP->bwp_id > 0) {
for (int i = 0; i < bwpList->list.count; i++) {
bwp_downlink = bwpList->list.array[i];
if(bwp_downlink->bwp_Id == DL_BWP->bwp_id)
break;
}
AssertFatal(bwp_downlink != NULL,"Couldn't find DLBWP corresponding to BWP ID %ld\n", DL_BWP->bwp_id);
DL_BWP->genericParameters = bwp_downlink->bwp_Common->genericParameters;
}
else {
if(mac->scc) {
DL_BWP->genericParameters = mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters;
}
if(mac->scc_SIB) {
DL_BWP->genericParameters = mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
}
}
NR_BWP_Uplink_t *bwp_uplink = NULL;
const struct NR_UplinkConfig__uplinkBWP_ToAddModList *ubwpList = spCellConfigDedicated->uplinkConfig->uplinkBWP_ToAddModList;
if (ubwpList && UL_BWP->bwp_id > 0) {
for (int i = 0; i < ubwpList->list.count; i++) {
bwp_uplink = ubwpList->list.array[i];
if(bwp_uplink->bwp_Id == UL_BWP->bwp_id)
break;
}
AssertFatal(bwp_uplink != NULL,"Couldn't find ULBWP corresponding to BWP ID %ld\n",UL_BWP->bwp_id);
UL_BWP->genericParameters = bwp_uplink->bwp_Common->genericParameters;
}
else {
if(mac->scc) {
UL_BWP->genericParameters = mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters;
}
if(mac->scc_SIB) {
UL_BWP->genericParameters = mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters;
}
}
}
else
AssertFatal(1==0,"We shouldn't end here in configuring BWP\n");
}
DL_BWP->scs = DL_BWP->genericParameters.subcarrierSpacing;
DL_BWP->cyclicprefix = DL_BWP->genericParameters.cyclicPrefix;
DL_BWP->BWPSize = NRRIV2BW(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
DL_BWP->BWPStart = NRRIV2PRBOFFSET(DL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
UL_BWP->scs = UL_BWP->genericParameters.subcarrierSpacing;
UL_BWP->cyclicprefix = UL_BWP->genericParameters.cyclicPrefix;
UL_BWP->BWPSize = NRRIV2BW(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
UL_BWP->BWPStart = NRRIV2PRBOFFSET(UL_BWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
}
int nr_rrc_mac_config_req_ue(module_id_t module_id,
int cc_idP,
uint8_t gNB_index,
NR_MIB_t *mibP,
NR_ServingCellConfigCommonSIB_t *sccP,
// NR_MAC_CellGroupConfig_t *mac_cell_group_configP,
// NR_PhysicalCellGroupConfig_t *phy_cell_group_configP,
NR_CellGroupConfig_t *cell_group_config,
NR_CellGroupConfig_t *scell_group_config){
NR_CellGroupConfig_t *scell_group_config)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
RA_config_t *ra = &mac->ra;
......@@ -613,9 +643,10 @@ int nr_rrc_mac_config_req_ue(
if (sccP != NULL) {
mac->scc_SIB=sccP;
mac->scc_SIB = sccP;
LOG_D(NR_MAC, "In %s: Keeping ServingCellConfigCommonSIB\n", __FUNCTION__);
config_common_ue_sa(mac,module_id,cc_idP);
config_common_ue_sa(mac, module_id, cc_idP);
configure_current_BWP(mac, sccP, NULL);
int num_slots_ul = nr_slots_per_frame[mac->mib->subCarrierSpacingCommon];
if(cfg->cell_config.frame_duplex_type == TDD){
......@@ -628,7 +659,7 @@ int nr_rrc_mac_config_req_ue(
mac->ul_config_request = (fapi_nr_ul_config_request_t *)calloc(num_slots_ul, sizeof(fapi_nr_ul_config_request_t));
for (int i=0; i<num_slots_ul; i++)
pthread_mutex_init(&(mac->ul_config_request[i].mutex_ul_config), NULL);
// Setup the SSB to Rach Occasions mapping according to the config
// Setup the SSB to Rach Occasionsif (cell_group_config->spCellConfig) { mapping according to the config
build_ssb_to_ro_map(mac);//->scc, mac->phy_config.config_req.cell_config.frame_duplex_type);
if (!get_softmodem_params()->emulate_l1)
mac->if_module->phy_config_request(&mac->phy_config);
......@@ -636,10 +667,6 @@ int nr_rrc_mac_config_req_ue(
if(scell_group_config != NULL ){
mac->cg = scell_group_config;
mac->servCellIndex = *scell_group_config->spCellConfig->servCellIndex;
mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0;
mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0;
config_control_ue(mac);
if (scell_group_config->spCellConfig->reconfigurationWithSync) {
if (scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
ra->rach_ConfigDedicated = scell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated->choice.uplink;
......@@ -650,35 +677,30 @@ int nr_rrc_mac_config_req_ue(
mac->crnti = scell_group_config->spCellConfig->reconfigurationWithSync->newUE_Identity;
LOG_I(MAC,"Configuring CRNTI %x\n",mac->crnti);
}
configure_current_BWP(mac, NULL, scell_group_config);
config_control_ue(mac);
// Setup the SSB to Rach Occasions mapping according to the config
build_ssb_to_ro_map(mac);
}
else if (cell_group_config != NULL ){
LOG_I(MAC,"Applying CellGroupConfig from gNodeB\n");
mac->cg = cell_group_config;
if (cell_group_config->spCellConfig) {
if (cell_group_config->spCellConfig)
mac->servCellIndex = cell_group_config->spCellConfig->servCellIndex ? *cell_group_config->spCellConfig->servCellIndex : 0;
mac->DL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->firstActiveDownlinkBWP_Id : 0;
mac->UL_BWP_Id=mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id ? *mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->firstActiveUplinkBWP_Id : 0;
}
else {
else
mac->servCellIndex = 0;
mac->DL_BWP_Id = 0;
mac->UL_BWP_Id = 0;
}
mac->scheduling_info.periodicBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->scheduling_info.retxBSR_SF =
MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->scheduling_info.periodicBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->scheduling_info.retxBSR_SF = MAC_UE_BSR_TIMER_NOT_RUNNING;
mac->BSR_reporting_active = NR_BSR_TRIGGER_NONE;
LOG_D(MAC, "[UE %d]: periodic BSR %d (SF), retx BSR %d (SF)\n",
module_id,
mac->scheduling_info.periodicBSR_SF,
mac->scheduling_info.retxBSR_SF);
configure_current_BWP(mac, NULL, cell_group_config);
config_control_ue(mac);
if (get_softmodem_params()->nsa) {
if (cell_group_config->spCellConfig && cell_group_config->spCellConfig->reconfigurationWithSync) {
if (cell_group_config->spCellConfig->reconfigurationWithSync->rach_ConfigDedicated) {
......@@ -698,72 +720,6 @@ int nr_rrc_mac_config_req_ue(
// Setup the SSB to Rach Occasions mapping according to the config
build_ssb_to_ro_map(mac);
}
/*
if(mac_cell_group_configP != NULL){
if(mac_cell_group_configP->drx_Config != NULL ){
switch(mac_cell_group_configP->drx_Config->present){
case NR_SetupRelease_DRX_Config_PR_NOTHING:
break;
case NR_SetupRelease_DRX_Config_PR_release:
mac->drx_Config = NULL;
break;
case NR_SetupRelease_DRX_Config_PR_setup:
mac->drx_Config = mac_cell_group_configP->drx_Config->choice.setup;
break;
default:
break;
}
}
if(mac_cell_group_configP->schedulingRequestConfig != NULL ){
mac->schedulingRequestConfig = mac_cell_group_configP->schedulingRequestConfig;
}
if(mac_cell_group_configP->bsr_Config != NULL ){
mac->bsr_Config = mac_cell_group_configP->bsr_Config;
}
if(mac_cell_group_configP->tag_Config != NULL ){
mac->tag_Config = mac_cell_group_configP->tag_Config;
}
if(mac_cell_group_configP->phr_Config != NULL ){
switch(mac_cell_group_configP->phr_Config->present){
case NR_SetupRelease_PHR_Config_PR_NOTHING:
break;
case NR_SetupRelease_PHR_Config_PR_release:
mac->phr_Config = NULL;
break;
case NR_SetupRelease_PHR_Config_PR_setup:
mac->phr_Config = mac_cell_group_configP->phr_Config->choice.setup;
break;
default:
break;
}
}
}
if(phy_cell_group_configP != NULL ){
if(phy_cell_group_configP->cs_RNTI != NULL ){
switch(phy_cell_group_configP->cs_RNTI->present){
case NR_SetupRelease_RNTI_Value_PR_NOTHING:
break;
case NR_SetupRelease_RNTI_Value_PR_release:
mac->cs_RNTI = NULL;
break;
case NR_SetupRelease_RNTI_Value_PR_setup:
mac->cs_RNTI = &phy_cell_group_configP->cs_RNTI->choice.setup;
break;
default:
break;
}
}
}
*/
}
return 0;
}
......@@ -372,6 +372,23 @@ typedef struct {
} NR_PHY_meas_t;
typedef struct NR_DL_BWP {
NR_BWP_Id_t bwp_id;
NR_BWP_t genericParameters;
int scs;
long *cyclicprefix;
uint16_t BWPSize;
uint16_t BWPStart;
} NR_DL_BWP_t;
typedef struct NR_UL_BWP {
NR_BWP_Id_t bwp_id;
NR_BWP_t genericParameters;
int scs;
long *cyclicprefix;
uint16_t BWPSize;
uint16_t BWPStart;
} NR_UL_BWP_t;
/*!\brief Top level UE MAC structure */
typedef struct {
......@@ -393,6 +410,9 @@ typedef struct {
NR_RNTI_Value_t *cs_RNTI;
NR_MIB_t *mib;
NR_DL_BWP_t current_DL_BWP;
NR_UL_BWP_t current_UL_BWP;
NR_BWP_Downlink_t *DLbwp[MAX_NUM_BWP_UE];
NR_BWP_Uplink_t *ULbwp[MAX_NUM_BWP_UE];
NR_ControlResourceSet_t *coreset[MAX_NUM_BWP_UE][FAPI_NR_MAX_CORESET_PER_BWP];
......@@ -400,12 +420,6 @@ typedef struct {
frame_type_t frame_type;
/*BWP*/
// dedicated active DL BWP
NR_BWP_Id_t DL_BWP_Id;
// dedicated active UL BWP
NR_BWP_Id_t UL_BWP_Id;
/// Type0-PDCCH seach space
fapi_nr_dl_config_dci_dl_pdu_rel15_t type0_pdcch_dci_config;
uint32_t type0_pdcch_ss_mux_pattern;
......
......@@ -451,8 +451,6 @@ void fill_dci_search_candidates(NR_SearchSpace_t *ss,fapi_nr_dl_config_dci_dl_pd
void build_ssb_to_ro_map(NR_UE_MAC_INST_t *mac);
void config_bwp_ue(NR_UE_MAC_INST_t *mac, uint32_t *bwp_ind, uint8_t *dci_format);
void configure_ss_coreset(NR_UE_MAC_INST_t *mac,
NR_ServingCellConfig_t *scd,
NR_BWP_Id_t dl_bwp_id);
......
......@@ -177,11 +177,11 @@ void init_RA(module_id_t mod_id,
}
}
if (ss_id < 0) {
if (mac->DL_BWP_Id>0) {
ra_ss = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace;
if (mac->current_DL_BWP.bwp_id>0) {
ra_ss = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace;
if (ra_ss) {
commonSearchSpaceList = mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList;
ss_id = *mac->DLbwp[mac->DL_BWP_Id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace;
commonSearchSpaceList = mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->commonSearchSpaceList;
ss_id = *mac->DLbwp[mac->current_DL_BWP.bwp_id-1]->bwp_Common->pdcch_ConfigCommon->choice.setup->ra_SearchSpace;
}
}
}
......
......@@ -94,10 +94,10 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
AssertFatal(mac->scc == NULL || mac->scc_SIB == NULL, "both scc and scc_SIB cannot be non-null\n");
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id;
NR_ServingCellConfigCommon_t *scc = mac->scc;
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;
......@@ -105,7 +105,6 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
initialDownlinkBWP = scc!=NULL ? scc->downlinkConfigCommon->initialDownlinkBWP : &scc_SIB->downlinkConfigCommon.initialDownlinkBWP;
initialUplinkBWP = scc!=NULL ? scc->uplinkConfigCommon->initialUplinkBWP : &scc_SIB->uplinkConfigCommon->initialUplinkBWP;
}
bwp_Common = dl_bwp_id>0 ? mac->DLbwp[dl_bwp_id-1]->bwp_Common : NULL;
NR_SearchSpace_t *ss;
NR_ControlResourceSet_t *coreset;
......@@ -167,28 +166,20 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
switch(rnti_type) {
case NR_RNTI_C:
// we use DL BWP dedicated
sps = bwp_Common ?
(bwp_Common->genericParameters.cyclicPrefix ? 12 : 14) :
initialDownlinkBWP->genericParameters.cyclicPrefix ? 12 : 14;
sps = current_DL_BWP->cyclicprefix ? 12 : 14;
// 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;
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;
}
rel15->BWPSize = current_DL_BWP->BWPSize;
rel15->BWPStart = current_DL_BWP->BWPStart;
rel15->SubcarrierSpacing = current_DL_BWP->scs;
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_C, rel15->BWPSize, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs);
}
break;
case NR_RNTI_RA:
// we use the initial DL BWP
sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12;
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rel15->rnti = mac->ra.ra_rnti;
if (get_softmodem_params()->sa) {
......@@ -196,9 +187,9 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb;
} else { // NSA mode is not using the Initial BWP
rel15->BWPSize = NRRIV2BW(initialDownlinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
rel15->BWPStart = NRRIV2PRBOFFSET(bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
rel15->BWPStart = current_DL_BWP->BWPStart;
}
rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
rel15->SubcarrierSpacing = current_DL_BWP->scs;
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, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs);
break;
case NR_RNTI_P:
......@@ -207,12 +198,12 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
break;
case NR_RNTI_TC:
// we use the initial DL BWP
sps = initialDownlinkBWP->genericParameters.cyclicPrefix == NULL ? 14 : 12;
sps = current_DL_BWP->cyclicprefix == NULL ? 14 : 12;
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
rel15->rnti = mac->ra.t_crnti;
rel15->BWPSize = mac->type0_PDCCH_CSS_config.num_rbs;
rel15->BWPStart = mac->type0_PDCCH_CSS_config.cset_start_rb;
rel15->SubcarrierSpacing = initialDownlinkBWP->genericParameters.subcarrierSpacing;
rel15->SubcarrierSpacing = current_DL_BWP->scs;
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, dl_bwp_id, coreset_id, mac->type0_PDCCH_CSS_config.num_rbs);
}
......@@ -220,9 +211,7 @@ void config_dci_pdu(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_dci_dl_pdu_rel15_t
case NR_RNTI_SP_CSI:
break;
case NR_RNTI_SI:
// we use DL BWP dedicated
if (bwp_Common) sps = bwp_Common->genericParameters.cyclicPrefix == NULL ? 14 : 12;
else sps=14; // note: normally this would be found with SSS detection
sps=14;
// for SPS=14 8 MSBs in positions 13 down to 6
monitoringSymbolsWithinSlot = (ss->monitoringSymbolsWithinSlot->buf[0]<<(sps-8)) | (ss->monitoringSymbolsWithinSlot->buf[1]>>(16-sps));
......@@ -280,7 +269,7 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
RA_config_t *ra = &mac->ra;
int ss_id;
uint8_t bwp_id = (mac->cg) ? mac->DL_BWP_Id : 0;
uint8_t bwp_id = mac->current_DL_BWP.bwp_id;
//NR_ServingCellConfig_t *scd = mac->scg->spCellConfig->spCellConfigDedicated;
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;
......@@ -431,7 +420,6 @@ void ue_dci_configuration(NR_UE_MAC_INST_t *mac, fapi_nr_dl_config_request_t *dl
} // for ss_id
}
else {
AssertFatal(1==0,"Handle DCI searching when CellGroup without dedicated BWP\n");
}
}
......@@ -310,10 +310,10 @@ int8_t nr_ue_decode_mib(module_id_t module_id,
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
mac->physCellId = cell_id;
nr_mac_rrc_data_ind_ue( module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3 ); // fixed 3 bytes MIB PDU
nr_mac_rrc_data_ind_ue(module_id, cc_id, gNB_index, 0, 0, 0, NR_BCCH_BCH, (uint8_t *) pduP, 3); // fixed 3 bytes MIB PDU
AssertFatal(mac->mib != NULL, "nr_ue_decode_mib() mac->mib == NULL\n");
//if(mac->mib != NULL){
uint16_t frame = (mac->mib->systemFrameNumber.buf[0] >> mac->mib->systemFrameNumber.bits_unused);
uint16_t frame_number_4lsb = 0;
......@@ -649,17 +649,13 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
RA_config_t *ra = &mac->ra;
fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
uint8_t is_Msg3 = 0;
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id;
NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id;
int default_abc = 1;
uint16_t n_RB_DLBWP;
if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) n_RB_DLBWP = NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
else if (mac->scc) n_RB_DLBWP = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
else if (mac->scc_SIB) n_RB_DLBWP = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
else n_RB_DLBWP = mac->type0_PDCCH_CSS_config.num_rbs;
LOG_D(MAC, "In %s: Processing received DCI format %s (DL BWP %d)\n", __FUNCTION__, dci_formats[dci_format], n_RB_DLBWP);
LOG_D(MAC, "In %s: Processing received DCI format %s\n", __FUNCTION__, dci_formats[dci_format]);
switch(dci_format){
case NR_UL_DCI_FORMAT_0_0: {
......@@ -1067,8 +1063,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
dci->pucch_resource_indicator,
1+dci->pdsch_to_harq_feedback_timing_indicator.val);
// dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
LOG_D(MAC,"(nr_ue_procedures.c) pdu_type=%d\n\n",dl_config->dl_config_list[dl_config->number_pdus].pdu_type);
dl_config->number_pdus = dl_config->number_pdus + 1;
......@@ -1111,9 +1105,8 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
LOG_W(NR_MAC,"[%d.%d] bwp_indicator %d > NR_MAX_NUM_BWP Possibly due to false DCI. Ignoring DCI!\n", frame, slot,dci->bwp_indicator.val);
return -1;
}
config_bwp_ue(mac, &dci->bwp_indicator.val, &dci_format);
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id;
NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id;
NR_PDSCH_Config_t *pdsch_Config=NULL;
NR_BWP_DownlinkDedicated_t *bwpd=NULL;
NR_BWP_DownlinkCommon_t *bwpc=NULL;
......@@ -1127,16 +1120,16 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
fapi_nr_dl_config_dlsch_pdu_rel15_t *dlsch_config_pdu_1_1 = &dl_config->dl_config_list[dl_config->number_pdus].dlsch_config_pdu.dlsch_config_rel15;
dlsch_config_pdu_1_1->BWPSize = NRRIV2BW(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
dlsch_config_pdu_1_1->BWPStart = NRRIV2PRBOFFSET(bwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
dlsch_config_pdu_1_1->SubcarrierSpacing = bwpc->genericParameters.subcarrierSpacing;
dlsch_config_pdu_1_1->BWPSize = current_DL_BWP->BWPSize;
dlsch_config_pdu_1_1->BWPStart = current_DL_BWP->BWPStart;
dlsch_config_pdu_1_1->SubcarrierSpacing = current_DL_BWP->scs;
/* IDENTIFIER_DCI_FORMATS */
/* CARRIER_IND */
/* BANDWIDTH_PART_IND */
// dlsch_config_pdu_1_1->bandwidth_part_ind = dci->bandwidth_part_ind;
/* FREQ_DOM_RESOURCE_ASSIGNMENT_DL */
if (nr_ue_process_dci_freq_dom_resource_assignment(NULL,dlsch_config_pdu_1_1,0,n_RB_DLBWP,dci->frequency_domain_assignment.val) < 0) {
if (nr_ue_process_dci_freq_dom_resource_assignment(NULL, dlsch_config_pdu_1_1, 0, current_DL_BWP->BWPSize, dci->frequency_domain_assignment.val) < 0) {
LOG_W(MAC, "[%d.%d] Invalid frequency_domain_assignment. Possibly due to false DCI. Ignoring DCI!\n", frame, slot);
return -1;
}
......@@ -1357,8 +1350,6 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
/* DMRS_SEQ_INI */
//FIXME!!!
// dl_config->dl_config_list[dl_config->number_pdus].dci_config_pdu.dci_config_rel15.N_RB_BWP = n_RB_DLBWP;
/* PDSCH_TO_HARQ_FEEDBACK_TIME_IND */
// according to TS 38.213 Table 9.2.3-1
uint8_t feedback_ti =
......@@ -1406,9 +1397,7 @@ int8_t nr_ue_process_dci(module_id_t module_id, int cc_id, uint8_t gNB_index, fr
long *maxMIMO_Layers = mac->cg->spCellConfig->spCellConfigDedicated->pdsch_ServingCellConfig->choice.setup->ext1->maxMIMO_Layers;
AssertFatal (maxMIMO_Layers != NULL,"Option with max MIMO layers not configured is not supported\n");
int nl_tbslbrm = *maxMIMO_Layers < 4 ? *maxMIMO_Layers : 4;
NR_BWP_t genericParameters = mac->scc ? mac->scc->downlinkConfigCommon->initialDownlinkBWP->genericParameters :
mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
int BWPSize = NRRIV2BW(genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
int BWPSize = current_DL_BWP->BWPSize;
int bw_tbslbrm = get_dlbw_tbslbrm(BWPSize, mac->cg);
dlsch_config_pdu_1_1->tbslbrm = nr_compute_tbslbrm(dlsch_config_pdu_1_1->mcs_table,
bw_tbslbrm,
......@@ -1527,23 +1516,12 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
int O_CRC = 0; //FIXME
uint16_t O_uci = O_CSI + O_ACK;
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id;
NR_PUCCH_FormatConfig_t *pucchfmt;
long *pusch_id = NULL;
long *id0 = NULL;
int scs;
NR_BWP_UplinkCommon_t *initialUplinkBWP;
if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP;
else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP;
if (mac->cg && bwp_id > 1 && mac->ULbwp[bwp_id - 1] &&
mac->cg->spCellConfig &&
mac->cg->spCellConfig->spCellConfigDedicated &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) {
scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing;
}
else
scs = initialUplinkBWP->genericParameters.subcarrierSpacing;
const int scs = current_UL_BWP->scs;
int subframe_number = slot / (nr_slots_per_frame[scs]/10);
nb_pucch_format_4_in_subframes[subframe_number] = 0;
......@@ -1560,10 +1538,8 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
pucch_pdu->start_symbol_index = initial_pucch_resource[pucch->initial_pucch_id].startingSymbolIndex;
pucch_pdu->nr_of_symbols = initial_pucch_resource[pucch->initial_pucch_id].nrofSymbols;
pucch_pdu->bwp_size = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,
MAX_BWP_SIZE);
pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,
MAX_BWP_SIZE);
pucch_pdu->bwp_size = current_UL_BWP->BWPSize;
pucch_pdu->bwp_start = current_UL_BWP->BWPStart;
pucch_pdu->prb_size = 1; // format 0 or 1
int RB_BWP_offset;
......@@ -1626,8 +1602,6 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
id0 = pusch_Config->dmrs_UplinkForPUSCH_MappingTypeB->choice.setup->transformPrecodingDisabled->scramblingID0;
else *id0 = mac->physCellId;
pucch_Config = mac->ULbwp[bwp_id-1]->bwp_Dedicated->pucch_Config->choice.setup;
pucch_pdu->bwp_size = NRRIV2BW(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->ULbwp[bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
}
else if (bwp_id==0 &&
mac->cg &&
......@@ -1638,12 +1612,11 @@ void nr_ue_configure_pucch(NR_UE_MAC_INST_t *mac,
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup) {
pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup;
pucch_pdu->bwp_size = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
pucch_pdu->bwp_start = NRRIV2PRBOFFSET(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth,MAX_BWP_SIZE);
}
else AssertFatal(1==0,"no pucch_Config\n");
pucch_pdu->bwp_size = current_UL_BWP->BWPSize;
pucch_pdu->bwp_start = current_UL_BWP->BWPStart;
pucch_pdu->prb_start = pucchres->startingPRB;
pucch_pdu->freq_hop_flag = pucchres->intraSlotFrequencyHopping!= NULL ? 1 : 0;
pucch_pdu->second_hop_prb = pucchres->secondHopPRB!= NULL ? *pucchres->secondHopPRB : 0;
......@@ -1955,7 +1928,7 @@ int get_deltatf(uint16_t nb_of_prbs,
int find_pucch_resource_set(NR_UE_MAC_INST_t *mac, int uci_size) {
int pucch_resource_set_id = 0;
NR_BWP_Id_t bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t bwp_id = mac->current_DL_BWP.bwp_id;
//long *pucch_max_pl_bits = NULL;
......@@ -2027,7 +2000,7 @@ void select_pucch_resource(NR_UE_MAC_INST_t *mac,
PUCCH_sched_t *pucch) {
NR_PUCCH_ResourceId_t *current_resource_id = NULL;
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id;
int n_list;
if (pucch->is_common == 1 ||
......@@ -2151,10 +2124,12 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac,
int V_DAI_m_DL = 0;
NR_UE_HARQ_STATUS_t *current_harq;
int sched_frame,sched_slot;
int slots_per_frame,scs;
int slots_per_frame;
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id;
NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id;
NR_BWP_DownlinkDedicated_t *bwpd=NULL;
NR_BWP_DownlinkCommon_t *bwpc=NULL;
NR_BWP_UplinkDedicated_t *ubwpd=NULL;
......@@ -2170,7 +2145,7 @@ uint8_t get_downlink_ack(NR_UE_MAC_INST_t *mac,
number_of_code_word = 2;
}
scs = ubwpc->genericParameters.subcarrierSpacing;
int scs = current_UL_BWP->scs;
slots_per_frame = nr_slots_per_frame[scs];
......@@ -2350,24 +2325,11 @@ bool trigger_periodic_scheduling_request(NR_UE_MAC_INST_t *mac,
frame_t frame,
int slot) {
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id;
NR_PUCCH_Config_t *pucch_Config = NULL;
int scs;
NR_BWP_UplinkCommon_t *initialUplinkBWP;
if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP;
else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP;
if (mac->cg && bwp_id && mac->ULbwp[bwp_id - 1] &&
mac->cg->spCellConfig &&
mac->cg->spCellConfig->spCellConfigDedicated &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP) {
scs = mac->ULbwp[bwp_id - 1]->bwp_Common->genericParameters.subcarrierSpacing;
}
else
scs = initialUplinkBWP->genericParameters.subcarrierSpacing;
const int n_slots_frame = nr_slots_per_frame[scs];
const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs];
if (bwp_id>0 &&
mac->ULbwp[bwp_id-1] &&
......@@ -2476,7 +2438,8 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac,
int slot,
PUCCH_sched_t *pucch) {
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t bwp_id = current_UL_BWP->bwp_id;
NR_PUCCH_Config_t *pucch_Config = NULL;
int csi_bits = 0;
......@@ -2499,19 +2462,6 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac,
int period, offset;
csi_period_offset(csirep, NULL, &period, &offset);
int scs;
NR_BWP_Uplink_t *ubwp = mac->ULbwp[bwp_id-1];
NR_BWP_UplinkCommon_t *initialUplinkBWP;
if (mac->scc) initialUplinkBWP = mac->scc->uplinkConfigCommon->initialUplinkBWP;
else initialUplinkBWP = &mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP;
if (ubwp &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig &&
mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP)
scs = ubwp->bwp_Common->genericParameters.subcarrierSpacing;
else
scs = initialUplinkBWP->genericParameters.subcarrierSpacing;
if (bwp_id>0 &&
mac->ULbwp[bwp_id-1] &&
mac->ULbwp[bwp_id-1]->bwp_Dedicated &&
......@@ -2527,7 +2477,7 @@ uint8_t nr_get_csi_measurements(NR_UE_MAC_INST_t *mac,
pucch_Config = mac->cg->spCellConfig->spCellConfigDedicated->uplinkConfig->initialUplinkBWP->pucch_Config->choice.setup;
}
const int n_slots_frame = nr_slots_per_frame[scs];
const int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs];
if (((n_slots_frame*frame + slot - offset)%period) == 0 && pucch_Config) {
LOG_D(NR_MAC, "Preparing CSI report in frame %d slot %d CSI report ID %d\n", frame, slot, csi_report_id);
NR_PUCCH_CSI_Resource_t *pucchcsires = csirep->reportConfigType.choice.periodic->pucch_CSI_ResourceList.list.array[0];
......@@ -2859,7 +2809,7 @@ void nr_ue_send_sdu(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_t *u
int get_n_rb(NR_UE_MAC_INST_t *mac, int rnti_type){
int N_RB = 0, start_RB;
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id;
switch(rnti_type) {
case NR_RNTI_RA:
case NR_RNTI_TC:
......@@ -2896,17 +2846,10 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
int fsize = 0;
int rnti_type = get_rnti_type(mac, rnti);
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id ;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id ;
int N_RB_UL = 0;
if(ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) {
N_RB_UL = NRRIV2BW(mac->ULbwp[ul_bwp_id - 1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
} else if(mac->scc) {
N_RB_UL = NRRIV2BW(mac->scc->uplinkConfigCommon->initialUplinkBWP->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
} else if(mac->scc_SIB) {
N_RB_UL = NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
}
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id;
int N_RB_UL = current_UL_BWP->BWPSize;
LOG_D(MAC,"nr_extract_dci_info : dci_pdu %lx, size %d\n",*dci_pdu,dci_size);
switch(dci_format) {
......@@ -2968,10 +2911,7 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
LOG_D(MAC,"Format indicator %d (%d bits) N_RB_BWP %d => %d (0x%lx)\n",dci_pdu_rel15->format_indicator,1,N_RB,dci_size-pos,*dci_pdu);
#endif
// check BWP id
if (dl_bwp_id>0 && mac->DLbwp[dl_bwp_id-1]) N_RB=NRRIV2BW(mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
else N_RB=NRRIV2BW(mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
N_RB = current_DL_BWP->BWPSize;
// Freq domain assignment (275rb >> fsize = 16)
fsize = (int)ceil( log2( (N_RB*(N_RB+1))>>1 ) );
pos+=fsize;
......@@ -3234,9 +3174,6 @@ static uint8_t nr_extract_dci_info(NR_UE_MAC_INST_t *mac,
break;
case NR_UL_DCI_FORMAT_0_0:
if (mac->ULbwp[ul_bwp_id-1]) N_RB_UL=NRRIV2BW(mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
else N_RB_UL=NRRIV2BW(mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
switch(rnti_type)
{
case NR_RNTI_C:
......
......@@ -107,7 +107,7 @@ void fill_scheduled_response(nr_scheduled_response_t *scheduled_response,
long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) {
long k2 = -1;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id;
// Get K2 from RRC configuration
NR_PUSCH_Config_t *pusch_config= ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ? mac->ULbwp[ul_bwp_id-1]->bwp_Dedicated->pusch_Config->choice.setup : NULL;
NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = NULL;
......@@ -149,7 +149,7 @@ long get_k2(NR_UE_MAC_INST_t *mac, uint8_t time_domain_ind) {
*/
fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int slot)
{
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_TDD_UL_DL_ConfigCommon_t *tdd_config = mac->scc==NULL ? mac->scc_SIB->tdd_UL_DL_ConfigurationCommon : mac->scc->tdd_UL_DL_ConfigurationCommon;
//Check if request to access ul_config is for a UL slot
......@@ -161,9 +161,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl
// Calculate the index of the UL slot in mac->ul_config_request list. This is
// based on the TDD pattern (slot configuration period) and number of UL+mixed
// slots in the period. TS 38.213 Sec 11.1
int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ?
mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing :
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing;
int mu = mac->current_UL_BWP.scs;
const int n = nr_slots_per_frame[mu];
const int num_slots_per_tdd = tdd_config ? (n >> (7 - tdd_config->pattern1.dl_UL_TransmissionPeriodicity)) : n;
const int num_slots_ul = tdd_config ? (tdd_config->pattern1.nrofUplinkSlots + (tdd_config->pattern1.nrofUplinkSymbols != 0)) : n;
......@@ -184,7 +182,7 @@ fapi_nr_ul_config_request_t *get_ul_config_request(NR_UE_MAC_INST_t *mac, int sl
void ul_layers_config(NR_UE_MAC_INST_t * mac, nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, dci_pdu_rel15_t *dci) {
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id;
NR_BWP_UplinkDedicated_t *ubwpd=NULL;
NR_SRS_Config_t *srs_config = NULL;
......@@ -342,7 +340,7 @@ void ul_ports_config(NR_UE_MAC_INST_t *mac, int *n_front_load_symb, nfapi_nr_ue_
uint8_t rank = pusch_config_pdu->nrOfLayers;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id;
NR_ServingCellConfigCommon_t *scc = mac->scc;
NR_BWP_UplinkDedicated_t *ubwpd=NULL;
......@@ -555,7 +553,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
int N_PRB_oh = 0;
int rnti_type = get_rnti_type(mac, rnti);
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id;
// Common configuration
pusch_config_pdu->dmrs_config_type = pusch_dmrs_type1;
......@@ -675,8 +674,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
pusch_config_pdu->tbslbrm = 0;
} else if (dci) {
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t dl_bwp_id = mac->current_DL_BWP.bwp_id;
NR_BWP_Id_t ul_bwp_id = mac->current_UL_BWP.bwp_id;
NR_BWP_DownlinkDedicated_t *bwpd=NULL;
NR_BWP_DownlinkCommon_t *bwpc=NULL;
NR_BWP_UplinkDedicated_t *ubwpd=NULL;
......@@ -686,9 +685,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
int target_ss;
bool valid_ptrs_setup = 0;
uint16_t n_RB_ULBWP = NRRIV2BW(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
pusch_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwpc->genericParameters.locationAndBandwidth, MAX_BWP_SIZE);
pusch_config_pdu->bwp_size = n_RB_ULBWP;
pusch_config_pdu->bwp_start = current_UL_BWP->BWPStart;
pusch_config_pdu->bwp_size = current_UL_BWP->BWPSize;
const NR_PUSCH_Config_t *pusch_Config = ubwpd? ubwpd->pusch_Config->choice.setup : NULL;
......@@ -710,8 +708,6 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
} else if (*dci_format == NR_UL_DCI_FORMAT_0_1) {
config_bwp_ue(mac, &dci->bwp_indicator.val, dci_format);
get_bwp_info(mac,dl_bwp_id,ul_bwp_id,&bwpd,&bwpc,&ubwpd,&ubwpc);
target_ss = NR_SearchSpace__searchSpaceType_PR_ue_Specific;
......@@ -780,7 +776,7 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
/* IDENTIFIER_DCI_FORMATS */
/* FREQ_DOM_RESOURCE_ASSIGNMENT_UL */
if (nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, n_RB_ULBWP, 0, dci->frequency_domain_assignment.val) < 0){
if (nr_ue_process_dci_freq_dom_resource_assignment(pusch_config_pdu, NULL, current_UL_BWP->BWPSize, 0, dci->frequency_domain_assignment.val) < 0){
return -1;
}
/* TIME_DOM_RESOURCE_ASSIGNMENT */
......@@ -953,7 +949,8 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo
bool srs_scheduled = false;
NR_UE_MAC_INST_t *mac = get_mac_inst(mod_id);
const NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id;
NR_SRS_Config_t *srs_config = NULL;
if (ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1]) {
......@@ -997,14 +994,10 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo
continue;
}
NR_BWP_t ubwp = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ?
mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters :
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters;
uint16_t period = srs_period[srs_resource->resourceType.choice.periodic->periodicityAndOffset_p.present];
uint16_t offset = get_nr_srs_offset(srs_resource->resourceType.choice.periodic->periodicityAndOffset_p);
int n_slots_frame = nr_slots_per_frame[ubwp.subcarrierSpacing];
int n_slots_frame = nr_slots_per_frame[current_UL_BWP->scs];
// Check if UE should transmit the SRS
if((frame*n_slots_frame+slot-offset)%period == 0) {
......@@ -1014,9 +1007,9 @@ bool nr_ue_periodic_srs_scheduling(module_id_t mod_id, frame_t frame, slot_t slo
srs_config_pdu->rnti = mac->crnti;
srs_config_pdu->handle = 0;
srs_config_pdu->bwp_size = NRRIV2BW(ubwp.locationAndBandwidth, MAX_BWP_SIZE);;
srs_config_pdu->bwp_start = NRRIV2PRBOFFSET(ubwp.locationAndBandwidth, MAX_BWP_SIZE);;
srs_config_pdu->subcarrier_spacing = ubwp.subcarrierSpacing;
srs_config_pdu->bwp_size = current_UL_BWP->BWPSize;
srs_config_pdu->bwp_start = current_UL_BWP->BWPStart;
srs_config_pdu->subcarrier_spacing = current_UL_BWP->scs;
srs_config_pdu->cyclic_prefix = 0;
srs_config_pdu->num_ant_ports = srs_resource->nrofSRS_Ports;
srs_config_pdu->num_symbols = srs_resource->resourceMapping.nrofSymbols;
......@@ -1588,12 +1581,11 @@ int nr_ue_pusch_scheduler(NR_UE_MAC_INST_t *mac,
uint8_t tda_id){
int delta = 0;
NR_BWP_Id_t ul_bwp_id = mac->UL_BWP_Id;
NR_UL_BWP_t *current_UL_BWP = &mac->current_UL_BWP;
NR_BWP_Id_t ul_bwp_id = current_UL_BWP->bwp_id;
// Get the numerology to calculate the Tx frame and slot
int mu = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ?
mac->ULbwp[ul_bwp_id-1]->bwp_Common->genericParameters.subcarrierSpacing :
mac->scc_SIB->uplinkConfigCommon->initialUplinkBWP.genericParameters.subcarrierSpacing;
int mu = current_UL_BWP->scs;
NR_PUSCH_TimeDomainResourceAllocationList_t *pusch_TimeDomainAllocationList = ul_bwp_id > 0 && mac->ULbwp[ul_bwp_id-1] ?
mac->ULbwp[ul_bwp_id-1]->bwp_Common->pusch_ConfigCommon->choice.setup->pusch_TimeDomainAllocationList:
......@@ -2338,7 +2330,7 @@ void nr_ue_pucch_scheduler(module_id_t module_idP, frame_t frameP, int slotP, vo
// ACKNACK
O_ACK = get_downlink_ack(mac, frameP, slotP, &pucch);
NR_BWP_Id_t bwp_id = mac->UL_BWP_Id;
NR_BWP_Id_t bwp_id = mac->current_UL_BWP.bwp_id;
NR_PUCCH_Config_t *pucch_Config = NULL;
if (bwp_id>0 &&
......@@ -2426,18 +2418,11 @@ void nr_schedule_csi_for_im(NR_UE_MAC_INST_t *mac, int frame, int slot) {
fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
NR_CSI_IM_Resource_t *imcsi;
int period, offset;
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_t *genericParameters = NULL;
if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) {
genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters;
} else {
genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
}
int mu = genericParameters->subcarrierSpacing;
uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
int mu = current_DL_BWP->scs;
uint16_t bwp_size = current_DL_BWP->BWPSize;
uint16_t bwp_start = current_DL_BWP->BWPStart;
for (int id = 0; id < csi_measconfig->csi_IM_ResourceToAddModList->list.count; id++){
imcsi = csi_measconfig->csi_IM_ResourceToAddModList->list.array[id];
......@@ -2491,18 +2476,12 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) {
fapi_nr_dl_config_request_t *dl_config = &mac->dl_config_request;
NR_NZP_CSI_RS_Resource_t *nzpcsi;
int period, offset;
NR_BWP_Id_t dl_bwp_id = mac->DL_BWP_Id;
NR_BWP_t *genericParameters = NULL;
if(dl_bwp_id > 0 && mac->DLbwp[dl_bwp_id-1]) {
genericParameters = &mac->DLbwp[dl_bwp_id-1]->bwp_Common->genericParameters;
} else {
genericParameters = &mac->scc_SIB->downlinkConfigCommon.initialDownlinkBWP.genericParameters;
}
NR_DL_BWP_t *current_DL_BWP = &mac->current_DL_BWP;
NR_BWP_Id_t dl_bwp_id = current_DL_BWP->bwp_id;
int mu = genericParameters->subcarrierSpacing;
uint16_t bwp_size = NRRIV2BW(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
uint16_t bwp_start = NRRIV2PRBOFFSET(genericParameters->locationAndBandwidth, MAX_BWP_SIZE);
int mu = current_DL_BWP->scs;
uint16_t bwp_size = current_DL_BWP->BWPSize;
uint16_t bwp_start = current_DL_BWP->BWPStart;
// looking for the correct CSI-RS resource in current BWP
NR_NZP_CSI_RS_ResourceSetId_t *nzp = NULL;
......@@ -2530,7 +2509,7 @@ void nr_schedule_csirs_reception(NR_UE_MAC_INST_t *mac, int frame, int slot) {
fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_config_pdu = &dl_config->dl_config_list[dl_config->number_pdus].csirs_config_pdu.csirs_config_rel15;
NR_CSI_RS_ResourceMapping_t resourceMapping = nzpcsi->resourceMapping;
csirs_config_pdu->subcarrier_spacing = mu;
csirs_config_pdu->cyclic_prefix = genericParameters->cyclicPrefix ? *genericParameters->cyclicPrefix : 0;
csirs_config_pdu->cyclic_prefix = current_DL_BWP->cyclicprefix ? *current_DL_BWP->cyclicprefix : 0;
// According to last paragraph of TS 38.214 5.2.2.3.1
if (resourceMapping.freqBand.startingRB < bwp_start) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment