Commit 6ef5d27c authored by Thomas Schlichter's avatar Thomas Schlichter

NR_UE: fix usage of PUSCH new_data_indicator and cleanup

parent 6debc5dd
...@@ -615,7 +615,6 @@ void nr_init_ul_harq_processes(NR_UL_UE_HARQ_t harq_list[NR_MAX_ULSCH_HARQ_PROCE ...@@ -615,7 +615,6 @@ void nr_init_ul_harq_processes(NR_UL_UE_HARQ_t harq_list[NR_MAX_ULSCH_HARQ_PROCE
DevAssert(harq_list[i].f); DevAssert(harq_list[i].f);
bzero(harq_list[i].f,14*num_rb*12*16); bzero(harq_list[i].f,14*num_rb*12*16);
harq_list[i].first_tx = 1;
harq_list[i].round = 0; harq_list[i].round = 0;
} }
} }
...@@ -642,7 +641,6 @@ void clean_UE_harq(PHY_VARS_NR_UE *UE) ...@@ -642,7 +641,6 @@ void clean_UE_harq(PHY_VARS_NR_UE *UE)
ul_harq_process->tx_status = NEW_TRANSMISSION_HARQ; ul_harq_process->tx_status = NEW_TRANSMISSION_HARQ;
ul_harq_process->status = SCH_IDLE; ul_harq_process->status = SCH_IDLE;
ul_harq_process->round = 0; ul_harq_process->round = 0;
ul_harq_process->first_tx = 1;
} }
} }
......
...@@ -45,8 +45,6 @@ typedef enum { ...@@ -45,8 +45,6 @@ typedef enum {
} harq_result_t; } harq_result_t;
typedef struct { typedef struct {
/// Indicator of first transmission
uint8_t first_tx;
/// HARQ tx status /// HARQ tx status
harq_result_t tx_status; harq_result_t tx_status;
/// Status Flag indicating for this ULSCH (idle,active,disabled) /// Status Flag indicating for this ULSCH (idle,active,disabled)
...@@ -57,8 +55,6 @@ typedef struct { ...@@ -57,8 +55,6 @@ typedef struct {
uint8_t O_ACK; uint8_t O_ACK;
/// Index of current HARQ round for this ULSCH /// Index of current HARQ round for this ULSCH
uint8_t round; uint8_t round;
/// Last Ndi for this harq process
uint8_t ndi;
/// pointer to pdu from MAC interface (TS 36.212 V15.4.0, Sec 5.1 p. 8) /// pointer to pdu from MAC interface (TS 36.212 V15.4.0, Sec 5.1 p. 8)
unsigned char *a; unsigned char *a;
/// Pointer to the payload + CRC /// Pointer to the payload + CRC
......
...@@ -72,15 +72,13 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ...@@ -72,15 +72,13 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
LOG_D(NR_PHY, "ulsch coding nb_rb %d, Nl = %d\n", nb_rb, ulsch->pusch_pdu.nrOfLayers); LOG_D(NR_PHY, "ulsch coding nb_rb %d, Nl = %d\n", nb_rb, ulsch->pusch_pdu.nrOfLayers);
LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d Coderate %f\n", A, G, mod_order, Coderate); LOG_D(NR_PHY, "ulsch coding A %d G %d mod_order %d Coderate %f\n", A, G, mod_order, Coderate);
LOG_D(NR_PHY, "harq_pid %d harq_process->ndi %d, pusch_data.new_data_indicator %d\n", LOG_D(NR_PHY, "harq_pid %d, pusch_data.new_data_indicator %d\n",
harq_pid,harq_process->ndi,ulsch->pusch_pdu.pusch_data.new_data_indicator); harq_pid, ulsch->pusch_pdu.pusch_data.new_data_indicator);
if (harq_process->first_tx == 1 || if (ulsch->pusch_pdu.pusch_data.new_data_indicator) { // this is a new packet
harq_process->ndi != ulsch->pusch_pdu.pusch_data.new_data_indicator) { // this is a new packet
#ifdef DEBUG_ULSCH_CODING #ifdef DEBUG_ULSCH_CODING
printf("encoding thinks this is a new packet \n"); printf("encoding thinks this is a new packet \n");
#endif #endif
harq_process->first_tx = 0;
///////////////////////// a---->| add CRC |---->b ///////////////////////// ///////////////////////// a---->| add CRC |---->b /////////////////////////
/////////// ///////////
/* /*
...@@ -216,8 +214,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue, ...@@ -216,8 +214,6 @@ int nr_ulsch_encoding(PHY_VARS_NR_UE *ue,
/////////// ///////////
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
LOG_D(PHY,"setting ndi to %d from pusch_data\n", ulsch->pusch_pdu.pusch_data.new_data_indicator);
harq_process->ndi = ulsch->pusch_pdu.pusch_data.new_data_indicator;
} }
F = harq_process->F; F = harq_process->F;
Kr = harq_process->K; Kr = harq_process->K;
......
...@@ -98,75 +98,6 @@ ...@@ -98,75 +98,6 @@
#define DL_DCI (1) #define DL_DCI (1)
#define UL_DCI (0) #define UL_DCI (0)
/*******************************************************************
*
* NAME : uplink_harq_process
*
* PARAMETERS : ue context
* slot_tx slot for transmission
* gNB_id identifier
* ndi from DCI
* rnti_type from DCI
*
* RETURN : true it a new transmission
* false it is a retransmission
*
* DESCRIPTION : manage uplink grant information for transmissions/retransmissions
* TS 38.321 5.4.1 UL Grant reception
* TS 38.321 5.4.2.1 HARQ Entity
*
*********************************************************************/
harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, NR_UL_UE_HARQ_t harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES], int ndi, uint8_t rnti_type)
{
harq_result_t result_harq = RETRANSMISSION_HARQ;
if (rnti_type == _CS_RNTI_) {
LOG_E(PHY, "Fatal error in HARQ entity due to not supported CS_RNTI at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__);
return(NEW_TRANSMISSION_HARQ);
}
else if ((rnti_type != _C_RNTI_) && (rnti_type != _TC_RNTI_)) {
/* harq mechanism is not relevant for other rnti */
return(NEW_TRANSMISSION_HARQ);
}
else if (harq_pid > ulsch->number_harq_processes_for_pusch) {
LOG_E(PHY, "Fatal error in HARQ entity due to unknown process identity %d at line %d in function %s of file %s \n", harq_pid, __LINE__ , __func__, __FILE__);
assert(0);
}
/* 38.321 5.4.2.1 2> if the uplink grant was received on PDCCH for the C-RNTI and the HARQ buffer of the identified process is empty */
if ((harq_processes[harq_pid].first_tx == 1) && (rnti_type == _C_RNTI_)) { /* no transmission yet on this process so consider its harq buffer as empty */
harq_processes[harq_pid].first_tx = 0;
harq_processes[harq_pid].ndi = ndi; /* store first value of ndi */
harq_processes[harq_pid].round = 0;
result_harq = NEW_TRANSMISSION_HARQ;
LOG_D(PHY, "[HARQ-UL-PUSCH harqId : %d] first new transmission \n", harq_pid);
}
/* 38.321 5.4.2.1 2> if the received grant was not addressed to a Temporary C-RNTI on PDCCH, and the NDI provided in the associated HARQ */
/* information has been toggled compared to the value in the previous transmission of this TB of this HARQ process */
else if ((harq_processes[harq_pid].ndi != ndi) && (rnti_type != _TC_RNTI_)) { /* is ndi toogled so this is a new grant ? */
harq_processes[harq_pid].ndi = ndi; /* store first value of ndi */
harq_processes[harq_pid].round = 0;
result_harq = NEW_TRANSMISSION_HARQ;
LOG_D(PHY, "[HARQ-UL-PUSCH harqId : %d] new transmission due to toogle of ndi \n", harq_pid);
}
/* 38.321 5.4.2.1 2> else (i.e. retransmission): */
else {
harq_processes[harq_pid].ndi = ndi; /* ndi has not toggled si this is a retransmission */
harq_processes[harq_pid].round++; /* increment number of retransmission */
result_harq = RETRANSMISSION_HARQ;
LOG_D(PHY, "[HARQ-UL-PUSCH harqId : %d] retransmission \n", harq_pid);
}
return (result_harq);
}
/******************************************************************* /*******************************************************************
* *
* NAME : init_downlink_harq_status * NAME : init_downlink_harq_status
......
...@@ -55,13 +55,6 @@ ...@@ -55,13 +55,6 @@
/*************** FUNCTIONS ****************************************/ /*************** FUNCTIONS ****************************************/
/** \brief This function update uplink harq context and return transmission type (new transmission or retransmission)
@param ulsch uplink harq context
@param harq process identifier harq_pid
@returns retransmission or new transmission */
harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, NR_UL_UE_HARQ_t harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES], int ndi, uint8_t rnti_type);
/** \brief This function initialises downlink HARQ status /** \brief This function initialises downlink HARQ status
@param pointer to downlink harq status @param pointer to downlink harq status
@returns none */ @returns none */
......
...@@ -1117,7 +1117,7 @@ int main(int argc, char *argv[]) ...@@ -1117,7 +1117,7 @@ int main(int argc, char *argv[])
pusch_config_pdu->target_code_rate = code_rate; pusch_config_pdu->target_code_rate = code_rate;
pusch_config_pdu->tbslbrm = tbslbrm; pusch_config_pdu->tbslbrm = tbslbrm;
pusch_config_pdu->pusch_data.tb_size = TBS / 8; pusch_config_pdu->pusch_data.tb_size = TBS / 8;
pusch_config_pdu->pusch_data.new_data_indicator = trial & 0x1; pusch_config_pdu->pusch_data.new_data_indicator = round == 0 ? true : false;
pusch_config_pdu->pusch_data.rv_index = rv_index; pusch_config_pdu->pusch_data.rv_index = rv_index;
pusch_config_pdu->pusch_data.harq_process_id = harq_pid; pusch_config_pdu->pusch_data.harq_process_id = harq_pid;
pusch_config_pdu->pusch_ptrs.ptrs_time_density = ptrs_time_density; pusch_config_pdu->pusch_ptrs.ptrs_time_density = ptrs_time_density;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
* *
* MODULE : UE test bench for hard (hybrid repeat request acknowledgment) * MODULE : UE test bench for hard (hybrid repeat request acknowledgment)
* *
* DESCRIPTION : it allows unitary tests for uplink and downlink harq * DESCRIPTION : it allows unitary tests for downlink harq
* *
************************************************************************/ ************************************************************************/
...@@ -39,65 +39,6 @@ ...@@ -39,65 +39,6 @@
//#include "PHY/vars.h" //#include "PHY/vars.h"
//#include "LAYER2/MAC/vars.h" //#include "LAYER2/MAC/vars.h"
/*******************************************************************
*
* NAME : test_harq_uplink
*
* PARAMETERS : none
*
* RETURN : none
*
* DESCRIPTION : test of HARQ uplink feature
*
*********************************************************************/
int test_harq_uplink(PHY_VARS_NR_UE *phy_vars_ue)
{
int gNB_id = 0;
int thread_number = 0;
int code_word_idx = 0;
int harq_pid = 0;
int ndi = 1;
uint8_t rnti_type = _C_RNTI_;
int number_steps = 5;
printf("\nHARQ Uplink \n");
config_uplink_harq_process(phy_vars_ue , gNB_id, thread_number, code_word_idx, NR_DEFAULT_DLSCH_HARQ_PROCESSES);
NR_UE_ULSCH_t *ulsch_harq = phy_vars_ue->ulsch[gNB_id];
/* reach maximum number of retransmissions */
printf("First sequence ndi does not toggle \n");
for (int i = 0 ; i < number_steps; i++) {
uplink_harq_process(ulsch_harq, harq_pid, ndi, rnti_type);
}
harq_pid++; /* next harq */
/* new grant so new transmission each try */
printf("Second sequence ndi toggle each transmission \n");
for (int i = 0 ; i < number_steps; i++) {
uplink_harq_process(ulsch_harq, harq_pid, ndi, rnti_type);
ndi ^= 1; /* toogle ndi each try */
}
harq_pid++; /* next harq */
/* new grant so new transmission each try */
printf("Third sequence ndi toggle each two transmissions \n");
for (int i = 0 ; i < number_steps; i++) {
uplink_harq_process(ulsch_harq, harq_pid, ndi, rnti_type);
if (i & 0x1) {
ndi ^= 1; /* toogle ndi each try */
}
}
release_uplink_harq_process(phy_vars_ue , gNB_id, thread_number, code_word_idx);
return 0;
}
/******************************************************************* /*******************************************************************
* *
* NAME : test_harq_downlink * NAME : test_harq_downlink
...@@ -175,11 +116,7 @@ int test_harq(PHY_VARS_NR_UE *phy_vars_ue) ...@@ -175,11 +116,7 @@ int test_harq(PHY_VARS_NR_UE *phy_vars_ue)
{ {
int result = -1; int result = -1;
result = test_harq_uplink(phy_vars_ue); result = test_harq_downlink(phy_vars_ue);
if (result == 0) {
result = test_harq_downlink(phy_vars_ue);
}
return (result); return (result);
} }
...@@ -188,7 +125,7 @@ int test_harq(PHY_VARS_NR_UE *phy_vars_ue) ...@@ -188,7 +125,7 @@ int test_harq(PHY_VARS_NR_UE *phy_vars_ue)
* *
* NAME : main * NAME : main
* *
* DESCRIPTION : test of uplink and downlink harq entities * DESCRIPTION : test of downlink harq entities
* *
*********************************************************************/ *********************************************************************/
......
...@@ -505,9 +505,7 @@ typedef struct { ...@@ -505,9 +505,7 @@ typedef struct {
fapi_nr_csirs_measurements_t csirs_measurements; fapi_nr_csirs_measurements_t csirs_measurements;
/// Last NDI of UL HARQ processes /// Last NDI of UL HARQ processes
uint8_t UL_ndi[NR_MAX_HARQ_PROCESSES]; int UL_ndi[NR_MAX_HARQ_PROCESSES];
/// first ULTX of UL HARQ processes
int first_ul_tx[NR_MAX_HARQ_PROCESSES];
//// FAPI-like interface message //// FAPI-like interface message
fapi_nr_ul_config_request_t *ul_config_request; fapi_nr_ul_config_request_t *ul_config_request;
fapi_nr_dl_config_request_t *dl_config_request; fapi_nr_dl_config_request_t *dl_config_request;
......
...@@ -197,7 +197,7 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac) ...@@ -197,7 +197,7 @@ void nr_ue_mac_default_configs(NR_UE_MAC_INST_t *mac)
mac->scheduling_info.lc_sched_info[i].LCID_status = LCID_EMPTY; mac->scheduling_info.lc_sched_info[i].LCID_status = LCID_EMPTY;
mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0; mac->scheduling_info.lc_sched_info[i].LCID_buffer_remain = 0;
for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++) for (int k = 0; k < NR_MAX_HARQ_PROCESSES; k++)
mac->first_ul_tx[k] = 1; mac->UL_ndi[k] = -1; // initialize to invalid value
} }
memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements)); memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements));
......
...@@ -627,7 +627,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac, ...@@ -627,7 +627,8 @@ int nr_config_pusch_pdu(NR_UE_MAC_INST_t *mac,
} }
/* NDI */ /* NDI */
pusch_config_pdu->pusch_data.new_data_indicator = dci->ndi; pusch_config_pdu->pusch_data.new_data_indicator = dci->ndi != mac->UL_ndi[dci->harq_pid] ? 1 : 0;
mac->UL_ndi[dci->harq_pid] = dci->ndi;
/* RV */ /* RV */
pusch_config_pdu->pusch_data.rv_index = dci->rv; pusch_config_pdu->pusch_data.rv_index = dci->rv;
/* HARQ_PROCESS_NUMBER */ /* HARQ_PROCESS_NUMBER */
...@@ -1032,9 +1033,8 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1032,9 +1033,8 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) { if (ulcfg_pdu->pdu_type == FAPI_NR_UL_CONFIG_TYPE_PUSCH) {
int mac_pdu_exist = 0; int mac_pdu_exist = 0;
uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size; uint16_t TBS_bytes = ulcfg_pdu->pusch_config_pdu.pusch_data.tb_size;
LOG_D(NR_MAC,"harq_id %d, NDI %d NDI_DCI %d, TBS_bytes %d (ra_state %d)\n", LOG_D(NR_MAC,"harq_id %d, new_data_indicator %d, TBS_bytes %d (ra_state %d)\n",
ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id, ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id,
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id],
ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator, ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator,
TBS_bytes,ra->ra_state); TBS_bytes,ra->ra_state);
if (ra->ra_state == WAIT_RAR && !ra->cfra) { if (ra->ra_state == WAIT_RAR && !ra->cfra) {
...@@ -1043,14 +1043,10 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1043,14 +1043,10 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
for (int k = 0; k < TBS_bytes; k++) { for (int k = 0; k < TBS_bytes; k++) {
LOG_D(NR_MAC,"(%i): 0x%x\n", k, ulsch_input_buffer[k]); LOG_D(NR_MAC,"(%i): 0x%x\n", k, ulsch_input_buffer[k]);
} }
LOG_D(NR_MAC,"Flipping NDI for harq_id %d (Msg3)\n", ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
mac_pdu_exist = 1; mac_pdu_exist = 1;
} else { } else {
if ((mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] != ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator || if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator &&
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] == 1) &&
(mac->state == UE_CONNECTED || (mac->state == UE_CONNECTED ||
(ra->ra_state == WAIT_RAR && ra->cfra))){ (ra->ra_state == WAIT_RAR && ra->cfra))){
...@@ -1059,10 +1055,6 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info) ...@@ -1059,10 +1055,6 @@ void nr_ue_ul_scheduler(nr_uplink_indication_t *ul_info)
mac_pdu_exist = 1; mac_pdu_exist = 1;
} }
LOG_D(NR_MAC,"Flipping NDI for harq_id %d\n",ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator);
mac->UL_ndi[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator;
mac->first_ul_tx[ulcfg_pdu->pusch_config_pdu.pusch_data.harq_process_id] = 0;
} }
// Config UL TX PDU // Config UL TX PDU
......
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