From e8834e9620d255f9ebcfd0e7485d413f0e47d7d7 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 14 Feb 2020 05:44:12 +0100 Subject: [PATCH] added FAPI interfaces int gNB prach receiver functions (rx_nr_prach,rx_nr_prach_ru) and in indication to MAC. --- executables/nr-gnb.c | 6 +- .../nfapi/public_inc/nfapi_nr_interface_scf.h | 2 +- openair1/PHY/NR_TRANSPORT/nr_prach.c | 494 +++++++++--------- openair1/PHY/NR_TRANSPORT/nr_transport.h | 2 + .../PHY/NR_TRANSPORT/nr_transport_proto.h | 1 + openair1/PHY/defs_RU.h | 4 +- openair1/PHY/defs_gNB.h | 7 +- openair1/SCHED_NR/nr_prach_procedures.c | 71 ++- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c | 15 +- openair2/LAYER2/NR_MAC_gNB/mac_proto.h | 6 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.c | 29 +- openair2/NR_PHY_INTERFACE/NR_IF_Module.h | 5 +- 12 files changed, 322 insertions(+), 320 deletions(-) diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c index dedee9b651..7f85cabeb7 100644 --- a/executables/nr-gnb.c +++ b/executables/nr-gnb.c @@ -165,14 +165,14 @@ static inline int rxtx(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, int frame_t if (gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus|| gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs || gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs || - gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles || + gNB->UL_INFO.rach_ind.number_of_pdus || gNB->UL_INFO.cqi_ind.number_of_cqis ) { - LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d preambles:%05d:%d cqis:%d] RX:%04d%d TX:%04d%d \n", + LOG_D(PHY, "UL_info[rx_ind:%05d:%d harqs:%05d:%d crcs:%05d:%d rach_pdus:%0d.%d:%d cqis:%d] RX:%04d%d TX:%04d%d \n", NFAPI_SFNSF2DEC(gNB->UL_INFO.rx_ind.sfn_sf), gNB->UL_INFO.rx_ind.rx_indication_body.number_of_pdus, NFAPI_SFNSF2DEC(gNB->UL_INFO.harq_ind.sfn_sf), gNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs, NFAPI_SFNSF2DEC(gNB->UL_INFO.crc_ind.sfn_sf), gNB->UL_INFO.crc_ind.crc_indication_body.number_of_crcs, - NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles, + gNB->UL_INFO.rach_ind.sfn, gNB->UL_INFO.rach_ind.slot,gNB->UL_INFO.rach_ind.number_of_pdus, gNB->UL_INFO.cqi_ind.number_of_cqis, frame_rx, slot_rx, frame_tx, slot_tx); diff --git a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h index 8233be587c..3be4f03dde 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface_scf.h @@ -85,7 +85,7 @@ typedef enum { NFAPI_NR_PHY_MSG_TYPE_CRC_INDICATION= 0X86, NFAPI_NR_PHY_MSG_TYPE_UCI_INDICATION= 0X87, NFAPI_NR_PHY_MSG_TYPE_SRS_INDICATION= 0X88, - NFAPI_NR_PHY_MSG_TYPE_PACH_INDICATION= 0X89 + NFAPI_NR_PHY_MSG_TYPE_RACH_INDICATION= 0X89 //RESERVED 0X8a ~ 0xff } nfapi_nr_phy_msg_type_e; diff --git a/openair1/PHY/NR_TRANSPORT/nr_prach.c b/openair1/PHY/NR_TRANSPORT/nr_prach.c index 8bcd3f2662..77a1ac5229 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_prach.c +++ b/openair1/PHY/NR_TRANSPORT/nr_prach.c @@ -50,22 +50,28 @@ extern uint16_t nr_du[838]; extern int16_t nr_ru[2*839]; void rx_nr_prach_ru(RU_t *ru, + nfapi_nr_prach_pdu_t *prach_pdu, int frame, - int subframe) { + int slot) { AssertFatal(ru!=NULL,"ru is null\n"); int16_t **rxsigF=NULL; - NR_DL_FRAME_PARMS *fp=ru->nr_frame_parms; - int16_t prach_ConfigIndex = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; + NR_DL_FRAME_PARMS *fp=&ru->frame_parms; + + int frame_type = ru->config.cell_config.frame_duplex_type.value; + int16_t *prach[ru->nb_rx]; - uint8_t prach_fmt = get_nr_prach_fmt(prach_ConfigIndex,fp->frame_type,fp->freq_range); + uint8_t prach_fmt = prach_pdu->prach_format; + int prach_sequence_length = ru->config.prach_config.prach_sequence_length.value; + + int msg1_frequencystart = ru->config.prach_config.num_prach_fd_occasions_list[0].k1.value; rxsigF = ru->prach_rxsigF; AssertFatal(ru->if_south == LOCAL_RF,"we shouldn't call this if if_south != LOCAL_RF\n"); for (int aa=0; aanb_rx; aa++) - prach[aa] = (int16_t*)&ru->common.rxdata[aa][(subframe*fp->samples_per_slot<<1)-ru->N_TA_offset]; + prach[aa] = (int16_t*)&ru->common.rxdata[aa][(slot*fp->samples_per_slot)-ru->N_TA_offset]; @@ -73,84 +79,88 @@ void rx_nr_prach_ru(RU_t *ru, int Ncp; int16_t *prach2; - - switch (prach_fmt) { - case 0: - Ncp = 3168; - break; - - case 1: - Ncp = 21024; - break; - - case 2: - Ncp = 4688; - break; - - case 3: - Ncp = 3168; - break; - - case 0xa1: - Ncp = 288/(1<N_RB_UL, ru->nb_rx, Ncp); + LOG_D(PHY,"rx_prach: Doing PRACH FFT for nb_rx:%d Ncp:%d\n",ru->nb_rx, Ncp); } AssertFatal(mu==1,"only 30 kHz SCS handled for now\n"); // Note: Assumes PUSCH SCS @ 30 kHz, take values for formats 0-2 and adjust for others below int kbar = 1; int K = 24; - if (prach_fmt == 3) { + if (prach_sequence_length == 0 && prach_fmt == 3) { K=4; kbar=10; } - else if (prach_fmt > 3) { + else if (prach_sequence_length == 1) { // Note: Assumes that PRACH SCS is same as PUSCH SCS K=1; kbar=2; } - int n_ra_prb = fp->prach_config_common.prach_ConfigInfo.msg1_frequencystart; + int n_ra_prb = msg1_frequencystart; int k = (12*n_ra_prb) - 6*fp->N_RB_UL; int N_ZC = (prach_fmt<4)?839:139; @@ -174,169 +184,178 @@ void rx_nr_prach_ru(RU_t *ru, //40 MHz @ 61.44 Ms/s //50 MHz @ 61.44 Ms/s prach2 = prach[aa] + (Ncp<<2); - if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) - dft49152(prach2,rxsigF[aa],1); - if (prach_fmt == 1 || prach_fmt == 2) { - dft49152(prach2+98304,rxsigF[aa]+98304,1); - reps++; + if (prach_sequence_length == 0) { + if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) + dft49152(prach2,rxsigF[aa],1); + if (prach_fmt == 1 || prach_fmt == 2) { + dft49152(prach2+98304,rxsigF[aa]+98304,1); + reps++; + } + if (prach_fmt == 2) { + dft49152(prach2+(98304*2),rxsigF[aa]+(98304*2),1); + dft49152(prach2+(98304*3),rxsigF[aa]+(98304*3),1); + reps+=2; + } + if (prach_fmt == 3) { + for (int i=0;i<4;i++) dft12288(prach2+(i*12288*2),rxsigF[aa]+(i*12288*2),1); + reps=4; + } } - if (prach_fmt == 2) { - dft49152(prach2+(98304*2),rxsigF[aa]+(98304*2),1); - dft49152(prach2+(98304*3),rxsigF[aa]+(98304*3),1); - reps+=2; - } - if (prach_fmt == 3) { - for (int i=0;i<4;i++) dft12288(prach2+(i*12288*2),rxsigF[aa]+(i*12288*2),1); - reps=4; - } - if (prach_fmt >3) { + else { dft2048(prach2,rxsigF[aa],1); - if (prach_fmt != 0xc0) { + if (prach_fmt != 7) { // !=C0 dft2048(prach2+4096,rxsigF[aa]+4096,1); reps++; } - } - if (prach_fmt == 0xa2 || prach_fmt == 0xa3 || prach_fmt == 0xb2 || prach_fmt == 0xb3 || prach_fmt == 0xb4 || prach_fmt == 0xc2) { + if (prach_fmt == 1 || prach_fmt == 2 || prach_fmt == 4 || prach_fmt == 5 || prach_fmt == 6 || prach_fmt == 8) { dft2048(prach2+4096*2,rxsigF[aa]+4096*2,1); dft2048(prach2+4096*3,rxsigF[aa]+4096*3,1); reps+=2; - } - if (prach_fmt == 0xa3 || prach_fmt == 0xb3 || prach_fmt == 0xB4) { - dft2048(prach2+4096*4,rxsigF[aa]+4096*4,1); - dft2048(prach2+4096*5,rxsigF[aa]+4096*5,1); - reps+=2; - } - if (prach_fmt == 0xB4) { - for (int i=6;i<11;i++) dft2048(prach2+(4096*i),rxsigF[aa]+(4096*i),1); + } + if (prach_fmt == 2 || prach_fmt == 5 || prach_fmt == 6) { + dft2048(prach2+4096*4,rxsigF[aa]+4096*4,1); + dft2048(prach2+4096*5,rxsigF[aa]+4096*5,1); + reps+=2; + } + if (prach_fmt == 6) { + for (int i=6;i<11;i++) dft2048(prach2+(4096*i),rxsigF[aa]+(4096*i),1); reps+=6; + } } } else { // 40 MHz @ 46.08 Ms/s - prach2 = prach[aa] + (3*Ncp); - AssertFatal(fp->N_RB_UL <= 107,"cannot do 108..136 PRBs with 3/4 sampling\n"); - if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) { - dft36864(prach2,rxsigF[aa],1); - reps++; - } - if (prach_fmt == 1 || prach_fmt == 2) { - dft36864(prach2+73728,rxsigF[aa]+73728,1); - reps++; - } - if (prach_fmt == 2) { - dft36864(prach2+(73728*2),rxsigF[aa]+(73728*2),1); - dft36864(prach2+(73728*3),rxsigF[aa]+(73728*3),1); - reps+=2; - } - if (prach_fmt == 3) { - for (int i=0;i<4;i++) dft9216(prach2+(i*9216*2),rxsigF[aa]+(i*9216*2),1); - reps=4; - } - if (prach_fmt >3) { + if (prach_sequence_length == 0) { + prach2 = prach[aa] + (3*Ncp); + AssertFatal(fp->N_RB_UL <= 107,"cannot do 108..136 PRBs with 3/4 sampling\n"); + if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) { + dft36864(prach2,rxsigF[aa],1); + reps++; + } + if (prach_fmt == 1 || prach_fmt == 2) { + dft36864(prach2+73728,rxsigF[aa]+73728,1); + reps++; + } + if (prach_fmt == 2) { + dft36864(prach2+(73728*2),rxsigF[aa]+(73728*2),1); + dft36864(prach2+(73728*3),rxsigF[aa]+(73728*3),1); + reps+=2; + } + if (prach_fmt == 3) { + for (int i=0;i<4;i++) dft9216(prach2+(i*9216*2),rxsigF[aa]+(i*9216*2),1); + reps=4; + } + } else { dft1536(prach2,rxsigF[aa],1); if (prach_fmt != 0xc0) { dft1536(prach2+3072,rxsigF[aa]+3072,1); reps++; } - } - if (prach_fmt == 0xa2 || prach_fmt == 0xa3 || prach_fmt == 0xb2 || prach_fmt == 0xb3 || prach_fmt == 0xb4 || prach_fmt == 0xc2) { - dft1536(prach2+3072*2,rxsigF[aa]+3072*2,1); - dft1536(prach2+3072*3,rxsigF[aa]+3072*3,1); - reps+=2; - } - if (prach_fmt == 0xa3 || prach_fmt == 0xb3 || prach_fmt == 0xB4) { - dft1536(prach2+3072*4,rxsigF[aa]+3072*4,1); - dft1536(prach2+3072*5,rxsigF[aa]+3072*5,1); - reps+=2; - } - if (prach_fmt == 0xB4) { - for (int i=6;i<11;i++) dft1536(prach2+(3072*i),rxsigF[aa]+(3072*i),1); - reps+=6; - } - } - } + + if (prach_fmt == 0xa2 || prach_fmt == 0xa3 || prach_fmt == 0xb2 || prach_fmt == 0xb3 || prach_fmt == 0xb4 || prach_fmt == 0xc2) { + dft1536(prach2+3072*2,rxsigF[aa]+3072*2,1); + dft1536(prach2+3072*3,rxsigF[aa]+3072*3,1); + reps+=2; + } + if (prach_fmt == 0xa3 || prach_fmt == 0xb3 || prach_fmt == 0xB4) { + dft1536(prach2+3072*4,rxsigF[aa]+3072*4,1); + dft1536(prach2+3072*5,rxsigF[aa]+3072*5,1); + reps+=2; + } + if (prach_fmt == 0xB4) { + for (int i=6;i<11;i++) dft1536(prach2+(3072*i),rxsigF[aa]+(3072*i),1); + reps+=6; + } + } // short format + } // 3/4 sampling + } // <=50 MHz BW else if (fp->N_RB_UL <= 273) { if (fp->threequarter_fs==0) { prach2 = prach[aa] + (Ncp<<3); dftlen=98304; //80,90,100 MHz @ 122.88 Ms/s - if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) - dft98304(prach2,rxsigF[aa],1); - if (prach_fmt == 1 || prach_fmt == 2) { - dft98304(prach2+196608,rxsigF[aa]+196608,1); - reps++; + + if (prach_sequence_length == 0) { + if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) + dft98304(prach2,rxsigF[aa],1); + if (prach_fmt == 1 || prach_fmt == 2) { + dft98304(prach2+196608,rxsigF[aa]+196608,1); + reps++; + } + if (prach_fmt == 2) { + dft98304(prach2+196608*2,rxsigF[aa]+196608*2,1); + dft98304(prach2+(196608*3),rxsigF[aa]+(196608*3),1); + reps+=2; + } + if (prach_fmt == 3) { + for (int i=0;i<4;i++) dft24576(prach2+(i*2*24576),rxsigF[aa]+(i*2*24576),1); + reps=4; + dftlen=24576; + } } - if (prach_fmt == 2) { - dft98304(prach2+196608*2,rxsigF[aa]+196608*2,1); - dft98304(prach2+(196608*3),rxsigF[aa]+(196608*3),1); - reps+=2; - } - if (prach_fmt == 3) { - for (int i=0;i<4;i++) dft24576(prach2+(i*2*24576),rxsigF[aa]+(i*2*24576),1); - reps=4; - dftlen=24576; - } - if (prach_fmt >3) { + else { dftlen=4096; dft4096(prach2,rxsigF[aa],1); - if (prach_fmt != 0xc0) { + if (prach_fmt != 7) { //!=C0 dft4096(prach2+8192,rxsigF[aa]+8192,1); reps++; } - } - if (prach_fmt == 0xa2 || prach_fmt == 0xa3 || prach_fmt == 0xb2 || prach_fmt == 0xb3 || prach_fmt == 0xb4 || prach_fmt == 0xc2) { - dft4096(prach2+8192*2,rxsigF[aa]+8192*2,1); - dft4096(prach2+8192*3,rxsigF[aa]+8192*3,1); - reps+=2; - } - if (prach_fmt == 0xa3 || prach_fmt == 0xb3 || prach_fmt == 0xB4) { - dft4096(prach2+8192*4,rxsigF[aa]+8192*4,1); - dft4096(prach2+8192*5,rxsigF[aa]+8192*5,1); - reps+=2; - } - if (prach_fmt == 0xB4) { - for (int i=6;i<11;i++) dft4096(prach2+(8192*i),rxsigF[aa]+(8192*i),1); - reps+=6; + + if (prach_fmt == 1 || prach_fmt == 2 || prach_fmt == 4 || prach_fmt == 5 || prach_fmt == 6 || prach_fmt == 8) { + dft4096(prach2+8192*2,rxsigF[aa]+8192*2,1); + dft4096(prach2+8192*3,rxsigF[aa]+8192*3,1); + reps+=2; + } + if (prach_fmt == 2 || prach_fmt == 5 || prach_fmt == 6) { + dft4096(prach2+8192*4,rxsigF[aa]+8192*4,1); + dft4096(prach2+8192*5,rxsigF[aa]+8192*5,1); + reps+=2; + } + if (prach_fmt == 6) { + for (int i=6;i<11;i++) dft4096(prach2+(8192*i),rxsigF[aa]+(8192*i),1); + reps+=6; + } } } else { AssertFatal(fp->N_RB_UL <= 217,"cannot do more than 217 PRBs with 3/4 sampling\n"); prach2 = prach[aa] + (6*Ncp); // 80 MHz @ 92.16 Ms/s dftlen=73728; - if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) { - dft73728(prach2,rxsigF[aa],1); - reps++; - } - if (prach_fmt == 1 || prach_fmt == 2) { - dft73728(prach2+(2*73728),rxsigF[aa]+(2*73728),1); - reps++; - } - if (prach_fmt == 3) { - for (int i=0;i<4;i++) dft18432(prach2+(i*2*18432),rxsigF[aa]+(i*2*18432),1); - reps=4; - dftlen=18432; - } - - if (prach_fmt >3) { + if (prach_sequence_length == 0) { + if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) { + dft73728(prach2,rxsigF[aa],1); + reps++; + } + if (prach_fmt == 1 || prach_fmt == 2) { + dft73728(prach2+(2*73728),rxsigF[aa]+(2*73728),1); + reps++; + } + if (prach_fmt == 3) { + for (int i=0;i<4;i++) dft18432(prach2+(i*2*18432),rxsigF[aa]+(i*2*18432),1); + reps=4; + dftlen=18432; + } + } else { dftlen=3072; dft3072(prach2,rxsigF[aa],1); - if (prach_fmt != 0xc0) { + if (prach_fmt != 7) { //!=C0 dft3072(prach2+6144,rxsigF[aa]+6144,1); reps++; } - } - if (prach_fmt == 0xa2 || prach_fmt == 0xa3 || prach_fmt == 0xb2 || prach_fmt == 0xb3 || prach_fmt == 0xb4 || prach_fmt == 0xc2) { - dft3072(prach2+6144*2,rxsigF[aa]+6144*2,1); - dft3072(prach2+6144*3,rxsigF[aa]+6144*3,1); - reps+=2; - } - if (prach_fmt == 0xa3 || prach_fmt == 0xb3 || prach_fmt == 0xB4) { - dft3072(prach2+6144*4,rxsigF[aa]+6144*4,1); - dft3072(prach2+6144*5,rxsigF[aa]+6144*5,1); - reps+=2; - } - if (prach_fmt == 0xB4) { - for (int i=6;i<11;i++) dft3072(prach2+(6144*i),rxsigF[aa]+(6144*i),1); - reps+=6; + + if (prach_fmt == 1 || prach_fmt == 2 || prach_fmt == 4 || prach_fmt == 5 || prach_fmt == 6 || prach_fmt == 8) { + dft3072(prach2+6144*2,rxsigF[aa]+6144*2,1); + dft3072(prach2+6144*3,rxsigF[aa]+6144*3,1); + reps+=2; + } + if (prach_fmt == 2 || prach_fmt == 5 || prach_fmt == 6) { + dft3072(prach2+6144*4,rxsigF[aa]+6144*4,1); + dft3072(prach2+6144*5,rxsigF[aa]+6144*5,1); + reps+=2; + } + if (prach_fmt == 6) { + for (int i=6;i<11;i++) dft3072(prach2+(6144*i),rxsigF[aa]+(6144*i),1); + reps+=6; + } } } } @@ -359,6 +378,7 @@ void rx_nr_prach_ru(RU_t *ru, } void rx_nr_prach(PHY_VARS_gNB *gNB, + nfapi_nr_prach_pdu_t *prach_pdu, int frame, int subframe, uint16_t *max_preamble, @@ -369,11 +389,12 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, int i; + nfapi_nr_prach_config_t *cfg=&gNB->gNB_config.prach_config; NR_DL_FRAME_PARMS *fp; + lte_frame_type_t frame_type; uint16_t rootSequenceIndex; - uint8_t prach_ConfigIndex; - uint8_t Ncs_config; + int numrootSequenceIndex; uint8_t restricted_set; uint8_t n_ra_prb; int16_t *prachF=NULL; @@ -403,63 +424,47 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, int16_t prach_ifft_tmp[2048*2] __attribute__((aligned(32))); int32_t *prach_ifft=(int32_t*)NULL; - nr_frequency_range_e freq_range; - - AssertFatal(gNB!=NULL,"Can only be called from gNB\n"); - fp = &gNB->frame_parms; - nb_rx = fp->nb_antennas_rx; - - frame_type = fp->frame_type; - freq_range = fp->freq_range; - rootSequenceIndex = fp->prach_config_common.rootSequenceIndex; - prach_ConfigIndex = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex; - Ncs_config = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig; - restricted_set = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag; - - - uint8_t prach_fmt = get_nr_prach_fmt(prach_ConfigIndex,frame_type,freq_range); - uint16_t N_ZC = (prach_fmt <4)?839:139; AssertFatal(gNB!=NULL,"gNB is null\n"); + fp = &gNB->frame_parms; + + nb_rx = gNB->gNB_config.carrier_config.num_rx_ant.value; + + frame_type = gNB->gNB_config.cell_config.frame_duplex_type.value; + rootSequenceIndex = cfg->num_prach_fd_occasions_list[0].prach_root_sequence_index.value; + numrootSequenceIndex = cfg->num_prach_fd_occasions_list[0].num_root_sequences.value; + NCS = cfg->num_prach_fd_occasions_list[0].prach_zero_corr_conf.value; + int prach_sequence_length = cfg->prach_sequence_length.value; + + int msg1_frequencystart = cfg->num_prach_fd_occasions_list[0].k1.value; + // int num_unused_root_sequences = cfg->num_prach_fd_occasions_list[0].num_unused_root_sequences.value; + // cfg->num_prach_fd_occasions_list[0].unused_root_sequences_list + + restricted_set = cfg->restricted_set_config.value; + + AssertFatal(prach_sequence_length == 1, "no support yet for long prachSequenceLength\n"); + + + uint8_t prach_fmt = prach_pdu->prach_format; + uint16_t N_ZC = (prach_sequence_length==0)?839:139; + + + prach_ifft = gNB->prach_vars.prach_ifft; prachF = gNB->prach_vars.prachF; if (LOG_DEBUGFLAG(PRACH)){ - if ((frame&1023) < 20) LOG_D(PHY,"PRACH (gNB) : running rx_prach for subframe %d, msg1_frequencystart %d, prach_ConfigIndex %d , rootSequenceIndex %d\n", subframe,fp->prach_config_common.prach_ConfigInfo.msg1_frequencystart,prach_ConfigIndex,rootSequenceIndex); + if ((frame&1023) < 20) LOG_D(PHY,"PRACH (gNB) : running rx_prach for subframe %d, msg1_frequencystart %d, rootSequenceIndex %d\n", subframe,msg1_frequencystart,rootSequenceIndex); } - - int restricted_Type = 0; //this is hardcoded ('0' for restricted_TypeA; and '1' for restricted_TypeB). FIXME - if (prach_fmt<3){ - if (restricted_set == 0) { - NCS = NCS_unrestricted_delta_f_RA_125[Ncs_config]; - } else { - if (restricted_Type == 0) NCS = NCS_restricted_TypeA_delta_f_RA_125[Ncs_config]; // for TypeA, this is hardcoded. FIXME - if (restricted_Type == 1) NCS = NCS_restricted_TypeB_delta_f_RA_125[Ncs_config]; // for TypeB, this is hardcoded. FIXME - } - } - if (prach_fmt==3){ - if (restricted_set == 0) { - NCS = NCS_unrestricted_delta_f_RA_5[Ncs_config]; - } else { - if (restricted_Type == 0) NCS = NCS_restricted_TypeA_delta_f_RA_5[Ncs_config]; // for TypeA, this is hardcoded. FIXME - if (restricted_Type == 1) NCS = NCS_restricted_TypeB_delta_f_RA_5[Ncs_config]; // for TypeB, this is hardcoded. FIXME - } - } - if (prach_fmt>3){ - NCS = NCS_unrestricted_delta_f_RA_15[Ncs_config]; - } - - AssertFatal(NCS!=99,"NCS has not been set\n"); - - if (gNB) start_meas(&gNB->rx_prach); + start_meas(&gNB->rx_prach); - prach_root_sequence_map = (prach_fmt<4) ? prach_root_sequence_map_0_3 : prach_root_sequence_map_abc; + prach_root_sequence_map = (cfg->prach_sequence_length.value==0) ? prach_root_sequence_map_0_3 : prach_root_sequence_map_abc; // PDP is oversampled, e.g. 1024 sample instead of 839 // Adapt the NCS (zero-correlation zones) with oversampling factor e.g. 1024/839 @@ -562,8 +567,8 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, // Compute DFT of RX signal (conjugate input, results in conjugate output) for each new rootSequenceIndex if (LOG_DEBUGFLAG(PRACH)) { int en = dB_fixed(signal_energy((int32_t*)&rxsigF[0][0],840)); - if (en>60) LOG_I(PHY,"frame %d, subframe %d : preamble index %d, NCS %d, NCS_config %d, N_ZC/NCS %d: offset %d, preamble shift %d , en %d)\n", - frame,subframe,preamble_index,NCS,Ncs_config,N_ZC/NCS,preamble_offset,preamble_shift,en); + if (en>60) LOG_I(PHY,"frame %d, subframe %d : preamble index %d, NCS %d, N_ZC/NCS %d: offset %d, preamble shift %d , en %d)\n", + frame,subframe,preamble_index,NCS,N_ZC/NCS,preamble_offset,preamble_shift,en); } if (new_dft == 1) { @@ -644,12 +649,11 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, // max_preamble_delay * ( (2048/2^mu*(fs/30.72M)) / 256 ) / fs = TA * 16 * 64 / 2^mu * Tc uint16_t *TA = max_preamble_delay; int mu = fp->numerology_index; - if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) - *TA = *TA*3*(1< 3) - *TA = *TA/2; + if (cfg->prach_sequence_length.value==0) { + if (prach_fmt == 0 || prach_fmt == 1 || prach_fmt == 2) *TA = *TA*3*(1<rx_prach); + stop_meas(&gNB->rx_prach); } diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport.h b/openair1/PHY/NR_TRANSPORT/nr_transport.h index be73875058..bce0b62f8c 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport.h @@ -112,6 +112,7 @@ NR_gNB_DLSCH_t *new_gNB_dlsch(NR_DL_FRAME_PARMS *frame_parms, uint16_t N_RB); void rx_nr_prach(PHY_VARS_gNB *gNB, + nfapi_nr_prach_pdu_t *prach_pdu, int frame, int subframe, uint16_t *max_preamble, @@ -120,6 +121,7 @@ void rx_nr_prach(PHY_VARS_gNB *gNB, ); void rx_nr_prach_ru(RU_t *ru, + nfapi_nr_prach_pdu_t *prach_pdu, int frame, int subframe); diff --git a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h index e8216ea004..b34bd12d75 100644 --- a/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h +++ b/openair1/PHY/NR_TRANSPORT/nr_transport_proto.h @@ -214,6 +214,7 @@ uint32_t nr_get_code_rate_ul(uint8_t Imcs, uint8_t table_idx); uint32_t nr_get_code_rate_dl(uint8_t Imcs, uint8_t table_idx); void rx_nr_prach(PHY_VARS_gNB *gNB, + nfapi_nr_prach_pdu_t *prach_pdu, int frame, int subframe, uint16_t *max_preamble, diff --git a/openair1/PHY/defs_RU.h b/openair1/PHY/defs_RU.h index 10496ced20..6d2b7db638 100644 --- a/openair1/PHY/defs_RU.h +++ b/openair1/PHY/defs_RU.h @@ -38,7 +38,7 @@ #include "openairinterface5g_limits.h" #include "PHY/TOOLS/time_meas.h" #include "defs_common.h" - +#include "nfapi_nr_interface_scf.h" #define MAX_BANDS_PER_RRU 4 #define MAX_RRU_CONFIG_SIZE 1024 @@ -480,6 +480,8 @@ typedef struct RU_t_s { int att_tx; /// flag to indicate precoding operation in RU int do_precoding; + /// FAPI confiuration + nfapi_nr_config_request_scf_t config; /// Frame parameters struct LTE_DL_FRAME_PARMS *frame_parms; struct NR_DL_FRAME_PARMS *nr_frame_parms; diff --git a/openair1/PHY/defs_gNB.h b/openair1/PHY/defs_gNB.h index f291261336..d7dde57a11 100644 --- a/openair1/PHY/defs_gNB.h +++ b/openair1/PHY/defs_gNB.h @@ -582,6 +582,9 @@ typedef struct { int prach_I0; } PHY_MEASUREMENTS_gNB; +#define MAX_NUM_NR_RX_RACH_PDUS 4 +#define MAX_NUM_NR_RX_PRACH_PREAMBLES 4 + /// Top-level PHY Data Structure for gNB typedef struct PHY_VARS_gNB_s { /// Module ID indicator for this instance @@ -620,7 +623,9 @@ typedef struct PHY_VARS_gNB_s { /// NFAPI CQI information (raw component) nfapi_cqi_indication_raw_pdu_t cqi_raw_pdu_list[NFAPI_CQI_IND_MAX_PDU]; /// NFAPI PRACH information - nfapi_preamble_pdu_t preamble_list[MAX_NUM_RX_PRACH_PREAMBLES]; + nfapi_nr_prach_indication_pdu_t prach_pdu_indication_list[MAX_NUM_NR_RX_RACH_PDUS]; + /// NFAPI PRACH information + nfapi_nr_prach_indication_preamble_t preamble_list[MAX_NUM_NR_RX_PRACH_PREAMBLES]; //Sched_Rsp_t Sched_INFO; nfapi_nr_ul_tti_request_t UL_tti_req; diff --git a/openair1/SCHED_NR/nr_prach_procedures.c b/openair1/SCHED_NR/nr_prach_procedures.c index b9a8ba94f1..7c1c9f890a 100644 --- a/openair1/SCHED_NR/nr_prach_procedures.c +++ b/openair1/SCHED_NR/nr_prach_procedures.c @@ -52,12 +52,14 @@ extern uint32_t nfapi_mode; extern int oai_nfapi_nr_rach_ind(nfapi_rach_indication_t *rach_ind); -void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int subframe) { +void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int slot, + nfapi_nr_prach_pdu_t *prach_pdu) { + uint16_t max_preamble[4],max_preamble_energy[4],max_preamble_delay[4]; uint16_t i; - gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles=0; + gNB->UL_INFO.rach_ind.number_of_pdus=0; RU_t *ru; int aa=0; @@ -75,16 +77,18 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int subframe) { } } + rx_nr_prach(gNB, + prach_pdu, frame, - subframe, + slot, &max_preamble[0], &max_preamble_energy[0], &max_preamble_delay[0] ); - LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", - frame,subframe, + LOG_D(PHY,"[RAPROC] Frame %d, slot %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", + frame,slot, max_preamble[0], max_preamble_energy[0]/10, max_preamble_delay[0], @@ -93,49 +97,42 @@ void L1_nr_prach_procedures(PHY_VARS_gNB *gNB,int frame,int subframe) { if ((gNB->prach_energy_counter == 100) && (max_preamble_energy[0] > gNB->measurements.prach_I0+100)) { - LOG_I(PHY,"[gNB %d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", + LOG_I(PHY,"[gNB %d][RAPROC] Frame %d, slot %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n", gNB->Mod_id, frame, - subframe, + slot, max_preamble[0], max_preamble_energy[0]/10, max_preamble_energy[0]%10, max_preamble_delay[0]); - T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(gNB->Mod_id), T_INT(frame), T_INT(subframe), + T(T_ENB_PHY_INITIATE_RA_PROCEDURE, T_INT(gNB->Mod_id), T_INT(frame), T_INT(slot), T_INT(max_preamble[0]), T_INT(max_preamble_energy[0]), T_INT(max_preamble_delay[0])); - gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 1; - gNB->UL_INFO.rach_ind.rach_indication_body.preamble_list = &gNB->preamble_list[0]; - gNB->UL_INFO.rach_ind.rach_indication_body.tl.tag = NFAPI_RACH_INDICATION_BODY_TAG; - gNB->UL_INFO.rach_ind.header.message_id = NFAPI_RACH_INDICATION; - gNB->UL_INFO.rach_ind.sfn_sf = frame<<4 | subframe; + gNB->UL_INFO.rach_ind.number_of_pdus = 1; + gNB->UL_INFO.rach_ind.pdu_list = &gNB->prach_pdu_indication_list[0]; + gNB->UL_INFO.rach_ind.sfn = frame; + gNB->UL_INFO.rach_ind.slot = slot; - gNB->preamble_list[0].preamble_rel8.tl.tag = NFAPI_PREAMBLE_REL8_TAG; - gNB->preamble_list[0].preamble_rel8.timing_advance = max_preamble_delay[0]; - gNB->preamble_list[0].preamble_rel8.preamble = max_preamble[0]; - gNB->preamble_list[0].preamble_rel8.rnti = 1+subframe; // note: fid is implicitly 0 here - gNB->preamble_list[0].instance_length = 0; //don't know exactly what this is - - if (nfapi_mode == 1) { // If NFAPI PNF then we need to send the message to the VNF - - LOG_D(PHY,"Filling NFAPI indication for NR RACH : SFN_SF:%d TA %d, Preamble %d, rnti %x\n", - NFAPI_SFNSF2DEC(gNB->UL_INFO.rach_ind.sfn_sf), - gNB->preamble_list[0].preamble_rel8.timing_advance, - gNB->preamble_list[0].preamble_rel8.preamble, - gNB->preamble_list[0].preamble_rel8.rnti); - AssertFatal(1==0,"shouldn't be here yet..\n"); - //oai_nfapi_nr_rach_ind(&gNB->UL_INFO.rach_ind); - - gNB->UL_INFO.rach_ind.rach_indication_body.number_of_preambles = 0; - } - } // max_preamble_energy > prach_I0 + 100 - else { - gNB->measurements.prach_I0 = ((gNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); - if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); - if (gNB->prach_energy_counter < 100) gNB->prach_energy_counter++; - } + gNB->prach_pdu_indication_list[0].phy_cell_id = gNB->gNB_config.cell_config.phy_cell_id.value; + gNB->prach_pdu_indication_list[0].symbol_index = prach_pdu->prach_start_symbol; + gNB->prach_pdu_indication_list[0].slot_index = slot; + gNB->prach_pdu_indication_list[0].freq_index = 0; // single frequency for now + gNB->prach_pdu_indication_list[0].avg_rssi = (max_preamble_energy[0]<631) ? (128+(max_preamble_energy[0]/5)) : 254; + gNB->prach_pdu_indication_list[0].avg_snr = 0xff; // invalid for now + + + gNB->prach_pdu_indication_list[0].num_preamble = 1; + gNB->prach_pdu_indication_list[0].preamble_list = gNB->preamble_list; + gNB->prach_pdu_indication_list[0].preamble_list[0].preamble_index = max_preamble[0]; + gNB->prach_pdu_indication_list[0].preamble_list[0].timing_advance = max_preamble_delay[0]; + gNB->prach_pdu_indication_list[0].preamble_list[0].preamble_pwr = 0xffffffff; + } + gNB->measurements.prach_I0 = ((gNB->measurements.prach_I0*900)>>10) + ((max_preamble_energy[0]*124)>>10); + if (frame==0) LOG_I(PHY,"prach_I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); + if (gNB->prach_energy_counter < 100) gNB->prach_energy_counter++; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PRACH_RX,0); } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index dd268d5dd6..c23f361fc9 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -57,8 +57,9 @@ void nr_initiate_ra_proc(module_id_t module_idP, frame_t frameP, sub_frame_t slotP, uint16_t preamble_index, - int16_t timing_offset, - uint16_t ra_rnti){ + int16_t timing_offset){ + + uint16_t ra_rnti=157; uint8_t i; uint16_t msg2_frame = frameP, msg2_slot = slotP; int offset; @@ -186,14 +187,6 @@ void nr_generate_Msg2(module_id_t module_idP, if ((ra->Msg2_frame == frameP) && (ra->Msg2_slot == slotP)) { - // todo - // Allocate 4 PRBS starting in RB 0 - // first_rb = 0; - // vrb_map[first_rb] = 1; - // vrb_map[first_rb + 1] = 1; - // vrb_map[first_rb + 2] = 1; - // vrb_map[first_rb + 3] = 1; - nfapi_nr_dl_tti_request_body_t *dl_req = &nr_mac->DL_req[CC_id].dl_tti_request_body; nfapi_nr_dl_tti_request_pdu_t *dl_config_pdu = &dl_req->dl_tti_pdu_list[dl_req->nPDUs]; nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; @@ -526,4 +519,4 @@ void nr_add_msg3(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t config_uldci(ubwp, pusch_pdu, pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types); pdcch_pdu_rel15->dci_pdu.PayloadSizeBits[0] = nr_dci_size(dci_formats[0], rnti_types[0], pdcch_pdu_rel15->BWPSize); fill_dci_pdu_rel15(pdcch_pdu_rel15, &dci_pdu_rel15[0], dci_formats, rnti_types); -} \ No newline at end of file +} diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 89bb3e3f2c..28177e2919 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -90,11 +90,7 @@ void nr_schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t slotP); @param rach_resource type (0=non BL/CE,1 CE level 0,2 CE level 1, 3 CE level 2,4 CE level 3) */ void nr_initiate_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP, sub_frame_t slotP, - uint16_t preamble_index, int16_t timing_offset, uint16_t rnti - #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0)) - , uint8_t rach_resource_type - #endif - ); + uint16_t preamble_index, int16_t timing_offset); void nr_clear_ra_proc(module_id_t module_idP, int CC_id, frame_t frameP); diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c index bde960a2e1..8a0763daca 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.c +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.c @@ -53,18 +53,23 @@ extern uint8_t nfapi_mode; extern uint16_t sf_ahead; void handle_nr_rach(NR_UL_IND_t *UL_info) { - if (UL_info->rach_ind.rach_indication_body.number_of_preambles>0) { - AssertFatal(UL_info->rach_ind.rach_indication_body.number_of_preambles==1,"More than 1 preamble not supported\n"); - UL_info->rach_ind.rach_indication_body.number_of_preambles=0; - LOG_D(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SF:%d\n",UL_info->frame,UL_info->slot, NFAPI_SFNSF2DEC(UL_info->rach_ind.sfn_sf)); - + if (UL_info->rach_ind.number_of_pdus>0) { + AssertFatal(UL_info->rach_ind.number_of_pdus==1,"More than 1 RACH pdu not supported\n"); + UL_info->rach_ind.number_of_pdus=0; + LOG_D(MAC,"UL_info[Frame %d, Slot %d] Calling initiate_ra_proc RACH:SFN/SLOT:%d/%d\n",UL_info->frame,UL_info->slot, UL_info->rach_ind.sfn,UL_info->rach_ind.slot); + + + if (UL_info->rach_ind.pdu_list[0].num_preamble>0) + AssertFatal(UL_info->rach_ind.pdu_list[0].num_preamble==1, + "More than 1 preamble not supported\n"); + nr_initiate_ra_proc(UL_info->module_id, UL_info->CC_id, - NFAPI_SFNSF2SFN(UL_info->rach_ind.sfn_sf), - NFAPI_SFNSF2SF(UL_info->rach_ind.sfn_sf), - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.preamble, - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.timing_advance, - UL_info->rach_ind.rach_indication_body.preamble_list[0].preamble_rel8.rnti); + UL_info->rach_ind.sfn, + UL_info->rach_ind.slot, + UL_info->rach_ind.pdu_list[0].preamble_list[0].preamble_index, + UL_info->rach_ind.pdu_list[0].preamble_list[0].timing_advance); + } } @@ -220,11 +225,11 @@ void NR_UL_indication(NR_UL_IND_t *UL_info) { NR_Sched_Rsp_t *sched_info = &Sched_INFO[module_id][CC_id]; NR_IF_Module_t *ifi = if_inst[module_id]; gNB_MAC_INST *mac = RC.nrmac[module_id]; - LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d preambles:%d sr_ind:%d]\n", + LOG_D(PHY,"SFN/SF:%d%d module_id:%d CC_id:%d UL_info[rx_ind:%d harqs:%d crcs:%d cqis:%d rach_pdus:%d sr_ind:%d]\n", UL_info->frame,UL_info->slot, module_id,CC_id, UL_info->rx_ind.rx_indication_body.number_of_pdus, UL_info->harq_ind.harq_indication_body.number_of_harqs, UL_info->crc_ind.crc_indication_body.number_of_crcs, UL_info->cqi_ind.number_of_cqis, - UL_info->rach_ind.rach_indication_body.number_of_preambles, UL_info->sr_ind.sr_indication_body.number_of_srs); + UL_info->rach_ind.number_of_pdus, UL_info->sr_ind.sr_indication_body.number_of_srs); if (nfapi_mode != 1) { if (ifi->CC_mask==0) { diff --git a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h index 14355781d0..eaf0811883 100644 --- a/openair2/NR_PHY_INTERFACE/NR_IF_Module.h +++ b/openair2/NR_PHY_INTERFACE/NR_IF_Module.h @@ -74,10 +74,7 @@ typedef struct { nfapi_cqi_indication_body_t cqi_ind; /// RACH indication list - nfapi_rach_indication_t rach_ind; - - /// RACH indication list for BR UEs - nfapi_rach_indication_t rach_ind_br; + nfapi_nr_rach_indication_t rach_ind; /// SRS indication list nfapi_srs_indication_body_t srs_ind;