Commit 5ea88ec9 authored by cig's avatar cig

Broken down get_band into two functions to get duplex offset and frame type

- the band is coming from the SI, therefore a function to get the band is not
  necessary
- this solves also the limitations of the get_band algorithm with the NR bands
  overlapping in the NR operating bands table (e.g. band 78 and band 48)
parent 80747394
...@@ -432,7 +432,6 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { ...@@ -432,7 +432,6 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms; NR_DL_FRAME_PARMS *fp = &RC.gNB[Mod_id]->frame_parms;
nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config; nfapi_nr_config_request_scf_t *gNB_config = &RC.gNB[Mod_id]->gNB_config;
int32_t dlul_offset = 0; int32_t dlul_offset = 0;
lte_frame_type_t frame_type = 0;
memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg)); memcpy((void*)gNB_config,phy_config->cfg,sizeof(*phy_config->cfg));
RC.gNB[Mod_id]->mac_enabled = 1; RC.gNB[Mod_id]->mac_enabled = 1;
...@@ -443,10 +442,15 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) { ...@@ -443,10 +442,15 @@ void nr_phy_config_request(NR_PHY_Config_t *phy_config) {
uint64_t ul_bw_khz = (12*gNB_config->carrier_config.ul_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<<gNB_config->ssb_config.scs_common.value); uint64_t ul_bw_khz = (12*gNB_config->carrier_config.ul_grid_size[gNB_config->ssb_config.scs_common.value].value)*(15<<gNB_config->ssb_config.scs_common.value);
fp->ul_CarrierFreq = ((ul_bw_khz>>1) + gNB_config->carrier_config.uplink_frequency.value)*1000 ; fp->ul_CarrierFreq = ((ul_bw_khz>>1) + gNB_config->carrier_config.uplink_frequency.value)*1000 ;
get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &dlul_offset, &frame_type); fp->nr_band = *RC.nrmac[Mod_id]->common_channels[0].ServingCellConfigCommon->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0];
get_delta_duplex(fp->nr_band, gNB_config->ssb_config.scs_common.value, &dlul_offset);
dlul_offset *= 1000;
AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + dlul_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + dlul_offset); AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + dlul_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + dlul_offset);
LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, dlul_offset);
fp->threequarter_fs = openair0_cfg[0].threequarter_fs; fp->threequarter_fs = openair0_cfg[0].threequarter_fs;
LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n", LOG_I(PHY,"Configuring MIB for instance %d, : (Nid_cell %d,DL freq %llu, UL freq %llu)\n",
Mod_id, Mod_id,
......
...@@ -330,10 +330,14 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp, ...@@ -330,10 +330,14 @@ int nr_init_frame_parms_ue(NR_DL_FRAME_PARMS *fp,
fp->N_RB_DL = config->carrier_config.dl_grid_size[fp->numerology_index]; fp->N_RB_DL = config->carrier_config.dl_grid_size[fp->numerology_index];
int32_t uplink_frequency_offset = 0; int32_t uplink_frequency_offset = 0;
get_delta_duplex(fp->nr_band, fp->numerology_index, &uplink_frequency_offset);
get_frame_type(fp->nr_band, fp->numerology_index, &fp->frame_type);
uplink_frequency_offset *= 1000;
get_band(fp->dl_CarrierFreq, fp->ul_CarrierFreq, &fp->nr_band, &uplink_frequency_offset, &fp->frame_type); LOG_I(PHY, "DL frequency %lu Hz, UL frequency %lu Hz: band %d, uldl offset %d Hz\n", fp->dl_CarrierFreq, fp->ul_CarrierFreq, fp->nr_band, uplink_frequency_offset);
AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band); AssertFatal(fp->frame_type==config->cell_config.frame_duplex_type, "Invalid duplex type in config request file for band %d\n", fp->nr_band);
AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + uplink_frequency_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + uplink_frequency_offset); AssertFatal(fp->ul_CarrierFreq == (fp->dl_CarrierFreq + uplink_frequency_offset), "Disagreement in uplink frequency for band %d: ul_CarrierFreq = %lu Hz vs expected %lu Hz\n", fp->nr_band, fp->ul_CarrierFreq, fp->dl_CarrierFreq + uplink_frequency_offset);
#if DISABLE_LOG_X #if DISABLE_LOG_X
......
...@@ -1473,8 +1473,8 @@ nr_bandentry_t nr_bandtable[] = { ...@@ -1473,8 +1473,8 @@ nr_bandentry_t nr_bandtable[] = {
{41, 2496000, 2690000, 2496000, 2690000, 3, 499200, 15}, {41, 2496000, 2690000, 2496000, 2690000, 3, 499200, 15},
{41, 2496000, 2690000, 2496000, 2690000, 6, 499200, 30}, {41, 2496000, 2690000, 2496000, 2690000, 6, 499200, 30},
{47, 5855000, 5925000, 5855000, 5925000, 1, 790334, 15}, {47, 5855000, 5925000, 5855000, 5925000, 1, 790334, 15},
{48, 3550000, 3700000, 3550000, 3700000, 1, 636667, 15}, //{48, 3550000, 3700000, 3550000, 3700000, 1, 636667, 15},
{48, 3550000, 3700000, 3550000, 3700000, 2, 636668, 30}, //{48, 3550000, 3700000, 3550000, 3700000, 2, 636668, 30},
{50, 1432000, 1517000, 1432000, 1517000, 20, 286400, 100}, {50, 1432000, 1517000, 1432000, 1517000, 20, 286400, 100},
{51, 1427000, 1432000, 1427000, 1432000, 20, 285400, 100}, {51, 1427000, 1432000, 1427000, 1432000, 20, 285400, 100},
{53, 2483500, 2495000, 2483500, 2495000, 20, 496700, 100}, {53, 2483500, 2495000, 2483500, 2495000, 20, 496700, 100},
...@@ -1559,29 +1559,19 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = { ...@@ -1559,29 +1559,19 @@ int32_t table_6_4_1_1_3_4_pusch_dmrs_positions_l [12][8] = {
#define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t)) #define NR_BANDTABLE_SIZE (sizeof(nr_bandtable)/sizeof(nr_bandentry_t))
// Computes the duplex spacing (either positive or negative) in KHz // Returns the corresponding row index of the NR table
void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex){ int get_nr_table_idx(int nr_bandP, uint8_t scs_index){
int i, j;
int scs_khz = 15 << scs_index;
int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95}; int supplementary_bands[] = {29,75,76,80,81,82,83,84,86,89,95};
size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]); size_t s = sizeof(supplementary_bands)/sizeof(supplementary_bands[0]);
for(int i = 0; i < s; i++){ for(j = 0; j < s; j++){
if (nr_table_idx == supplementary_bands[i]) if (nr_bandP == supplementary_bands[j])
AssertFatal(0 == 1, "Band %d is a supplementary band. This is not supported yet.\n", nr_table_idx); AssertFatal(0 == 1, "Band %d is a supplementary band (%d). This is not supported yet.\n", nr_bandP, supplementary_bands[j]);
} }
*delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min);
LOG_D(PHY, "NR band duplex spacing %d KHz (nr_bandtable[%d].band = %d)\n", *delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band);
}
// Returns the corresponding row index of the NR table
int get_nr_table_idx(int nr_bandP, uint8_t scs_index){
int scs_khz = 15 << scs_index;
int i;
AssertFatal(nr_bandP <= nr_bandtable[NR_BANDTABLE_SIZE-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[NR_BANDTABLE_SIZE-1].band); AssertFatal(nr_bandP <= nr_bandtable[NR_BANDTABLE_SIZE-1].band, "NR band %d exceeds NR bands table maximum limit %d\n", nr_bandP, nr_bandtable[NR_BANDTABLE_SIZE-1].band);
for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++); for (i = 0; i < NR_BANDTABLE_SIZE && nr_bandtable[i].band != nr_bandP; i++);
...@@ -1589,52 +1579,37 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index){ ...@@ -1589,52 +1579,37 @@ int get_nr_table_idx(int nr_bandP, uint8_t scs_index){
if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz)) if ((nr_bandtable[i].deltaf_raster != 100) && (nr_bandtable[i].deltaf_raster != scs_khz))
i++; i++;
LOG_D(PHY, "NR band table index %d (Band %d)\n", i, nr_bandtable[i].band); LOG_D(PHY, "NR band table index %d (Band %d, dl_min %lu, ul_min %lu)\n", i, nr_bandtable[i].band, nr_bandtable[i].dl_min,nr_bandtable[i].ul_min);
return i; return i;
} }
void get_band(uint64_t downlink_frequency, // Computes the duplex spacing (either positive or negative) in KHz
uint64_t ul_frequency, void get_delta_duplex(int nr_bandP, uint8_t scs_index, int32_t *delta_duplex){
uint16_t *current_band,
int32_t *current_offset, int nr_table_idx = get_nr_table_idx(nr_bandP, scs_index);
lte_frame_type_t *current_type)
{ *delta_duplex = (nr_bandtable[nr_table_idx].ul_min - nr_bandtable[nr_table_idx].dl_min);
int ind;
uint64_t center_frequency_khz; LOG_D(PHY, "NR band duplex spacing is %d KHz (nr_bandtable[%d].band = %d)\n", *delta_duplex, nr_table_idx, nr_bandtable[nr_table_idx].band);
uint64_t center_freq_diff_khz;
uint64_t dl_freq_khz = downlink_frequency/1000; }
uint64_t ul_freq_khz = ul_frequency/1000;
void get_frame_type(uint16_t current_band,
center_freq_diff_khz = 999999999999999999; // 2^64 uint8_t scs_index,
*current_band = 0; lte_frame_type_t *current_type){
for ( ind=0; int32_t current_offset;
ind < sizeof(nr_bandtable) / sizeof(nr_bandtable[0]); get_delta_duplex(current_band, scs_index, &current_offset);
ind++) {
current_offset *= 1000;
LOG_I(PHY, "Scanning band %d, dl_min %"PRIu64", ul_min %"PRIu64"\n", nr_bandtable[ind].band, nr_bandtable[ind].dl_min,nr_bandtable[ind].ul_min); if (current_offset == 0)
if (nr_bandtable[ind].dl_min <= dl_freq_khz && nr_bandtable[ind].dl_max >= dl_freq_khz && nr_bandtable[ind].ul_min <= ul_freq_khz && nr_bandtable[ind].ul_max >= ul_freq_khz) {
center_frequency_khz = (nr_bandtable[ind].dl_max + nr_bandtable[ind].dl_min)/2;
if (abs(dl_freq_khz - center_frequency_khz) < center_freq_diff_khz){
*current_band = nr_bandtable[ind].band;
get_delta_duplex(ind, current_offset);
*current_offset *= 1000;
center_freq_diff_khz = abs(dl_freq_khz - center_frequency_khz);
if (*current_offset == 0)
*current_type = TDD; *current_type = TDD;
else else
*current_type = FDD; *current_type = FDD;
}
}
}
LOG_I(PHY, "DL frequency %"PRIu64" Hz, UL frequency %"PRIu64" Hz: band %d, uldl offset %d Hz, duplex mode %s\n", downlink_frequency, ul_frequency, *current_band, *current_offset, duplex_mode[*current_type]);
AssertFatal(*current_band != 0, "Can't find NR band for frequency %lu\n", downlink_frequency); LOG_I(MAC, "NR band %d, duplex mode %s, duplex spacing = %d KHz\n", current_band, duplex_mode[*current_type], current_offset);
} }
...@@ -1806,7 +1781,7 @@ uint64_t from_nrarfcn(int nr_bandP, ...@@ -1806,7 +1781,7 @@ uint64_t from_nrarfcn(int nr_bandP,
if (nrarfcn > 2016666 && nrarfcn < 3279166) if (nrarfcn > 2016666 && nrarfcn < 3279166)
deltaFglobal = 60; deltaFglobal = 60;
get_delta_duplex(i, &delta_duplex); get_delta_duplex(nr_bandP, scs_index, &delta_duplex);
if (delta_duplex <= 0){ // DL band >= UL band if (delta_duplex <= 0){ // DL band >= UL band
if (nrarfcn >= nr_bandtable[i].N_OFFs_DL){ // is TDD of FDD DL if (nrarfcn >= nr_bandtable[i].N_OFFs_DL){ // is TDD of FDD DL
......
...@@ -66,9 +66,9 @@ typedef enum { ...@@ -66,9 +66,9 @@ typedef enum {
uint16_t config_bandwidth(int mu, int nb_rb, int nr_band); uint16_t config_bandwidth(int mu, int nb_rb, int nr_band);
void get_band(uint64_t dl_frequency, uint64_t ul_frequency, uint16_t *current_band, int32_t *current_offset, lte_frame_type_t *current_type); void get_frame_type(uint16_t nr_bandP, uint8_t scs_index, lte_frame_type_t *current_type);
void get_delta_duplex(int nr_table_idx, int32_t *delta_duplex); void get_delta_duplex(int nr_bandP, uint8_t scs_index, int32_t *delta_duplex);
uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn); uint64_t from_nrarfcn(int nr_bandP, uint8_t scs_index, uint32_t dl_nrarfcn);
......
...@@ -147,6 +147,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, ...@@ -147,6 +147,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req;
NR_ServingCellConfigCommon_t *scc = mac->scc; NR_ServingCellConfigCommon_t *scc = mac->scc;
int i; int i;
lte_frame_type_t frame_type;
mac->phy_config.Mod_id = module_id; mac->phy_config.Mod_id = module_id;
mac->phy_config.CC_id = cc_idP; mac->phy_config.CC_id = cc_idP;
...@@ -200,16 +201,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac, ...@@ -200,16 +201,7 @@ void config_common_ue(NR_UE_MAC_INST_t *mac,
} }
} }
lte_frame_type_t frame_type; get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing, &frame_type);
uint16_t band;
int32_t offset;
get_band((cfg->carrier_config.dl_frequency)*1000,
(cfg->carrier_config.uplink_frequency)*1000,
&band,
&offset,
&frame_type);
// cell config // cell config
......
...@@ -125,15 +125,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm ...@@ -125,15 +125,7 @@ void config_common(int Mod_idP, int pdsch_AntennaPorts, NR_ServingCellConfigComm
} }
lte_frame_type_t frame_type; lte_frame_type_t frame_type;
uint16_t band; get_frame_type(*scc->downlinkConfigCommon->frequencyInfoDL->frequencyBandList.list.array[0], *scc->ssbSubcarrierSpacing, &frame_type);
int32_t offset;
get_band((cfg->carrier_config.dl_frequency.value)*1000,
(cfg->carrier_config.uplink_frequency.value)*1000,
&band,
&offset,
&frame_type);
RC.nrmac[Mod_idP]->common_channels[0].frame_type = frame_type; RC.nrmac[Mod_idP]->common_channels[0].frame_type = frame_type;
// Cell configuration // Cell configuration
......
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