Commit 77525618 authored by francescomani's avatar francescomani Committed by Laurent THOMAS

MR2496 fapi new data indicator as bool and storage of previous NDI value to HARQ structures

parent d32bb894
......@@ -239,9 +239,9 @@ typedef struct {
typedef struct
{
uint8_t rv_index;
uint8_t harq_process_id;
uint8_t new_data_indicator;
uint8_t rv_index;
uint8_t harq_process_id;
bool new_data_indicator;
uint32_t tb_size;
uint16_t num_cb;
uint8_t cb_present_and_position[(NFAPI_UE_MAX_NUM_CB+7) / 8];
......@@ -455,13 +455,13 @@ typedef struct {
uint8_t rate_matching_ind;
uint8_t zp_csi_rs_trigger;
uint8_t mcs;
uint8_t ndi;
bool new_data_indicator;
uint8_t rv;
uint16_t targetCodeRate;
uint8_t qamModOrder;
uint32_t TBS;
uint8_t tb2_mcs;
uint8_t tb2_ndi;
bool tb2_new_data_indicator;
uint8_t tb2_rv;
uint8_t harq_process_nbr;
vrb_to_prb_mapping_t vrb_to_prb_mapping;
......
......@@ -104,8 +104,6 @@ typedef struct {
typedef struct {
/// Indicator of first reception
uint8_t first_rx;
/// Last Ndi received for this process on DCI (used for C-RNTI only)
uint8_t Ndi;
/// DLSCH status flag indicating
SCH_status_t status;
/// Transport block size
......
......@@ -304,14 +304,14 @@ static void configure_dlsch(NR_UE_DLSCH_t *dlsch0,
if ((dlsch_config_pdu->dmrs_ports>>i)&0x01) Nl += 1;
}
dlsch0->Nl = Nl;
if (dlsch_config_pdu->ndi) {
if (dlsch_config_pdu->new_data_indicator) {
dlsch0_harq->first_rx = true;
dlsch0_harq->DLround = 0;
} else {
dlsch0_harq->first_rx = false;
dlsch0_harq->DLround++;
}
downlink_harq_process(dlsch0_harq, current_harq_pid, dlsch_config_pdu->ndi, dlsch_config_pdu->rv, dlsch0->rnti_type);
downlink_harq_process(dlsch0_harq, current_harq_pid, dlsch_config_pdu->new_data_indicator, dlsch_config_pdu->rv, dlsch0->rnti_type);
if (dlsch0_harq->status != ACTIVE) {
// dlsch0_harq->status not ACTIVE due to false retransmission
// Reset the following flag to skip PDSCH procedures in that case and retrasmit harq status
......
......@@ -115,7 +115,6 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq)
dl_harq->status = SCH_IDLE;
dl_harq->first_rx = 1;
dl_harq->DLround = 0;
dl_harq->Ndi = 2; // set to an invalid value
dl_harq->ack = DL_ACKNACK_NO_SET;
}
......@@ -152,31 +151,9 @@ void downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int dci_ndi,
rv,
dci_ndi,
rnti_type,
dl_harq->Ndi != dci_ndi ? "yes" : "no");
dci_ndi ? "yes" : "no");
AssertFatal(rv<4 && rv>=0, "invalid redondancy version %d\n", rv);
if (dci_ndi!=dl_harq->Ndi) {
if (dl_harq->ack == DL_NACK)
LOG_D(PHY,"New transmission on a harq pid (%d) never acknowledged\n", harq_pid);
else
LOG_D(PHY,"Starting new transmission on a harq pid (%d)\n", harq_pid);
} else {
if (dl_harq->ack != DL_NACK)
LOG_D(PHY,"gNB asked for retransmission even if we sent ACK\n");
else
LOG_D(PHY,"Starting retransmission on a harq pid (%d), rv (%d)\n", harq_pid, rv);
}
if (dci_ndi!=dl_harq->Ndi) {
dl_harq->first_rx = true;
dl_harq->DLround = 0;
} else {
dl_harq->first_rx = false;
dl_harq->DLround++;
}
dl_harq->status = ACTIVE;
dl_harq->Ndi = dci_ndi;
}
}
......@@ -347,11 +347,13 @@ typedef struct {
int8_t delta_pucch;
uint32_t R;
uint32_t TBS;
int last_ndi;
} NR_UE_HARQ_STATUS_t;
typedef struct {
uint32_t R;
uint32_t TBS;
int last_ndi;
} NR_UL_HARQ_INFO_t;
typedef struct {
......@@ -503,9 +505,6 @@ typedef struct NR_UE_MAC_INST_s {
/// measurements from CSI-RS
fapi_nr_csirs_measurements_t csirs_measurements;
/// Last NDI of UL HARQ processes
int DL_ndi[NR_MAX_HARQ_PROCESSES];
int UL_ndi[NR_MAX_HARQ_PROCESSES];
//// FAPI-like interface message
fapi_nr_ul_config_request_t *ul_config_request;
fapi_nr_dl_config_request_t *dl_config_request;
......
......@@ -80,6 +80,10 @@ void nr_ue_init_mac(module_id_t module_idP)
memset(&mac->ssb_list[i], 0, sizeof(mac->ssb_list[i]));
memset(&mac->prach_assoc_pattern[i], 0, sizeof(mac->prach_assoc_pattern[i]));
}
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) {
mac->ul_harq_info[k].last_ndi = -1; // initialize to invalid value
mac->dl_harq_info[k].last_ndi = -1; // initialize to invalid value
}
}
void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
......@@ -107,11 +111,6 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
mac->scheduling_info.lc_sched_info[i].LCID_status = false;
mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0;
}
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) {
mac->UL_ndi[k] = -1; // initialize to invalid value
mac->DL_ndi[k] = -1; // initialize to invalid value
}
}
NR_UE_MAC_INST_t *nr_l2_init_ue(int nb_inst)
......@@ -147,6 +146,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
// MAC reset according to 38.321 Section 5.12
nr_ue_mac_default_configs(nr_mac);
// initialize Bj for each logical channel to zero
// Done in default config but to -1 (is that correct?)
......@@ -158,7 +158,7 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
// set the NDIs for all uplink HARQ processes to the value 0
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++)
nr_mac->UL_ndi[k] = -1; // initialize to invalid value
nr_mac->ul_harq_info[k].last_ndi = -1; // initialize to invalid value
// stop any ongoing RACH procedure
if (nr_mac->ra.ra_state < RA_SUCCEEDED)
......@@ -184,7 +184,8 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac)
memset(&nr_mac->dl_harq_info[k], 0, sizeof(NR_UE_HARQ_STATUS_t));
// for each DL HARQ process, consider the next received transmission for a TB as the very first transmission
// TODO there is nothing in the MAC indicating first transmission
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++)
nr_mac->dl_harq_info[k].last_ndi = -1; // initialize to invalid value
// release, if any, Temporary C-RNTI
nr_mac->ra.t_crnti = 0;
......
......@@ -684,18 +684,18 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id,
/* NDI (only if CRC scrambled by C-RNTI or CS-RNTI or new-RNTI or TC-RNTI)*/
if (dl_conf_req->pdu_type == FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH ||
dl_conf_req->pdu_type == FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH ||
dci->ndi != mac->DL_ndi[dci->harq_pid]) {
dci->ndi != current_harq->last_ndi) {
// new data
dlsch_pdu->ndi = 1;
dlsch_pdu->new_data_indicator = true;
current_harq->R = 0;
current_harq->TBS = 0;
}
else
dlsch_pdu->ndi = 0;
dlsch_pdu->new_data_indicator = false;
if (dl_conf_req->pdu_type != FAPI_NR_DL_CONFIG_TYPE_SI_DLSCH &&
dl_conf_req->pdu_type != FAPI_NR_DL_CONFIG_TYPE_RA_DLSCH) {
mac->DL_ndi[dci->harq_pid] = dci->ndi;
current_harq->last_ndi = dci->ndi;
}
dlsch_pdu->qamModOrder = nr_get_Qm_dl(dlsch_pdu->mcs, dlsch_pdu->mcs_table);
......@@ -723,10 +723,10 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id,
1);
// storing for possible retransmissions
current_harq->R = dlsch_pdu->targetCodeRate;
if (dlsch_pdu->ndi == 0 && current_harq->TBS != dlsch_pdu->TBS) {
if (!dlsch_pdu->new_data_indicator && current_harq->TBS != dlsch_pdu->TBS) {
LOG_W(NR_MAC, "NDI indicates re-transmission but computed TBS %d doesn't match with what previously stored %d\n",
dlsch_pdu->TBS, current_harq->TBS);
dlsch_pdu->ndi = 1; // treated as new data
dlsch_pdu->new_data_indicator = true; // treated as new data
}
current_harq->TBS = dlsch_pdu->TBS;
}
......@@ -825,7 +825,7 @@ static int nr_ue_process_dci_dl_10(module_id_t module_id,
"scaling_factor_S=%f\n>>> tpc_pucch=%d\n>>> pucch_res_ind=%d\n>>> pdsch_to_harq_feedback_time_ind=%d\n",
dlsch_pdu->vrb_to_prb_mapping,
dlsch_pdu->mcs,
dlsch_pdu->ndi,
dlsch_pdu->new_data_indicator,
dlsch_pdu->rv,
dlsch_pdu->harq_process_nbr,
dci->dai[0].val,
......@@ -986,22 +986,22 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id,
dlsch_pdu->mcs = dci->mcs;
/* NDI (for transport block 1)*/
NR_UE_HARQ_STATUS_t *current_harq = &mac->dl_harq_info[dci->harq_pid];
if (dci->ndi != mac->DL_ndi[dci->harq_pid]) {
if (dci->ndi != current_harq->last_ndi) {
// new data
dlsch_pdu->ndi = 1;
dlsch_pdu->new_data_indicator = true;
current_harq->R = 0;
current_harq->TBS = 0;
}
else {
dlsch_pdu->ndi = 0;
dlsch_pdu->new_data_indicator = false;
}
mac->DL_ndi[dci->harq_pid] = dci->ndi;
current_harq->last_ndi = dci->ndi;
/* RV (for transport block 1)*/
dlsch_pdu->rv = dci->rv;
/* MCS (for transport block 2)*/
dlsch_pdu->tb2_mcs = dci->mcs2.val;
/* NDI (for transport block 2)*/
dlsch_pdu->tb2_ndi = dci->ndi2.val;
dlsch_pdu->tb2_new_data_indicator = dci->ndi2.val;
/* RV (for transport block 2)*/
dlsch_pdu->tb2_rv = dci->rv2.val;
/* HARQ_PROCESS_NUMBER */
......@@ -1170,10 +1170,10 @@ static int nr_ue_process_dci_dl_11(module_id_t module_id,
0,
Nl);
// storing for possible retransmissions
if (dlsch_pdu->ndi == 0 && current_harq->TBS != dlsch_pdu->TBS) {
if (!dlsch_pdu->new_data_indicator && current_harq->TBS != dlsch_pdu->TBS) {
LOG_W(NR_MAC, "NDI indicates re-transmission but computed TBS %d doesn't match with what previously stored %d\n",
dlsch_pdu->TBS, current_harq->TBS);
dlsch_pdu->ndi = 1; // treated as new data
dlsch_pdu->new_data_indicator = true; // treated as new data
}
current_harq->R = dlsch_pdu->targetCodeRate;
current_harq->TBS = dlsch_pdu->TBS;
......
......@@ -651,13 +651,14 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
}
/* NDI */
pusch_config_pdu->pusch_data.new_data_indicator = 0;
if (dci->ndi != mac->UL_ndi[dci->harq_pid]) {
pusch_config_pdu->pusch_data.new_data_indicator = 1;
NR_UL_HARQ_INFO_t *harq = &mac->ul_harq_info[dci->harq_pid];
pusch_config_pdu->pusch_data.new_data_indicator = false;
if (dci->ndi != harq->last_ndi) {
pusch_config_pdu->pusch_data.new_data_indicator = true;
// if new data reset harq structure
memset(&mac->ul_harq_info[dci->harq_pid], 0, sizeof(mac->ul_harq_info[dci->harq_pid]));
memset(harq, 0, sizeof(*harq));
}
mac->UL_ndi[dci->harq_pid] = dci->ndi;
harq->last_ndi = dci->ndi;
/* RV */
pusch_config_pdu->pusch_data.rv_index = dci->rv;
/* HARQ_PROCESS_NUMBER */
......
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