From 5d30379b796653baa07b45fde578edb68a82b551 Mon Sep 17 00:00:00 2001 From: Jacques Date: Tue, 28 Aug 2018 11:17:02 +0200 Subject: [PATCH] nr ue : add tdd slot config --- openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c | 75 ++++-------- .../PHY/NR_UE_TRANSPORT/nr_transport_ue.h | 17 ++- openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c | 6 +- openair1/PHY/defs_nr_UE.h | 54 +++------ openair1/PHY/defs_nr_common.h | 3 +- openair1/PHY/impl_defs_nr.h | 4 +- openair1/PHY/impl_defs_top.h | 2 +- openair1/SCHED_NR_UE/harq_nr.c | 112 ++++++++++++------ openair1/SCHED_NR_UE/harq_nr.h | 37 +++--- openair1/SCHED_NR_UE/phy_frame_config_nr.c | 2 +- openair1/SCHED_NR_UE/phy_procedures_nr_ue.c | 23 ++-- openair1/SCHED_NR_UE/pucch_uci_ue_nr.c | 6 +- .../NR_UE_PHY/unit_tests/build/run_tests.sh | 55 +++++---- .../NR_UE_PHY/unit_tests/readme.txt | 51 +++++--- .../NR_UE_PHY/unit_tests/src/harq_test.c | 4 +- targets/RT/USER/nr-ue.c | 28 +---- 16 files changed, 249 insertions(+), 230 deletions(-) diff --git a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c index 37937e75eb..b67af47540 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/dci_tools_nr.c @@ -39,6 +39,7 @@ #endif #include "assertions.h" +#include "SCHED_NR_UE/harq_nr.h" //#define DEBUG_HARQ @@ -4180,6 +4181,22 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, #endif } + /* store rnti type */ + for (int k=0; k < TOTAL_NBR_SCRAMBLED_VALUES; k++) { + if (rnti == crc_scrambled_values[k]) { + if ((dci_format == format1_0) || (dci_format == format1_1)) { + pdlsch0->rnti_type = k; + } + else { + ulsch0->rnti_type = k; + } + } + } + + if (j == TOTAL_NBR_SCRAMBLED_VALUES) { + LOG_E(PHY, "Fatal error in DCI due to unknown RNTI type at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); + } + if ((dci_format == format1_0) || (dci_format == format1_1)) { if (rnti==crc_scrambled_values[_SI_RNTI_]) { ue->dlsch_SI[eNB_id]->active = 1; @@ -4335,9 +4352,6 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, start_RB = n_RB_DLBWP - start_RB - 1; } pdlsch0_harq->nb_rb = l_RB; - pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; - pdlsch0->active = 1; - pdlsch0->rnti = rnti; } #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->freq_dom_resource_assignment_DL=%x, RIV = %d\n",nr_pdci_info_extracted->freq_dom_resource_assignment_DL,nr_pdci_info_extracted->freq_dom_resource_assignment_DL); @@ -4534,30 +4548,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case NDI: // 25 NDI: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) nr_pdci_info_extracted->ndi = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); - if (dci_format == format0_0 || dci_format == format0_1) { - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi = nr_pdci_info_extracted->ndi; - if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx==1) { - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->first_tx=0; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; - } else { - if (ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi != nr_pdci_info_extracted->ndi) { // new SDU opportunity - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->DCINdi= nr_pdci_info_extracted->ndi; - ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->round = 0; - } - } - } else { - if (rnti == crc_scrambled_values[_TC_RNTI_]) { //fix for standalone Contention Resolution Id - pdlsch0_harq->DCINdi = (uint8_t)-1; - } else { - if ((prev_ndi != nr_pdci_info_extracted->ndi) || (pdlsch0_harq->first_tx==1)) { - pdlsch0_harq->round = 0; - pdlsch0_harq->first_tx = 0; - pdlsch0_harq->status = ACTIVE; - } - pdlsch0_harq->DCINdi = nr_pdci_info_extracted->ndi; - } - } + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->ndi=%x\n",nr_pdci_info_extracted->ndi); #endif @@ -4565,29 +4556,12 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case RV: // 26 RV: (field defined for format0_0,format0_1,format1_0,-,-,-,-,-) nr_pdci_info_extracted->rv = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); + if (dci_format == format0_0 || dci_format == format0_1) ulsch0->harq_processes[nr_pdci_info_extracted->harq_process_number]->rvidx = nr_pdci_info_extracted->rv; else pdlsch0_harq->rvidx = nr_pdci_info_extracted->rv; - if ((prev_ndi == nr_pdci_info_extracted->ndi) && (pdlsch0_harq->rvidx != 0)) { // NDI has not been toggled but rv was increased by eNB: retransmission - if (pdlsch0_harq->status == SCH_IDLE) { - // packet was actually decoded in previous transmission (ACK was missed by eNB) - // however, the round is not a good check as it might have been decoded in a retransmission prior to this one. - // skip pdsch decoding and report ack - - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.ack = 1; - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.send_harq_status; -#if 0 - pdlsch0->active = 0; - pdlsch0->harq_ack[nr_tti_rx].ack = 1; - pdlsch0->harq_ack[nr_tti_rx].harq_id = nr_pdci_info_extracted->harq_process_number; - pdlsch0->harq_ack[nr_tti_rx].send_harq_status = 1; -#endif - } else { // normal retransmission, nothing special to do - } - } else { - pdlsch0_harq->status = ACTIVE; - } + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->rv=%x\n",nr_pdci_info_extracted->rv); #endif @@ -4595,7 +4569,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, case HARQ_PROCESS_NUMBER: // 27 HARQ_PROCESS_NUMBER: (field defined for format0_0,format0_1,format1_0,format1_1,-,-,-,-) nr_pdci_info_extracted->harq_process_number = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); - pdlsch0->current_harq_pid = nr_pdci_info_extracted->harq_process_number; + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->harq_process_number=%x\n",nr_pdci_info_extracted->harq_process_number); #endif @@ -4607,8 +4581,7 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, // 2 if one serving cell is configured in the DL and the higher layer parameter HARQ-ACK-codebook=dynamic, where the 2 bits are the counter DAI // 0 otherwise nr_pdci_info_extracted->dai = (uint8_t)(((((*(uint64_t *)dci_pdu) << (left_shift - dci_fields_sizes[dci_field][dci_format-15]))) & pdu_bitmap) >> (dci_length - dci_fields_sizes[dci_field][dci_format-15])); - pdlsch0->harq_processes[pdlsch0->current_harq_pid]->harq_ack.vDAI_DL = nr_pdci_info_extracted->dai+1; - //pdlsch0->harq_ack[nr_tti_rx].vDAI_DL = nr_pdci_info_extracted->dai+1; + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->dai=%x\n",nr_pdci_info_extracted->dai); #endif @@ -4811,11 +4784,13 @@ int nr_extract_dci_info(PHY_VARS_NR_UE *ue, printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> nr_pdci_info_extracted->reserved_nr_dci=%x\n",nr_pdci_info_extracted->reserved_nr_dci); #endif break; - } } } + /* process harq -> set dlsch[0]->harq_processes[dlsch[0]->current_harq_pid].rx_status give NEW TRANSMISSION or RETRANSMISSION */ + get_dci_info_for_harq(ue, nr_pdci_info_extracted, pdlsch0, ulsch0, nr_tti_rx, k_offset); + #ifdef NR_PDCCH_DCI_TOOLS_DEBUG printf("\t\t<-NR_PDCCH_DCI_TOOLS_DEBUG (nr_extract_dci_info) -> Ending function nr_extract_dci_info()\n"); #endif diff --git a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h index 789515d60d..ceea378fc9 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h +++ b/openair1/PHY/NR_UE_TRANSPORT/nr_transport_ue.h @@ -33,6 +33,7 @@ #define __NR_TRANSPORT_UE__H__ #include #include "PHY/impl_defs_top.h" + //#include "PHY/defs_nr_UE.h" //#include "../LTE_TRANSPORT/dci.h" //#include "../LTE_TRANSPORT/mdci.h" @@ -50,11 +51,18 @@ * @{ */ +typedef enum { + NEW_TRANSMISSION_HARQ, + RETRANSMISSION_HARQ +} harq_result_t; + //#if defined(UPGRADE_RAT_NR) #if 1 typedef struct { /// HARQ process id uint8_t harq_id; + /// HARQ rx status + harq_result_t rx_status; /// ACK bits (after decoding) 0:NACK / 1:ACK / 2:DTX uint8_t ack; /// send status (for PUCCH) @@ -81,6 +89,8 @@ typedef struct { uint8_t first_tx; /// Last Ndi received for this process on DCI (used for C-RNTI only) uint8_t DCINdi; + /// HARQ tx status + harq_result_t tx_status; /// Flag indicating that this ULSCH has a new packet (start of new round) // uint8_t Ndi; /// Status Flag indicating for this ULSCH (idle,active,disabled) @@ -145,7 +155,6 @@ typedef struct { // int calibration_flag; /// Number of soft channel bits uint32_t G; - // decode phich uint8_t decode_phich; } NR_UL_UE_HARQ_t; @@ -159,7 +168,7 @@ typedef struct { #if 1 // Pointers to HARQ processes for the ULSCH NR_UL_UE_HARQ_t *harq_processes[NR_MAX_ULSCH_HARQ_PROCESSES]; - int harq_process_id[NR_MAX_SLOTS_PAR_FRAME]; + int harq_process_id[NR_MAX_SLOTS_PER_FRAME]; // UL number of harq processes uint8_t number_harq_processes_for_pusch; #endif @@ -211,6 +220,8 @@ typedef struct { uint8_t cooperation_flag; /// RNTI attributed to this ULSCH uint16_t rnti; + /// RNTI type + uint8_t rnti_type; /// f_PUSCH parameter for PUSCH power control int16_t f_pusch; /// Po_PUSCH - target output power for PUSCH @@ -311,6 +322,8 @@ typedef struct { typedef struct { /// RNTI uint16_t rnti; + /// RNTI type + uint8_t rnti_type; /// Active flag for DLSCH demodulation uint8_t active; /// Transmission mode diff --git a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c index 03d303a123..c9dd6112d4 100644 --- a/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c +++ b/openair1/PHY/NR_UE_TRANSPORT/pucch_nr.c @@ -453,7 +453,9 @@ void nr_generate_pucch0(int32_t **txdataF, PUCCH_GroupHopping=0; n_id=10; PUCCH_Frequency_Hopping = 0; +#ifdef DEBUG_NR_PUCCH_TX printf("\t [nr_generate_pucch0] sequence generation: variable initialization for test\n"); +#endif /////////////////////////////////////////////////////// ending variables initialization for test // x_n contains the sequence r_u_v_alpha_delta(n) @@ -862,7 +864,7 @@ inline void nr_pucch2_3_4_scrambling(uint16_t M_bit,uint16_t rnti,uint16_t n_id, for (i=0;i>i)&1); btilde[i] = (((B>>i)&1) ^ c); - #ifndef DEBUG_NR_PUCCH_TX + #ifdef DEBUG_NR_PUCCH_TX printf("\t\t\t btilde[%d]=%lx from scrambled bit %d\n",i,btilde[i],((B>>i)&1)); #endif } @@ -1303,7 +1305,7 @@ void nr_generate_pucch3_4(int32_t **txdataF, z_im[l*(12*nrofPRB)+k] = z_im[l*(12*nrofPRB)+k] + (int16_t)(((int32_t)round(32767/sqrt(12*nrofPRB))*(int16_t)((((int32_t)y_n_im[l*(12*nrofPRB)+m] * (int16_t)round(32767 * cos(2*M_PI*m*k/(12*nrofPRB))))>>15) - (((int32_t)y_n_re[l*(12*nrofPRB)+m] * (int16_t)round(32767 * sin(2*M_PI*m*k/(12*nrofPRB))))>>15)))>>15); - #ifndef DEBUG_NR_PUCCH_TX + #ifdef DEBUG_NR_PUCCH_TX printf("\t [nr_generate_pucch3_4] transform precoding for formats 3 and 4: (l,k,m)=(%d,%d,%d)\tz(%d) = \t(%d, %d)\n", l,k,m,l*(12*nrofPRB)+k,z_re[l*(12*nrofPRB)+k],z_im[l*(12*nrofPRB)+k]); #endif diff --git a/openair1/PHY/defs_nr_UE.h b/openair1/PHY/defs_nr_UE.h index 4654564a26..b31436f161 100644 --- a/openair1/PHY/defs_nr_UE.h +++ b/openair1/PHY/defs_nr_UE.h @@ -160,27 +160,6 @@ #include "NR_IF_Module.h" -//#if defined(UPGRADE_RAT_NR) -#if 1 - /* see 38.321 Table 7.1-2 RNTI usage */ -typedef enum { /* Type for Radio Network Temporary Identifier */ - C_RNTI_NR = 0, /* Cell RNTI */ - Temporary_C_RNTI_NR, /* Temporary C-RNTI */ - CS_RNTI_NR, /* Configured Scheduling RNTI */ - P_RNTI_NR, /* Paging RNTI */ - SI_RNTI_NR, /* System information RNTI */ - RA_RNTI_NR, /* Random Access RNTI */ - TPC_CS_RNTI_NR, /* configured scheduling uplink power control */ - TPC_PUCCH_RNTI_NR, /* PUCCH power control */ - TPC_PUSCH_RNTI_NR, /* PUSCH power control */ - TPC_SRS_RNTI_NR, /* SRS trigger and power control */ - INT_RNTI_NR, /* Indication pre-emption in DL */ - SFI_RNTI_NR, /* Slot Format Indication on the given cell */ - SP_CSI_RNTI_NR /* Semipersistent CSI reporting on PUSCH */ -} nr_rnti_type_t; - -#endif - /// Context data structure for RX/TX portion of subframe processing typedef struct { /// index of the current UE RX/TX proc @@ -700,24 +679,21 @@ typedef enum { #define _TPC_PUSCH_RNTI_ 10 #define _TPC_PUCCH_RNTI_ 11 #define _TPC_SRS_RNTI_ 12 - typedef enum { - _c_rnti = _C_RNTI_, - _cs_rnti = _CS_RNTI_, - _new_rnti = _NEW_RNTI_, - _tc_rnti = _TC_RNTI_, - _p_rnti = _P_RNTI_, - _si_rnti = _SI_RNTI_, - _ra_rnti = _RA_RNTI_, - _sp_csi_rnti = _SP_CSI_RNTI_, - _sfi_rnti = _SFI_RNTI_, - _int_rnti = _INT_RNTI_, - _tpc_pusch_rnti = _TPC_PUSCH_RNTI_, - _tpc_pucch_rnti = _TPC_PUCCH_RNTI_, + typedef enum { /* see 38.321 Table 7.1-2 RNTI usage */ + _c_rnti = _C_RNTI_, /* Cell RNTI */ + _cs_rnti = _CS_RNTI_, /* Configured Scheduling RNTI */ + _new_rnti = _NEW_RNTI_, /* ? */ + _tc_rnti = _TC_RNTI_, /* Temporary C-RNTI */ + _p_rnti = _P_RNTI_, /* Paging RNTI */ + _si_rnti = _SI_RNTI_, /* System information RNTI */ + _ra_rnti = _RA_RNTI_, /* Random Access RNTI */ + _sp_csi_rnti = _SP_CSI_RNTI_, /* Semipersistent CSI reporting on PUSCH */ + _sfi_rnti = _SFI_RNTI_, /* Slot Format Indication on the given cell */ + _int_rnti = _INT_RNTI_, /* Indication pre-emption in DL */ + _tpc_pusch_rnti = _TPC_PUSCH_RNTI_, /* PUSCH power control */ + _tpc_pucch_rnti = _TPC_PUCCH_RNTI_, /* PUCCH power control */ _tpc_srs_rnti = _TPC_SRS_RNTI_} crc_scrambled_t; - - - typedef enum {bundle_n2=2,bundle_n3=3,bundle_n6=6} NR_UE_CORESET_REG_bundlesize_t; typedef enum {interleave_n2=2,interleave_n3=3,interleave_n6=6} NR_UE_CORESET_interleaversize_t; @@ -1020,9 +996,9 @@ typedef struct { /// \brief Total gains with bypassed RF gain stage (ExpressMIMO2/Lime) uint32_t rx_gain_byp[4]; /// \brief Current transmit power - int16_t tx_power_dBm[MAX_NR_OF_SLOTS]; + int16_t tx_power_dBm[NR_MAX_SLOTS_PER_FRAME]; /// \brief Total number of REs in current transmission - int tx_total_RE[MAX_NR_OF_SLOTS]; + int tx_total_RE[NR_MAX_SLOTS_PER_FRAME]; /// \brief Maximum transmit power int8_t tx_power_max_dBm; /// \brief Number of eNB seen by UE diff --git a/openair1/PHY/defs_nr_common.h b/openair1/PHY/defs_nr_common.h index 261ebff336..46b4c4ef1f 100644 --- a/openair1/PHY/defs_nr_common.h +++ b/openair1/PHY/defs_nr_common.h @@ -33,6 +33,7 @@ #ifndef __PHY_DEFS_NR_COMMON__H__ #define __PHY_DEFS_NR_COMMON__H__ +#include "PHY/impl_defs_top.h" #include "defs_common.h" #include "nfapi_nr_interface.h" #include "impl_defs_nr.h" @@ -176,7 +177,7 @@ typedef struct NR_DL_FRAME_PARMS { TDD_UL_DL_SlotConfig_t *p_TDD_UL_DL_ConfigDedicated; /// TDD configuration - uint16_t tdd_uplink_nr[MAX_NR_OF_SLOTS]; /* this is a bitmap of symbol of each slot given for 2 frames */ + uint16_t tdd_uplink_nr[2*NR_MAX_SLOTS_PER_FRAME]; /* this is a bitmap of symbol of each slot given for 2 frames */ //SSB related params /// Start in Subcarrier index of the SSB block diff --git a/openair1/PHY/impl_defs_nr.h b/openair1/PHY/impl_defs_nr.h index b2be888e18..51798c94f9 100644 --- a/openair1/PHY/impl_defs_nr.h +++ b/openair1/PHY/impl_defs_nr.h @@ -114,8 +114,6 @@ SystemInformationBlockType1_nr_t; * ************************************************************************/ -#define MAX_NR_OF_SLOTS (320) /* maximum number of slots */ - #define NR_TDD_DOWNLINK_SLOT (0x0000) #define NR_TDD_UPLINK_SLOT (0x3FFF) /* uplink bitmap for each symbol, there are 14 symbols per slots */ #define NR_TDD_SET_ALL_SYMBOLS (0x3FFF) @@ -544,7 +542,7 @@ typedef struct { const initial_pucch_resource_t initial_pucch_resource[NB_INITIAL_PUCCH_RESOURCE]; /* TS 36.213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration */ -/* structure with all possible field for pucch format from 0 to 4 */ +/* structure with all possible fields for pucch format from 0 to 4 */ typedef struct { pucch_format_nr_t format; /* format 0 1 2 3 4 */ uint8_t initialCyclicShift; /* x x */ diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index 0b0f5b8ddb..3a7a0a935c 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -261,7 +261,7 @@ #define NB_NUMEROLOGIES_NR (5) #define TDD_CONFIG_NB_FRAMES (2) -#define NR_MAX_SLOTS_PAR_FRAME (160) /* number of slots per frame */ +#define NR_MAX_SLOTS_PER_FRAME (160) /* number of slots per frame */ #define NR_UE_CAPABILITY_SLOT_RX_TO_TX (4) /* FFS_NR_TODO it defines ue capability which is the number of slots */ /* - between reception of pdsch and tarnsmission of its acknowlegment */ /* - between reception of un uplink grant and its related transmission */ diff --git a/openair1/SCHED_NR_UE/harq_nr.c b/openair1/SCHED_NR_UE/harq_nr.c index f88ffa3afc..42a37c4593 100644 --- a/openair1/SCHED_NR_UE/harq_nr.c +++ b/openair1/SCHED_NR_UE/harq_nr.c @@ -89,9 +89,53 @@ ************************************************************************/ +#include "PHY/defs_nr_UE.h" #include "PHY/NR_UE_TRANSPORT/nr_transport_ue.h" #include "SCHED_NR_UE/harq_nr.h" +/********************* define **************************************/ + +#define DL_DCI (1) +#define UL_DCI (0) + +/******************************************************************* +* +* NAME : get_dci_info_for_harq +* +* PARAMETERS : pointer to ue context +* id of current gNB +* number of uplink processes +* maximum number of uplink retransmissions +* RETURN : none +* +* DESCRIPTION : update HARQ entity with information from DCI +* TS 38.212 7.3.1.2 DCI formats for scheduling PDSCH +* +*********************************************************************/ + +void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted, + NR_UE_DLSCH_t **dlsch, NR_UE_ULSCH_t *ulsch, uint8_t nr_tti_rx, uint8_t tx_offset) +{ + if (nr_dci_info_extracted->identifier_dci_formats == DL_DCI) { + + dlsch[0]->current_harq_pid = nr_dci_info_extracted->harq_process_number; + + NR_DL_UE_HARQ_t *dl_harq = dlsch[0]->harq_processes[dlsch[0]->current_harq_pid]; + + dl_harq->harq_ack.vDAI_DL = nr_dci_info_extracted->dai+1; + dl_harq->harq_ack.pucch_resource_indicator = nr_dci_info_extracted->pucch_resource_ind; + dl_harq->harq_ack.slot_for_feedback_ack = (nr_tti_rx + nr_dci_info_extracted->pdsch_to_harq_feedback_time_ind)%ue->frame_parms.ttis_per_subframe; + dl_harq->harq_ack.harq_id = nr_dci_info_extracted->harq_process_number; + dl_harq->harq_ack.rx_status = downlink_harq_process(dl_harq, dlsch[0]->current_harq_pid, nr_dci_info_extracted->ndi, dlsch[0]->rnti_type); + } + else if (nr_dci_info_extracted->identifier_dci_formats == UL_DCI) { + + /* store harq id for which pusch should be transmitted at rx_slot + tx_offset */ + set_tx_harq_id(ulsch, nr_dci_info_extracted->harq_process_number, (nr_tti_rx + tx_offset)%ue->frame_parms.ttis_per_subframe); + ulsch->harq_processes[nr_dci_info_extracted->harq_process_number]->tx_status = uplink_harq_process(ulsch, nr_dci_info_extracted->harq_process_number, nr_dci_info_extracted->ndi, ulsch->rnti_type); + } +} + /******************************************************************* * * NAME : config_uplink_harq_process @@ -139,6 +183,10 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_h ulsch->harq_processes[harq_pid]->first_tx = 1; ulsch->harq_processes[harq_pid]->round = 0; } + + for (int slot_tx = 0; slot_tx < NR_MAX_SLOTS_PER_FRAME; slot_tx++) { + ue->ulsch[gNB_id]->harq_process_id[slot_tx] = NR_MAX_HARQ_PROCESSES; + } } /******************************************************************* @@ -184,9 +232,9 @@ void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id) * *********************************************************************/ -void set_tx_harq_id(PHY_VARS_NR_UE *ue, int gNB_id, int harq_pid, int slot_tx) +void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx) { - ue->ulsch[gNB_id]->harq_process_id[slot_tx] = harq_pid; + ulsch->harq_process_id[slot_tx] = harq_pid; } /******************************************************************* @@ -199,30 +247,14 @@ void set_tx_harq_id(PHY_VARS_NR_UE *ue, int gNB_id, int harq_pid, int slot_tx) * * RETURN : harq process identifier * -* DESCRIPTION : return tx harq process identifier for given transmission slot +* DESCRIPTION : return tx harq process identifier for given slot transmission * *********************************************************************/ -int get_tx_harq_id(PHY_VARS_NR_UE *ue, int gNB_id, int slot_tx) +int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx) { - return (ue->ulsch[gNB_id]->harq_process_id[slot_tx]); -} -/******************************************************************* -* -* NAME : get_dci_slot_rx_to_tx -* -* PARAMETERS : dci index -* -* RETURN : number of slots -* -* DESCRIPTION : extract from DCI number of slots between current reception and its related transmission -* -*********************************************************************/ - -int get_dci_slot_rx_to_tx(int dci_index) -{ - return (4); + return (ulsch->harq_process_id[slot_tx]); } /******************************************************************* @@ -244,13 +276,17 @@ int get_dci_slot_rx_to_tx(int dci_index) * *********************************************************************/ -harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, int ndi, nr_rnti_type_t rnti_type) +harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, int ndi, uint8_t rnti_type) { harq_result_t result_harq = RETRANSMISSION_HARQ; - if ((rnti_type != C_RNTI_NR) && (rnti_type != Temporary_C_RNTI_NR)) { - LOG_E(PHY, "Fatal error in HARQ entity due to unsupported RNTI at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); - assert(0); + 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__); @@ -258,7 +294,7 @@ harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, int ndi, n } /* 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 ((ulsch->harq_processes[harq_pid]->first_tx == 1) && (rnti_type == C_RNTI_NR)) { /* no transmission yet on this process so consider its harq buffer as empty */ + if ((ulsch->harq_processes[harq_pid]->first_tx == 1) && (rnti_type == _C_RNTI_)) { /* no transmission yet on this process so consider its harq buffer as empty */ ulsch->harq_processes[harq_pid]->first_tx = 0; ulsch->harq_processes[harq_pid]->DCINdi = ndi; /* store first value of ndi */ ulsch->harq_processes[harq_pid]->round = 0; @@ -270,7 +306,7 @@ harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, int ndi, n } /* 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 ((ulsch->harq_processes[harq_pid]->DCINdi != ndi) && (rnti_type != Temporary_C_RNTI_NR)) { /* is ndi toogled so this is a new grant ? */ + else if ((ulsch->harq_processes[harq_pid]->DCINdi != ndi) && (rnti_type != _TC_RNTI_)) { /* is ndi toogled so this is a new grant ? */ ulsch->harq_processes[harq_pid]->DCINdi = ndi; /* store first value of ndi */ ulsch->harq_processes[harq_pid]->round = 0; ulsch->harq_processes[harq_pid]->subframe_scheduling_flag = 1; @@ -313,7 +349,7 @@ void init_downlink_harq_status(NR_DL_UE_HARQ_t *dl_harq) dl_harq->harq_ack.send_harq_status = 0; dl_harq->harq_ack.vDAI_UL = UL_DAI_NO_SET; dl_harq->harq_ack.vDAI_DL = DL_DAI_NO_SET; - dl_harq->harq_ack.slot_for_feedback_ack = NR_MAX_SLOTS_PAR_FRAME; + dl_harq->harq_ack.slot_for_feedback_ack = NR_MAX_SLOTS_PER_FRAME; dl_harq->harq_ack.pucch_resource_indicator = MAX_PUCCH_RESOURCE_INDICATOR; dl_harq->harq_ack.n_CCE = 0; dl_harq->harq_ack.N_CCE = 0;; @@ -418,13 +454,18 @@ void release_downlink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int TB_id, in * *********************************************************************/ -harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, nr_rnti_type_t rnti_type) +harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int ndi, uint8_t rnti_type) { harq_result_t result_harq = RETRANSMISSION_HARQ; - if ((rnti_type != C_RNTI_NR) && (rnti_type != Temporary_C_RNTI_NR)) { - LOG_E(PHY, "Fatal error in HARQ entity due to unknown RNTI at line %d in function %s of file %s \n", __LINE__ , __func__, __FILE__); - assert(0); + 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); } if (dl_harq->first_tx == 1) { @@ -436,7 +477,8 @@ harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int result_harq = NEW_TRANSMISSION_HARQ; NR_TST_PHY_PRINTF("[HARQ-DL-PDSCH harqId : %d] first new reception \n", harq_pid); - } else if (dl_harq->DCINdi != ndi) { + } + else if (dl_harq->DCINdi != ndi) { dl_harq->round = 0; dl_harq->status = ACTIVE; dl_harq->DCINdi = ndi; @@ -444,7 +486,9 @@ harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dl_harq, int harq_pid, int result_harq = NEW_TRANSMISSION_HARQ; NR_TST_PHY_PRINTF("[HARQ-DL-PDSCH harqId : %d] new reception due to toogle of ndi \n", harq_pid); - } else { + } + else { + dl_harq->round++; result_harq = RETRANSMISSION_HARQ; diff --git a/openair1/SCHED_NR_UE/harq_nr.h b/openair1/SCHED_NR_UE/harq_nr.h index 2cf29729be..2d3e87ddab 100644 --- a/openair1/SCHED_NR_UE/harq_nr.h +++ b/openair1/SCHED_NR_UE/harq_nr.h @@ -61,16 +61,25 @@ /************* TYPE ***********************************************/ -typedef enum { - NEW_TRANSMISSION_HARQ, - RETRANSMISSION_HARQ -} harq_result_t; /************** VARIABLES *****************************************/ /*************** FUNCTIONS ****************************************/ + +/** \brief This function updates HARQ context according to dci + @param PHY_VARS_NR_UE ue context + @param nr_dci_info_extracted extracted information from dci + @param dlsch downlink context + @param ulsch uplink context + @param nr_tti_rx rx slot + @param tx_offset slot offset for tx + @returns none */ + +void get_dci_info_for_harq(PHY_VARS_NR_UE *ue, NR_DCI_INFO_EXTRACTED_t *nr_dci_info_extracted, + NR_UE_DLSCH_t **dlsch, NR_UE_ULSCH_t *ulsch, uint8_t nr_tti_rx, uint8_t tx_offset); + /** \brief This function configures uplink HARQ context @param PHY_VARS_NR_UE ue context @param gNB_id gNodeB identifier @@ -87,32 +96,26 @@ void config_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, uint8_t number_h void release_uplink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id); /** \brief This function stores slot for transmission in HARQ context - @param ulsch_harq uplink harq context + @param ulsch uplink context @param harq process identifier harq_pid @param slot_tx slot for transmission related to current downlink PDCCH @returns 0 none */ -void set_tx_harq_id(PHY_VARS_NR_UE *ue, int gNB_id, int harq_pid, int slot_tx); +void set_tx_harq_id(NR_UE_ULSCH_t *ulsch, int harq_pid, int slot_tx); /** \brief This function initialises context of an uplink HARQ process - @param ulsch_harq uplink harq context + @param ulsch uplink context @param harq process identifier harq_pid - @returns 0 none */ + @returns harq number for tx slot */ -int get_tx_harq_id(PHY_VARS_NR_UE *ue, int gNB_id, int slot_tx); - -/** \brief This function returns number of slots between current reception and related transmission - @param dci value - @returns slots number between reception and related transmission */ - -int get_dci_slot_rx_to_tx(int dci_index); +int get_tx_harq_id(NR_UE_ULSCH_t *ulsch, int slot_tx); /** \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, int ndi, nr_rnti_type_t rnti_type); +harq_result_t uplink_harq_process(NR_UE_ULSCH_t *ulsch, int harq_pid, int ndi, uint8_t rnti_type); /** \brief This function initialises downlink HARQ status @param pointer to downlink harq status @@ -145,7 +148,7 @@ void release_downlink_harq_process(PHY_VARS_NR_UE *ue, int gNB_id, int TB_id, in @param rnti_type type of rnti @returns retransmission or new transmission */ -harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dlsch, int harq_pid, int ndi, nr_rnti_type_t rnti_type); +harq_result_t downlink_harq_process(NR_DL_UE_HARQ_t *dlsch, int harq_pid, int ndi, uint8_t rnti_type); #undef EXTERN #undef INIT_VARIABLES_HARQ_NR_H diff --git a/openair1/SCHED_NR_UE/phy_frame_config_nr.c b/openair1/SCHED_NR_UE/phy_frame_config_nr.c index b2eeef6e26..fc1c459ba4 100644 --- a/openair1/SCHED_NR_UE/phy_frame_config_nr.c +++ b/openair1/SCHED_NR_UE/phy_frame_config_nr.c @@ -296,7 +296,7 @@ void free_tdd_configuration_nr(NR_DL_FRAME_PARMS *frame_parms) free(p_tdd_UL_DL_Configuration); } - for (int number_of_slot = 0; number_of_slot < MAX_NR_OF_SLOTS; number_of_slot++) { + for (int number_of_slot = 0; number_of_slot < NR_MAX_SLOTS_PER_FRAME; number_of_slot++) { frame_parms->tdd_uplink_nr[number_of_slot] = NR_TDD_DOWNLINK_SLOT; } } diff --git a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c index 14a5a56e69..1224cf5eb7 100644 --- a/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c +++ b/openair1/SCHED_NR_UE/phy_procedures_nr_ue.c @@ -1538,6 +1538,8 @@ void ue_prach_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_PRACH, VCD_FUNCTION_OUT); } +#endif + void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { int harq_pid; @@ -1561,11 +1563,13 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 uint8_t ri_status = 0; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_IN); - // get harq_pid from nr_tti_rx relationship - harq_pid = nr_subframe2harq_pid(&ue->frame_parms, - frame_tx, - nr_tti_tx); + /* reset harq for tx of current rx slot because it is sure that transmission has already been achieved for this slot */ + set_tx_harq_id(ue->ulsch[eNB_id], NR_MAX_HARQ_PROCESSES, proc->nr_tti_rx); + /* get harq pid related to this next tx slot */ + harq_pid = get_tx_harq_id(ue->ulsch[eNB_id], nr_tti_tx); + +#if 0 if (ue->mac_enabled == 1) { if ((ue->ulsch_Msg3_active[eNB_id] == 1) && @@ -1575,7 +1579,7 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 ue->ulsch[eNB_id]->harq_processes[harq_pid]->subframe_scheduling_flag = 1; if (ue->ulsch[eNB_id]->harq_processes[harq_pid]->round==0) - generate_ue_ulsch_params_from_rar(ue, + generate_ue_ulsch_params_from_rar(ue, proc, eNB_id); @@ -1588,8 +1592,9 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 Msg3_flag = 1; } else { - if (harq_pid==255) { - LOG_E(PHY,"[UE%d] Frame %d nr_tti_rx %d ulsch_decoding.c: FATAL ERROR: illegal harq_pid, returning\n", + /* no pusch has been scheduled on this transmit slot */ + if (harq_pid == NR_MAX_HARQ_PROCESSES) { + LOG_E(PHY,"[UE%d] Frame %d nr_tti_rx %d ulsch_decoding.c: FATAL ERROR: illegal harq_pid, returning\n", Mod_id,frame_tx, nr_tti_tx); //mac_xface->macphy_exit("Error in ulsch_decoding"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX, VCD_FUNCTION_OUT); @@ -1953,8 +1958,12 @@ void ue_ulsch_uespec_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8 VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_UE_TX_ULSCH_UESPEC,VCD_FUNCTION_OUT); +#endif + } +#if 0 + void ue_srs_procedures(PHY_VARS_NR_UE *ue,UE_nr_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t abstraction_flag) { diff --git a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c index b64c3ab114..9a2c0ec244 100644 --- a/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c +++ b/openair1/SCHED_NR_UE/pucch_uci_ue_nr.c @@ -250,6 +250,7 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ nb_symbols_total = initial_pucch_resource[initial_pucch_id].nrofSymbols; int N_CS = initial_pucch_resource[initial_pucch_id].nb_CS_indexes; + /* see TS 38213 Table 9.2.1-1: PUCCH resource sets before dedicated PUCCH resource configuration */ int RB_BWP_offset; if (initial_pucch_id == 15) { RB_BWP_offset = ue->systemInformationBlockType1_nr.N_BWP_SIZE/4; @@ -469,10 +470,10 @@ bool pucch_procedures_ue_nr(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_ frame_tx%1024, nr_tti_tx, N_UCI, pucch_payload, O_ACK, pucch_ack_payload, O_SR, sr_payload, csi_status, csi_payload); NR_TST_PHY_PRINTF("PUCCH ( format : %d ) ( modulation : %s ) ( nb prb : %d ) ( nb symbols total: %d ) ( nb symbols : %d ) ( max code rate*100 : %d ) ( starting_symbol_index : %d ) \n", - format, (Q_m == BITS_PER_SYMBOL_QPSK ? " QPSK " : " BPSK "), nb_of_prbs, nb_symbols_total, nb_symbols, max_code_rate, starting_symbol_index); + format, (Q_m == BITS_PER_SYMBOL_QPSK ? " QPSK " : " BPSK "), nb_of_prbs, nb_symbols_total, nb_symbols, max_code_rate, starting_symbol_index); NR_TST_PHY_PRINTF("PUCCH ( starting_prb : %d ) ( second_hop : %d ) ( m_0 : %d ) ( m_CS : %d ) ( time_domain_occ %d ) (occ_length : %d ) ( occ_Index : %d ) \n", - starting_prb, second_hop, m_0, m_CS, time_domain_occ, occ_length, occ_Index); + starting_prb, second_hop, m_0, m_CS, time_domain_occ, occ_length, occ_Index); /* Part - IV */ /* Generate PUCCH signal according to its format and parameters */ @@ -619,7 +620,6 @@ uint8_t get_downlink_ack(PHY_VARS_NR_UE *ue, uint8_t gNB_id, UE_nr_rxtx_proc_t number_of_code_word = 1; } - if (ue->n_connected_eNB > 1) { LOG_E(PHY,"PUCCH ACK feedback is not implemented for mutiple gNB cells : at line %d in function %s of file %s \n", LINE_FILE , __func__, FILE_NAME); return (0); diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/build/run_tests.sh b/openair1/SIMULATION/NR_UE_PHY/unit_tests/build/run_tests.sh index c5d208c659..a9bbdc22f7 100755 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/build/run_tests.sh +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/build/run_tests.sh @@ -28,9 +28,10 @@ # - checking output files with reference files. # ./run_test to build/run and check all tests # -b no build -# -r no run +# -e no execution # -c no check -# an alone specific test can be executed ./run_test test_name +# -m no run of meld +# an alone specific test can be executed ./run_tests test_name #---------------------------------------------------------------------------- # CONFIGURATION # files and directories @@ -48,8 +49,9 @@ BROWSER="firefox" BUILD_TEST="yes" CHECK_TEST="yes" -RUN_TEST="yes" +EXECUTE_TEST="yes" SINGLE_TEST="no" +RUN_MELD="yes" # for removing files REMOVE="rm -f" COMPARE="cmp" @@ -76,23 +78,28 @@ do echo "No build of unit test" BUILD_TEST="no" ;; - -r) - echo "No run of unit test" - RUN_TEST="no" + -e) + echo "No execution of unit test" + EXECUTE_TEST="no" ;; -c) echo "No check of unit test" CHECK_TEST="no" ;; + -m) + echo "No run of meld tool" + RUN_MELD="no" + ;; -h) echo "Option of run_test script" echo "-b : No Build of unit tests" echo "-c : No check for unit test" echo "-r : No run of unit tests" + echo "-m : No run of meld tool" exit BUILD_TEST="no" CHECK_TEST="no" - RUN_TEST="no" + EXECUTE_TEST="no" ;; *) for file in $tst_files @@ -109,7 +116,7 @@ do echo "Unknown parameter $1" BUILD_TEST="no" CHECK_TEST="no" - RUN_TEST="no" + EXECUTE_TEST="no" exit fi ;; @@ -121,15 +128,12 @@ done #-------------------------------------------------------------------------------------------- # RUN AND CHECK RESULTS -# compare reference log file to results file -# diff -s -d -a -q ./testlogs/*.txt ./reflog/*.txt -# compare $RESULTS_FILE to $REFERENCE_DIR/$RESULTS_FILE numberDisplayFilesDifferencies=0 let MAX_NUMBER_DISPLAY_FILES_DIFFERENCES=8 num_diff=0 -if [ $RUN_TEST == "yes" ] +if [ $EXECUTE_TEST == "yes" ] then mkdir $RESULT_DIR fi @@ -174,7 +178,7 @@ for file in $tst_files make $file fi - if [ $RUN_TEST == "yes" ] + if [ $EXECUTE_TEST == "yes" ] then echo "rm $RESULT_DIR/$RESULT_TEST_FILE" rm $RESULT_DIR/$RESULT_TEST_FILE @@ -195,20 +199,25 @@ for file in $tst_files if [ $? == 0 ] then - echo "Same file for $file" + echo "Test $file is PASS" + echo "Same logging file for $file" else - echo "Difference for scenario $file" + echo "Test $file is FAIL" + echo "Difference of logging file for scenario $file" let "num_diff=$num_diff + 1" - meld $RESULT_DIR/$RESULT_TEST_FILE $REFERENCE_DIR/$RESULT_TEST_FILE & - let "numberDisplayFilesDifferencies=$numberDisplayFilesDifferencies + 1" - echo "Meld number "$numberDisplayFilesDifferencies - if [ $numberDisplayFilesDifferencies = $MAX_NUMBER_DISPLAY_FILES_DIFFERENCES ] + if [ $RUN_MELD == "yes" ] then - echo "###### ERROR ###### ERROR ###### ERROR ###### ERROR ###### ERROR ###### ERROR ######" - echo "=> ERROR Test aborted because there are already $MAX_NUMBER_DISPLAY_FILES_DIFFERENCES detected files which are different" - break + meld $RESULT_DIR/$RESULT_TEST_FILE $REFERENCE_DIR/$RESULT_TEST_FILE & + let "numberDisplayFilesDifferencies=$numberDisplayFilesDifferencies + 1" + echo "Meld number "$numberDisplayFilesDifferencies + if [ $numberDisplayFilesDifferencies = $MAX_NUMBER_DISPLAY_FILES_DIFFERENCES ] + then + echo "###### ERROR ###### ERROR ###### ERROR ###### ERROR ###### ERROR ###### ERROR ######" + echo "=> ERROR Test aborted because there are already $MAX_NUMBER_DISPLAY_FILES_DIFFERENCES detected logging files which are different" + break + fi fi - fi + fi else echo "No reference file for test $file" fi diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/readme.txt b/openair1/SIMULATION/NR_UE_PHY/unit_tests/readme.txt index aab534da33..8309bf0f92 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/readme.txt +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/readme.txt @@ -19,7 +19,6 @@ * contact@openairinterface.org */ - File: /home/jacques/workspace/oai_openairinterface/openairinterface5g/openair1/SIMULATION/NR_UE_PHY/unit_tests/README.txt This directory contains testbenchs for 5G NR physical layers. @@ -33,37 +32,30 @@ Install tools: Build NR UE: - under openairinterface5g/cmake_targets/build --nrUE -Files -===== +Specific test files +==================== -pss_test.c: test for detection of primary synchronisation signal. - +pss_test.c: test for detection of primary synchronisation signal. sss_test.c: test for detection of secundary synchronisation signal. - pbch_test.c: test for decoding of packet braodcast channel. - srs_test.c: test of sounding reference signal. - frame_config_test.c : test of frame configurations (FDD/TDD). - harq_test.c : test of HARQ downlink and uplink. - pucch_uci_test : test of packed Uplink Control Channel Uplink Control Information - pss_util_test.c: common functions for running synchronisation tests. - pss_util_test.h: common headers for synchronisation tests. - input_buffer_test.h: it allows providing samples for pss test. How to build & run tests ======================== -Before building, oai environment should be set by entering under openairinterface5g "source oaienv". +Before building, oai environment should be set by entering under directory openairinterface5g "source oaienv". -A script allows to build, to run and to check all tests: +A script "run_tests.sh" allows to build, to run and to check all tests. +To run a complete non regression of unit tests, go under directory NR_UE_PHY/unit_tests/build and execute: +./run_tests.sh ->run_tests +This script "run_tests.sh" list all available unit tests. build is based on cmake tool. @@ -73,7 +65,10 @@ CMakeList.txt lists different build. How to build: in directory "oai_openairinterface/openairinterface5g/openair1/SIMULATION/NR_UE_PHY/unit_tests/build/", below commands should be entered: +First command to do: cmake CMakeList.txt -> it generates makefiles to build all projects. + +Then build of test: make pss_test -> build pss_test: detection of NR (Primary Synchronisation Channel - synchronisation of UE). make sss_test -> build sss_test: detection of NR SSS (Secundary Synchronisation Channel - second step for UE synchronisation). make pbch_test -> build pbch_test: decoding of NR PBCH (Packet Broadcast Channel -> UE read MIB Master Information Block which gives network parameters). @@ -83,6 +78,7 @@ make harq_test -> build harq_test: Hybrid Repeat Request Acknowledgment make pucch_uci_test -> build pucch_uci_test : Packet Uplink Control Channel / Uplink Control information : create UCI payload and select PUCCH formats and its parameters. make clean -> clean all projects. +And execution of tests: ./pss_test -> run NR PSS tests. ./sss_test -> run NR SSS tests. ./pbch_test -> run NR PBCH tests. @@ -94,8 +90,28 @@ make clean -> clean all projects. There is a script in build/run_test.sh which allows: - building/running/checking all tests -Checking consists in a comparaison of generated logging file at execution with a reference logging file which is stored under git for each test. +What is test result? +==================== + +Test verdict consists in a comparaison of generated logging file at execution with a reference logging file which is stored under git for each test. By default, tool "meld" is open each time there is a difference between reference file and logging file. +It is possible to disable execution of meld with option -m. + +Build/execute only one test: +=========================== + +The script "run_tests.sh" has different options: +"-b : No Build of unit tests" +"-c : No check for unit test" +"-e : No execution of unit tests" +"-m : No run of meld tool" + +./run_tests.sh -> run all unit tests (build, execute and compare for each test) +./run_tests.sh -m -> run all unit tests but meld is not used (verdict is based on system command "cmp"). +./run_tests.sh -b -c -r -m -> list all available unit tests +./run_tests.sh pss_test -> run only one test (here it is pss_test). +./run_tests.sh -c -e -m pss_test -> build only one test +./run_tests.sh -m pss_test -> run only one test but without execution of meld Which processing can be tuned? ============================= @@ -121,7 +137,6 @@ Status ====== NR synchronisation tests run successfully with default parameters. - Warning: Tests of PSS NR with decimation (based on FIR or CIC filter) does not run successfully at the moment. diff --git a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c index c2f61ddb92..ab99841668 100644 --- a/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c +++ b/openair1/SIMULATION/NR_UE_PHY/unit_tests/src/harq_test.c @@ -56,7 +56,7 @@ int test_harq_uplink(PHY_VARS_NR_UE *phy_vars_ue) int gNB_id = 0; int harq_pid = 0; int ndi = 1; - nr_rnti_type_t rnti_type = C_RNTI_NR; + uint8_t rnti_type = _C_RNTI_; int number_steps = 5; printf("\nHARQ Uplink \n"); @@ -113,7 +113,7 @@ int test_harq_downlink(PHY_VARS_NR_UE *phy_vars_ue) int gNB_id = 0; int harq_pid = 0; int ndi = 1; - nr_rnti_type_t rnti_type = C_RNTI_NR; + uint8_t rnti_type = _C_RNTI_; int number_steps = 5; int thread_number = 0; int TB_identifier = 0; diff --git a/targets/RT/USER/nr-ue.c b/targets/RT/USER/nr-ue.c index 7ffaaffb9f..b1d0d2346e 100644 --- a/targets/RT/USER/nr-ue.c +++ b/targets/RT/USER/nr-ue.c @@ -647,33 +647,9 @@ static void *UE_thread_rxn_txnp4(void *arg) { pickTime(current); // updateTimes(proc->gotIQs, &t2, 10000, "Delay to wake up UE_Thread_Rx (case 2)"); -#ifndef NO_RAT_NR // Process Rx data for one sub-frame if (slot_select_nr(&UE->frame_parms, proc->frame_tx, proc->nr_tti_tx) & NR_DOWNLINK_SLOT) { -#else - // Process Rx data for one sub-frame - lte_subframe_t sf_type = subframe_select( &UE->frame_parms, proc->subframe_rx); - if ((sf_type == SF_DL) || - (UE->frame_parms.frame_type == FDD) || - (sf_type == SF_S)) { - if (UE->frame_parms.frame_type == TDD) { - LOG_D(PHY, "%s,TDD%d,%s: calling UE_RX\n", - threadname, - UE->frame_parms.tdd_config, - (sf_type==SF_DL? "SF_DL" : - (sf_type==SF_UL? "SF_UL" : - (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); - } else { - LOG_D(PHY, "%s,%s,%s: calling UE_RX\n", - threadname, - (UE->frame_parms.frame_type==FDD? "FDD": - (UE->frame_parms.frame_type==TDD? "TDD":"UNKNOWN_DUPLEX_MODE")), - (sf_type==SF_DL? "SF_DL" : - (sf_type==SF_UL? "SF_UL" : - (sf_type==SF_S ? "SF_S" : "UNKNOWN_SF_TYPE")))); - } -#endif #ifdef UE_SLOT_PARALLELISATION phy_procedures_slot_parallelization_UE_RX( UE, proc, 0, 0, 1, UE->mode, no_relay, NULL ); #else @@ -702,8 +678,6 @@ static void *UE_thread_rxn_txnp4(void *arg) { UE->if_inst->ul_indication(&UE->ul_indication); } - - #ifdef NEW_MAC ret = mac_xface->ue_scheduler(UE->Mod_id, proc->frame_rx, @@ -761,10 +735,10 @@ static void *UE_thread_rxn_txnp4(void *arg) { #else if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_UL) || (UE->frame_parms.frame_type == FDD) ) +#endif if (UE->mode != loop_through_memory) phy_procedures_UE_TX(UE,proc,0,0,UE->mode,no_relay); #endif -#endif #if 0 if ((subframe_select( &UE->frame_parms, proc->subframe_tx) == SF_S) && (UE->frame_parms.frame_type == TDD))