Avoid use of FAPI message buffers in msgDataTx

Note: after this commit, monolithic works but nFAPI operation is broken
and fixed in the next commit, to keep the changes small(er). All
simulators work.

This commit removes the use of msgDataTx's intermediate buffers for FAPI
messages and the call of the "Schedule response". The latter incurs an
additional copy of FAPI messages for the TX chain (for the RX chain, it
is and will remain there) which we can avoid.

Instead, it uses an NR_Sched_Rsp_t-typed variable sched_response to
store the results of the scheduler when called from tx_func(). Thus, the
scheduler remains unchanged (it gets a pointer to where to put FAPI
messages), but we don't call nr_schedule_response() to then copy FAPI
messages into the L1, but have them in a local variable sched_response.
sched_response on on the data segment, as it is big and would overflow
the stack; at the same time, this is ok because only one tx_func() runs
at a time.

Since we don't use allocate_sched_response() anymore, we don't need
deref_sched_response().

clear_slot_beamid() is moved to tx_func(), as it was called in
nr_schedule_response().

Since the "intermediate" NR_gNB_DLSCH_t structure groups both the
DL_tti_pdsch and TX_data.req structures, a pointer has been created to
point to pdsch_pdu. This affects a number of simulators, as they have to
put some messages on the stack:

- nr_dlschsim: put the corresponding variable on the stack
- nr_pbchsim: a new array for the SSB PDUs has been introduced

Further, these changes are now necessary:

- nr_dlsim:  there were variables "rel15" and "pdsch_pdu_rel15" that
  point to the same PDSCH PDU. At least "rel15" would not exist, as the
  corresponding pointer is now populated in phy_procedures_gNB_TX(), and
  we therefore refer to the single PDSCH PDU variable with
  "pdsch_pdu_rel15", but at the place where "rel15" used to be
  initialized.
- nr_ulsim: use nr_save_ul_tti_req() to load PDUs into the RX chain
  instead of nr_schedule_response(), which does not exist anymore.
This commit is contained in:
Robert Schmidt
2025-11-14 18:16:00 +01:00
parent e17c165c9d
commit 2bea71a80a
15 changed files with 206 additions and 195 deletions
+2 -2
View File
@@ -555,7 +555,7 @@ static int do_one_dlsch(unsigned char *input_ptr, PHY_VARS_gNB *gNB, NR_gNB_DLSC
time_stats_t *dlsch_scrambling_stats = &gNB->dlsch_scrambling_stats;
time_stats_t *dlsch_modulation_stats = &gNB->dlsch_modulation_stats;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu.pdsch_pdu_rel15;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu->pdsch_pdu_rel15;
const int layerSz = frame_parms->N_RB_DL * NR_SYMBOLS_PER_SLOT * NR_NB_SC_PER_RB;
const int symbol_sz=frame_parms->ofdm_symbol_size;
const int dmrs_Type = rel15->dmrsConfigType;
@@ -789,7 +789,7 @@ void nr_generate_pdsch(PHY_VARS_gNB *gNB, int n_dlsch, NR_gNB_DLSCH_t *dlsch_arr
for (int i = 0; i < n_dlsch; i++) {
NR_gNB_DLSCH_t *dlsch = &dlsch_array[i];
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu.pdsch_pdu_rel15;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu->pdsch_pdu_rel15;
LOG_D(PHY,
"pdsch: BWPStart %d, BWPSize %d, rbStart %d, rbsize %d\n",
+2 -2
View File
@@ -138,7 +138,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
NR_gNB_DLSCH_t *dlsch = &dlsch_array[i];
unsigned int crc = 1;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu.pdsch_pdu_rel15;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu->pdsch_pdu_rel15;
uint32_t A = rel15->TBSize[0] << 3;
unsigned char *a = dlsch->pdu;
if (rel15->rnti != SI_RNTI) {
@@ -224,7 +224,7 @@ int nr_dlsch_encoding(PHY_VARS_gNB *gNB,
for (int i = 0; i < n_dlsch; i++) {
NR_gNB_DLSCH_t *dlsch = &dlsch_array[i];
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu.pdsch_pdu_rel15;
const nfapi_nr_dl_tti_pdsch_pdu_rel15_t *rel15 = &dlsch->pdsch_pdu->pdsch_pdu_rel15;
nrLDPC_TB_encoding_parameters_t *TB_parameters = &TBs[i];
+1 -1
View File
@@ -54,7 +54,7 @@ void nr_fill_dlsch_tx_req(processingData_L1tx_t *msgTx, int idx, uint8_t *sdu)
/* not sure if FAPI could transmit DL_TTI_req and TX_req in different orders.
* for the moment, assume they are in the same order (and check!) */
NR_gNB_DLSCH_t *dlsch = &msgTx->gNB->dlsch[idx];
nfapi_nr_dl_tti_pdsch_pdu *pdsch = &dlsch->pdsch_pdu;
const nfapi_nr_dl_tti_pdsch_pdu *pdsch = dlsch->pdsch_pdu;
AssertFatal(pdsch->pdsch_pdu_rel15.pduIndex == idx, "PDSCH PDU index %d does not match %d\n", pdsch->pdsch_pdu_rel15.pduIndex, idx);
dlsch->pdu = sdu;
}
+1 -1
View File
@@ -98,7 +98,7 @@ typedef struct {
typedef struct {
/// Nfapi DLSCH PDU
nfapi_nr_dl_tti_pdsch_pdu pdsch_pdu;
const nfapi_nr_dl_tti_pdsch_pdu *pdsch_pdu;
/// pointer to pdu from MAC interface (this is "a" in 36.212)
uint8_t *pdu;
/// Pointer to the payload