Commit f0533b9e authored by Robert Schmidt's avatar Robert Schmidt

Move TBS calculation out of nr_fill_nfapi_dl_pdu

parent 71bfadf1
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
/*PHY*/ /*PHY*/
#include "PHY/CODING/coding_defs.h" #include "PHY/CODING/coding_defs.h"
#include "PHY/defs_nr_common.h" #include "PHY/defs_nr_common.h"
#include "common/utils/nr/nr_common.h"
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h" #include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
/*MAC*/ /*MAC*/
#include "NR_MAC_COMMON/nr_mac.h" #include "NR_MAC_COMMON/nr_mac.h"
...@@ -452,19 +453,68 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -452,19 +453,68 @@ void nr_schedule_ue_spec(module_id_t module_id,
const uint8_t numDmrsCdmGrpsNoData = 1; const uint8_t numDmrsCdmGrpsNoData = 1;
const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1; const nfapi_nr_dmrs_type_e dmrsConfigType = bwp->bwp_Dedicated->pdsch_Config->choice.setup->dmrs_DownlinkForPDSCH_MappingTypeA->choice.setup->dmrs_Type == NULL ? 0 : 1;
const int TBS_bytes = nr_fill_nfapi_dl_pdu(module_id, const int time_domain_assignment = 2;
UE_id, AssertFatal(time_domain_assignment<bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count);
bwp_id, const int startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength;
dl_req, int startSymbolIndex, nrOfSymbols;
pucch, SLIV2SL(startSymbolAndLength, &startSymbolIndex, &nrOfSymbols);
nrOfLayers,
mcs, const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP
bwpSize, uint8_t N_PRB_DMRS;
0 /* bwpStart */, if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) {
numDmrsCdmGrpsNoData, // if no data in dmrs cdm group is 1 only even REs have no data
dmrsConfigType); // if no data in dmrs cdm group is 2 both odd and even REs have no data
N_PRB_DMRS = numDmrsCdmGrpsNoData * 6;
if (TBS_bytes == 0) } else {
N_PRB_DMRS = numDmrsCdmGrpsNoData * 4;
}
const uint8_t N_sh_symb = nrOfSymbols;
const uint16_t rbSize = bwpSize;
const uint8_t table_idx = 0;
const uint16_t R = nr_get_code_rate_dl(mcs, table_idx);
const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx);
const uint32_t TBS =
nr_compute_tbs(Qm,
R,
rbSize,
N_sh_symb,
N_PRB_DMRS, // FIXME // This should be multiplied by the
// number of dmrs symbols
N_PRB_oh,
0 /* tb_scaling */,
nrOfLayers)
>> 3;
LOG_D(MAC,
"TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table %d",
TBS,
N_PRB_DMRS,
N_sh_symb,
N_PRB_oh,
R,
Qm,
table_idx);
nr_fill_nfapi_dl_pdu(module_id,
UE_id,
bwp_id,
dl_req,
pucch,
nrOfLayers,
mcs,
rbSize,
0 /* bwpStart */,
numDmrsCdmGrpsNoData,
dmrsConfigType,
table_idx,
R,
Qm,
TBS,
time_domain_assignment,
startSymbolIndex,
nrOfSymbols);
if (TBS == 0)
return; return;
const int lcid = DL_SCH_LCID_DTCH; const int lcid = DL_SCH_LCID_DTCH;
...@@ -473,7 +523,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -473,7 +523,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
int sdu_length_total = 0; int sdu_length_total = 0;
int num_sdus = 0; int num_sdus = 0;
LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n", LOG_D(MAC, "[gNB %d], Frame %d, DTCH%d->DLSCH, Checking RLC status (TBS %d bytes, len %d)\n",
module_id, frame, lcid, TBS_bytes, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3); module_id, frame, lcid, TBS, TBS - ta_len - header_length_total - sdu_length_total - 3);
const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id, const mac_rlc_status_resp_t rlc_status = mac_rlc_status_ind(module_id,
rnti, rnti,
...@@ -490,9 +540,9 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -490,9 +540,9 @@ void nr_schedule_ue_spec(module_id_t module_id,
LOG_I(MAC, "configure fapi due to data availability \n"); LOG_I(MAC, "configure fapi due to data availability \n");
LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS_bytes: %d \n \n", LOG_I(MAC, "[gNB %d][USER-PLANE DEFAULT DRB] Frame %d : DTCH->DLSCH, Requesting %d bytes from RLC (lcid %d total hdr len %d), TBS: %d \n \n",
module_id, frame, TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, module_id, frame, TBS - ta_len - header_length_total - sdu_length_total - 3,
lcid, header_length_total, TBS_bytes); lcid, header_length_total, TBS);
sdu_lengths[num_sdus] = mac_rlc_data_req(module_id, sdu_lengths[num_sdus] = mac_rlc_data_req(module_id,
rnti, rnti,
...@@ -501,7 +551,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -501,7 +551,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
ENB_FLAG_YES, ENB_FLAG_YES,
MBMS_FLAG_NO, MBMS_FLAG_NO,
lcid, lcid,
TBS_bytes - ta_len - header_length_total - sdu_length_total - 3, TBS - ta_len - header_length_total - sdu_length_total - 3,
(char *)&mac_sdus[sdu_length_total], (char *)&mac_sdus[sdu_length_total],
0, 0,
0); 0);
...@@ -520,10 +570,10 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -520,10 +570,10 @@ void nr_schedule_ue_spec(module_id_t module_id,
else { else {
LOG_I(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot); LOG_I(MAC, "Configuring DL_TX in %d.%d: random data\n", frame, slot);
// fill dlsch_buffer with random data // fill dlsch_buffer with random data
for (int i = 0; i < TBS_bytes; i++) for (int i = 0; i < TBS; i++)
mac_sdus[i] = (unsigned char) (lrand48()&0xff); mac_sdus[i] = (unsigned char) (lrand48()&0xff);
sdu_lcids[0] = 0x3f; // DRB sdu_lcids[0] = 0x3f; // DRB
sdu_lengths[0] = TBS_bytes - ta_len - 3; sdu_lengths[0] = TBS - ta_len - 3;
header_length_total += 2 + (sdu_lengths[0] >= 128); header_length_total += 2 + (sdu_lengths[0] >= 128);
sdu_length_total += sdu_lengths[0]; sdu_length_total += sdu_lengths[0];
num_sdus +=1; num_sdus +=1;
...@@ -537,9 +587,9 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -537,9 +587,9 @@ void nr_schedule_ue_spec(module_id_t module_id,
} }
// Check if there is data from RLC or CE // Check if there is data from RLC or CE
const int post_padding = TBS_bytes >= 2 + header_length_total + sdu_length_total + ta_len; const int post_padding = TBS >= 2 + header_length_total + sdu_length_total + ta_len;
// padding param currently not in use // padding param currently not in use
//padding = TBS_bytes - header_length_total - sdu_length_total - ta_len - 1; //padding = TBS - header_length_total - sdu_length_total - ta_len - 1;
const int offset = nr_generate_dlsch_pdu( const int offset = nr_generate_dlsch_pdu(
module_id, module_id,
...@@ -554,7 +604,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -554,7 +604,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
// Padding: fill remainder of DLSCH with 0 // Padding: fill remainder of DLSCH with 0
if (post_padding > 0) { if (post_padding > 0) {
for (int j = 0; j < TBS_bytes - offset; j++) for (int j = 0; j < TBS - offset; j++)
gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0; gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0][offset + j] = 0;
} }
...@@ -563,7 +613,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -563,7 +613,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
slot, slot,
dl_req, dl_req,
tx_req, tx_req,
TBS_bytes, TBS,
gNB_mac->pdu_index[CC_id]); gNB_mac->pdu_index[CC_id]);
#if defined(ENABLE_MAC_PAYLOAD_DEBUG) #if defined(ENABLE_MAC_PAYLOAD_DEBUG)
...@@ -572,7 +622,7 @@ void nr_schedule_ue_spec(module_id_t module_id, ...@@ -572,7 +622,7 @@ void nr_schedule_ue_spec(module_id_t module_id,
"%d.%d, first 10 payload bytes, TBS size: %d \n", "%d.%d, first 10 payload bytes, TBS size: %d \n",
frame, frame,
slot, slot,
TBS_bytes); TBS);
for(int i = 0; i < 10; i++) { for(int i = 0; i < 10; i++) {
LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]); LOG_I(MAC, "byte %d : %x\n", i,((uint8_t *)gNB_mac->UE_list.DLSCH_pdu[0][0].payload[0])[i]);
} }
......
...@@ -407,17 +407,24 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu, ...@@ -407,17 +407,24 @@ void nr_configure_css_dci_initial(nfapi_nr_dl_tti_pdcch_pdu_rel15_t* pdcch_pdu,
} }
int nr_fill_nfapi_dl_pdu(int Mod_idP, void nr_fill_nfapi_dl_pdu(int Mod_idP,
int UE_id, int UE_id,
int bwp_id, int bwp_id,
nfapi_nr_dl_tti_request_body_t *dl_req, nfapi_nr_dl_tti_request_body_t *dl_req,
NR_sched_pucch *pucch_sched, NR_sched_pucch *pucch_sched,
int nrOfLayers, int nrOfLayers,
uint8_t mcs, uint8_t mcs,
uint16_t rbSize, uint16_t rbSize,
uint16_t rbStart, uint16_t rbStart,
uint8_t numDmrsCdmGrpsNoData, uint8_t numDmrsCdmGrpsNoData,
nfapi_nr_dmrs_type_e dmrsConfigType) { nfapi_nr_dmrs_type_e dmrsConfigType,
uint8_t table_idx,
uint16_t R,
uint8_t Qm,
uint32_t TBS,
int time_domain_assignment,
int StartSymbolIndex,
int NrOfSymbols) {
gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP]; gNB_MAC_INST *nr_mac = RC.nrmac[Mod_idP];
NR_COMMON_channels_t *cc = nr_mac->common_channels; NR_COMMON_channels_t *cc = nr_mac->common_channels;
NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon; NR_ServingCellConfigCommon_t *scc = cc->ServingCellConfigCommon;
...@@ -485,14 +492,10 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, ...@@ -485,14 +492,10 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP,
pdsch_pdu_rel15->rbStart = rbStart; pdsch_pdu_rel15->rbStart = rbStart;
pdsch_pdu_rel15->rbSize = rbSize; pdsch_pdu_rel15->rbSize = rbSize;
pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP pdsch_pdu_rel15->VRBtoPRBMapping = 1; // non-interleaved, check if this is ok for initialBWP
pdsch_pdu_rel15->targetCodeRate[0] = R;
int startSymbolAndLength=0; pdsch_pdu_rel15->qamModOrder[0] = Qm;
int time_domain_assignment=2; pdsch_pdu_rel15->TBSize[0] = TBS;
int StartSymbolIndex,NrOfSymbols; pdsch_pdu_rel15->mcsTable[0] = table_idx;
AssertFatal(time_domain_assignment<bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count,"time_domain_assignment %d>=%d\n",time_domain_assignment,bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.count);
startSymbolAndLength = bwp->bwp_Common->pdsch_ConfigCommon->choice.setup->pdsch_TimeDomainAllocationList->list.array[time_domain_assignment]->startSymbolAndLength;
SLIV2SL(startSymbolAndLength,&StartSymbolIndex,&NrOfSymbols);
pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex; pdsch_pdu_rel15->StartSymbolIndex = StartSymbolIndex;
pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols; pdsch_pdu_rel15->NrOfSymbols = NrOfSymbols;
...@@ -613,76 +616,31 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP, ...@@ -613,76 +616,31 @@ int nr_fill_nfapi_dl_pdu(int Mod_idP,
pdcch_pdu_rel15->StartSymbolIndex, pdcch_pdu_rel15->StartSymbolIndex,
pdcch_pdu_rel15->DurationSymbols); pdcch_pdu_rel15->DurationSymbols);
const uint16_t N_PRB_oh = 0; // overhead should be 0 for initialBWP
uint8_t N_PRB_DMRS;
if (dmrsConfigType == NFAPI_NR_DMRS_TYPE1) {
// if no data in dmrs cdm group is 1 only even REs have no data
// if no data in dmrs cdm group is 2 both odd and even REs have no data
N_PRB_DMRS = numDmrsCdmGrpsNoData * 6;
} else {
N_PRB_DMRS = numDmrsCdmGrpsNoData * 4;
}
const uint8_t N_sh_symb = NrOfSymbols;
const uint8_t table_idx = 0;
const uint16_t R = nr_get_code_rate_dl(mcs, table_idx);
const uint8_t Qm = nr_get_Qm_dl(mcs, table_idx);
const uint32_t TBS =
nr_compute_tbs(Qm,
R,
rbSize,
N_sh_symb,
N_PRB_DMRS, // FIXME // This should be multiplied by the
// number of dmrs symbols
N_PRB_oh,
0 /* tb_scaling */,
nrOfLayers)
>> 3;
pdsch_pdu_rel15->targetCodeRate[0] = R;
pdsch_pdu_rel15->qamModOrder[0] = Qm;
pdsch_pdu_rel15->TBSize[0] = TBS;
// I don't know why the following is not needed, but in this case we don't // I don't know why the following is not needed, but in this case we don't
// need additional calculations: // need additional calculations:
const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh; //const uint16_t N_RE_prime = NR_NB_SC_PER_RB * N_sh_symb - N_PRB_DMRS - N_PRB_oh;
LOG_D(MAC, //LOG_D(MAC,
"N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n", // "N_RE_prime %d for %d symbols %d DMRS per PRB and %d overhead\n",
N_RE_prime, // N_RE_prime,
N_sh_symb, // N_sh_symb,
N_PRB_DMRS, // N_PRB_DMRS,
N_PRB_oh); // N_PRB_oh);
//pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords; //pdsch_pdu_rel15->nb_mod_symbols = N_RE_prime*pdsch_pdu_rel15->n_prb*pdsch_pdu_rel15->nb_codewords;
pdsch_pdu_rel15->mcsTable[0] = table_idx;
LOG_D(MAC,
"TBS %d bytes: N_PRB_DMRS %d N_sh_symb %d N_PRB_oh %d R %d Qm %d table "
"%d nb_symbols %d\n",
TBS,
N_PRB_DMRS,
N_sh_symb,
N_PRB_oh,
R,
Qm,
table_idx,
N_RE_prime * pdsch_pdu_rel15->rbSize * pdsch_pdu_rel15->NrOfCodewords);
if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0) if (UE_list->UE_sched_ctrl[UE_id].harq_processes[current_harq_pid].round==0)
UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS; UE_list->mac_stats[UE_id].dlsch_total_bytes += TBS;
LOG_D(MAC, LOG_D(MAC,
"DLSCH PDU: start PRB %d n_PRB %d startSymbolAndLength %d start symbol " "DLSCH PDU: start PRB %d n_PRB %d start symbol %d nb_symbols %d "
"%d nb_symbols %d nb_layers %d nb_codewords %d mcs %d TBS: %d\n", "nb_layers %d nb_codewords %d mcs %d TBS: %d\n",
pdsch_pdu_rel15->rbStart, pdsch_pdu_rel15->rbStart,
pdsch_pdu_rel15->rbSize, pdsch_pdu_rel15->rbSize,
startSymbolAndLength,
pdsch_pdu_rel15->StartSymbolIndex, pdsch_pdu_rel15->StartSymbolIndex,
pdsch_pdu_rel15->NrOfSymbols, pdsch_pdu_rel15->NrOfSymbols,
pdsch_pdu_rel15->nrOfLayers, pdsch_pdu_rel15->nrOfLayers,
pdsch_pdu_rel15->NrOfCodewords, pdsch_pdu_rel15->NrOfCodewords,
pdsch_pdu_rel15->mcsIndex[0], pdsch_pdu_rel15->mcsIndex[0],
TBS); TBS);
return TBS; //Return TBS in bytes
} }
int nr_configure_pdcch(gNB_MAC_INST *nr_mac, int nr_configure_pdcch(gNB_MAC_INST *nr_mac,
......
...@@ -129,17 +129,24 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP, ...@@ -129,17 +129,24 @@ void nr_schedule_css_dlsch_phytest(module_id_t module_idP,
frame_t frameP, frame_t frameP,
sub_frame_t subframeP); sub_frame_t subframeP);
int nr_fill_nfapi_dl_pdu(int Mod_id, void nr_fill_nfapi_dl_pdu(int Mod_id,
int UE_id, int UE_id,
int bwp_id, int bwp_id,
nfapi_nr_dl_tti_request_body_t *dl_req, nfapi_nr_dl_tti_request_body_t *dl_req,
NR_sched_pucch *pucch_sched, NR_sched_pucch *pucch_sched,
int nrOfLayers, int nrOfLayers,
uint8_t mcs, uint8_t mcs,
uint16_t rbSize, uint16_t rbSize,
uint16_t rbStart, uint16_t rbStart,
uint8_t numDmrsCdmGrpsNoData, uint8_t numDmrsCdmGrpsNoData,
nfapi_nr_dmrs_type_e dmrsConfigType); nfapi_nr_dmrs_type_e dmrsConfigType,
uint8_t table_idx,
uint16_t R,
uint8_t Qm,
uint32_t tbs,
int time_domain_assignment,
int StartSymbolIndex,
int NrOfSymbols);
int configure_fapi_dl_pdu_phytest(int Mod_id, int configure_fapi_dl_pdu_phytest(int Mod_id,
nfapi_nr_dl_tti_request_body_t *dl_req, nfapi_nr_dl_tti_request_body_t *dl_req,
......
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