Commit 9714877e authored by Robert Schmidt's avatar Robert Schmidt

Merge remote-tracking branch 'origin/remove-NR_UE_PBCH' into integration_2022_wk10

parents e285b003 939b249b
...@@ -346,7 +346,7 @@ typedef struct { ...@@ -346,7 +346,7 @@ typedef struct {
@param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit) @param format data format (0 = real 16-bit, 1 = complex 16-bit,2 real 32-bit, 3 complex 32-bit,4 = real 8-bit, 5 = complex 8-bit)
@param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1) @param multiVec create new file or append to existing (useful for writing multiple vectors to same file. Just call the function multiple times with same file name and with this parameter set to 1)
*/ */
#define MATLAB_RAW (1<<31) #define MATLAB_RAW (1U<<31)
#define MATLAB_SHORT 0 #define MATLAB_SHORT 0
#define MATLAB_CSHORT 1 #define MATLAB_CSHORT 1
#define MATLAB_INT 2 #define MATLAB_INT 2
......
...@@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr, ...@@ -72,10 +72,10 @@ unsigned int crcbit (unsigned char * inputptr,
unsigned int i, crc = 0, c; unsigned int i, crc = 0, c;
while (octetlen-- > 0) { while (octetlen-- > 0) {
c = (*inputptr++) << 24; c = ((unsigned int)(*inputptr++)) << 24;
for (i = 8; i != 0; i--) { for (i = 8; i != 0; i--) {
if ((1 << 31) & (c ^ crc)) if ((1U << 31) & (c ^ crc))
crc = (crc << 1) ^ poly; crc = (crc << 1) ^ poly;
else else
crc <<= 1; crc <<= 1;
......
...@@ -445,29 +445,10 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ...@@ -445,29 +445,10 @@ int init_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
} }
} }
// PBCH // RACH
pbch_vars[gNB_id]->rxdataF_ext = (int32_t **)malloc16( fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->rxdataF_comp = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_ext = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->dl_ch_estimates_time = (int32_t **)malloc16_clear( 4*fp->nb_antennas_rx*sizeof(int32_t *) );
pbch_vars[gNB_id]->llr = (int16_t *)malloc16_clear( 1920 ); //
prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); prach_vars[gNB_id]->prachF = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) ); prach_vars[gNB_id]->prach = (int16_t *)malloc16_clear( sizeof(int)*(7*2*sizeof(int)*(fp->ofdm_symbol_size*12)) );
for (i=0; i<fp->nb_antennas_rx; i++) {
pbch_vars[gNB_id]->rxdataF_ext[i] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
for (j=0; j<4; j++) {//fp->nb_antennas_tx;j++) {
int idx = (j*fp->nb_antennas_rx)+i;
pbch_vars[gNB_id]->rxdataF_comp[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
pbch_vars[gNB_id]->dl_ch_estimates[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_time[idx]= (int32_t *)malloc16_clear( sizeof(int32_t)*7*2*sizeof(int)*(fp->ofdm_symbol_size) );
pbch_vars[gNB_id]->dl_ch_estimates_ext[idx] = (int32_t *)malloc16_clear( sizeof(int32_t)*20*12*4 );
}
}
pbch_vars[gNB_id]->decoded_output = (uint8_t *)malloc16_clear(64);
} }
// initialization for the last instance of pdsch_vars (used for MU-MIMO) // initialization for the last instance of pdsch_vars (used for MU-MIMO)
...@@ -640,25 +621,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB) ...@@ -640,25 +621,6 @@ void term_nr_ue_signal(PHY_VARS_NR_UE *ue, int nb_connected_gNB)
free_and_zero(ue->srs_vars[gNB_id]); free_and_zero(ue->srs_vars[gNB_id]);
for (int i = 0; i < fp->nb_antennas_rx; i++) {
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext[i]);
for (int j = 0; j < 4; j++) {
int idx = (j*fp->nb_antennas_rx)+i;
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time[idx]);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext[idx]);
}
}
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_ext);
free_and_zero(ue->pbch_vars[gNB_id]->rxdataF_comp);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_ext);
free_and_zero(ue->pbch_vars[gNB_id]->dl_ch_estimates_time);
free_and_zero(ue->pbch_vars[gNB_id]->llr);
free_and_zero(ue->pbch_vars[gNB_id]->decoded_output);
free_and_zero(ue->pbch_vars[gNB_id]); free_and_zero(ue->pbch_vars[gNB_id]);
free_and_zero(ue->prach_vars[gNB_id]->prachF); free_and_zero(ue->prach_vars[gNB_id]->prachF);
......
...@@ -64,7 +64,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue, ...@@ -64,7 +64,7 @@ void nr_gold_pdcch(PHY_VARS_NR_UE* ue,
reset = 1; reset = 1;
x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
x2 = (x2tmp0+(nid<<1))%(1<<31); //cinit x2 = (x2tmp0+(nid<<1))%(1U<<31); //cinit
for (n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) { for (n=0; n<NR_MAX_PDCCH_DMRS_INIT_LENGTH_DWORD; n++) {
ue->nr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset); ue->nr_gold_pdcch[0][ns][l][n] = lte_gold_generic(&x1, &x2, reset);
...@@ -95,7 +95,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue, ...@@ -95,7 +95,7 @@ void nr_gold_pdsch(PHY_VARS_NR_UE* ue,
reset = 1; reset = 1;
x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17; x2tmp0 = ((ue->frame_parms.symbols_per_slot*ns+l+1)*((nid<<1)+1))<<17;
x2 = (x2tmp0+(nid<<1)+nscid)%(1<<31); //cinit x2 = (x2tmp0+(nid<<1)+nscid)%(1U<<31); //cinit
LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid); LOG_D(PHY,"UE DMRS slot %d, symb %d, x2 %x, nscid %d\n",ns,l,x2,nscid);
for (n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) { for (n=0; n<NR_MAX_PDSCH_DMRS_INIT_LENGTH_DWORD; n++) {
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
module_id_t gNB_id, module_id_t gNB_id,
const int estimateSz, struct complex16 dl_ch_estimates_time[][estimateSz],
uint8_t frame, uint8_t frame,
uint8_t subframe, uint8_t subframe,
unsigned char clear, unsigned char clear,
...@@ -60,8 +61,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, ...@@ -60,8 +61,8 @@ void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
int j = (i < 0) ? (i + frame_parms->ofdm_symbol_size) : i; int j = (i < 0) ? (i + frame_parms->ofdm_symbol_size) : i;
for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) { for (int aa = 0; aa < frame_parms->nb_antennas_rx; aa++) {
int Re = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[(j<<1)]; int Re = dl_ch_estimates_time[aa][j].r;
int Im = ((int16_t*)ue->pbch_vars[gNB_id]->dl_ch_estimates_time[aa])[1+(j<<1)]; int Im = dl_ch_estimates_time[aa][j].i;
temp += (Re*Re/2) + (Im*Im/2); temp += (Re*Re/2) + (Im*Im/2);
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "PHY/NR_REFSIG/ptrs_nr.h" #include "PHY/NR_REFSIG/ptrs_nr.h"
#include "PHY/NR_TRANSPORT/nr_sch_dmrs.h" #include "PHY/NR_TRANSPORT/nr_sch_dmrs.h"
#include "filt16a_32.h" #include "filt16a_32.h"
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
//#define DEBUG_PDSCH //#define DEBUG_PDSCH
//#define DEBUG_PDCCH //#define DEBUG_PDCCH
...@@ -43,7 +44,6 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -43,7 +44,6 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
NR_UE_SSB *current_ssb) NR_UE_SSB *current_ssb)
{ {
int pilot[200] __attribute__((aligned(16))); int pilot[200] __attribute__((aligned(16)));
unsigned char aarx;
unsigned short k; unsigned short k;
unsigned int pilot_cnt; unsigned int pilot_cnt;
int16_t ch[2],*pil,*rxF; int16_t ch[2],*pil,*rxF;
...@@ -77,7 +77,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -77,7 +77,7 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
// generate pilot // generate pilot
nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) { for (int aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
int re_offset = ssb_offset; int re_offset = ssb_offset;
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
...@@ -197,6 +197,9 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -197,6 +197,9 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
int estimateSz,
struct complex16 dl_ch_estimates [][estimateSz],
struct complex16 dl_ch_estimates_time [][estimateSz],
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
uint8_t gNB_id, uint8_t gNB_id,
unsigned char Ns, unsigned char Ns,
...@@ -206,16 +209,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -206,16 +209,14 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
uint8_t n_hf) uint8_t n_hf)
{ {
int pilot[200] __attribute__((aligned(16))); int pilot[200] __attribute__((aligned(16)));
unsigned char aarx,p;
unsigned short k; unsigned short k;
unsigned int pilot_cnt; unsigned int pilot_cnt;
int16_t ch[2],*pil,*rxF,*dl_ch,*fl,*fm,*fr; int16_t *pil,*rxF,*dl_ch,*fl,*fm,*fr;
int ch_offset,symbol_offset; int ch_offset,symbol_offset;
//int slot_pbch; //int slot_pbch;
uint8_t nushift; uint8_t nushift;
int **dl_ch_estimates =ue->pbch_vars[gNB_id]->dl_ch_estimates; int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF;
int **rxdataF=ue->common_vars.common_vars_rx_data_per_thread[proc->thread_id].rxdataF;
nushift = ue->frame_parms.Nid_cell%4; nushift = ue->frame_parms.Nid_cell%4;
ue->frame_parms.nushift = nushift; ue->frame_parms.nushift = nushift;
...@@ -269,17 +270,57 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -269,17 +270,57 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
break; break;
} }
idft_size_idx_t idftsizeidx;
switch (ue->frame_parms.ofdm_symbol_size) {
case 128:
idftsizeidx = IDFT_128;
break;
case 256:
idftsizeidx = IDFT_256;
break;
case 512:
idftsizeidx = IDFT_512;
break;
case 1024:
idftsizeidx = IDFT_1024;
break;
case 1536:
idftsizeidx = IDFT_1536;
break;
case 2048:
idftsizeidx = IDFT_2048;
break;
case 3072:
idftsizeidx = IDFT_3072;
break;
case 4096:
idftsizeidx = IDFT_4096;
break;
default:
printf("unsupported ofdm symbol size \n");
assert(0);
}
// generate pilot // generate pilot
nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]); nr_pbch_dmrs_rx(dmrss,ue->nr_gold_pbch[n_hf][ssb_index], &pilot[0]);
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) { for (int aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) {
int re_offset = ssb_offset; int re_offset = ssb_offset;
pil = (int16_t *)&pilot[0]; pil = (int16_t *)&pilot[0];
rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)]; rxF = (int16_t *)&rxdataF[aarx][(symbol_offset+k+re_offset)];
dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset]; dl_ch = (int16_t *)&dl_ch_estimates[aarx][ch_offset];
memset(dl_ch,0,4*(ue->frame_parms.ofdm_symbol_size)); memset(dl_ch,0,sizeof(*dl_ch)*(ue->frame_parms.ofdm_symbol_size));
#ifdef DEBUG_CH #ifdef DEBUG_CH
printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL); printf("pbch ch est pilot addr %p RB_DL %d\n",&pilot[0], ue->frame_parms.N_RB_DL);
...@@ -289,6 +330,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -289,6 +330,7 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
#endif #endif
// Treat first 2 pilots specially (left edge) // Treat first 2 pilots specially (left edge)
int16_t ch[2];
ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15); ch[0] = (int16_t)(((int32_t)pil[0]*rxF[0] - (int32_t)pil[1]*rxF[1])>>15);
ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15); ch[1] = (int16_t)(((int32_t)pil[0]*rxF[1] + (int32_t)pil[1]*rxF[0])>>15);
...@@ -402,62 +444,18 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -402,62 +444,18 @@ int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
} }
idft_size_idx_t idftsizeidx;
switch (ue->frame_parms.ofdm_symbol_size) {
case 128:
idftsizeidx = IDFT_128;
break;
case 256:
idftsizeidx = IDFT_256;
break;
case 512:
idftsizeidx = IDFT_512;
break;
case 1024:
idftsizeidx = IDFT_1024;
break;
case 1536:
idftsizeidx = IDFT_1536;
break;
case 2048:
idftsizeidx = IDFT_2048;
break;
case 3072:
idftsizeidx = IDFT_3072;
break;
case 4096:
idftsizeidx = IDFT_4096;
break;
default:
printf("unsupported ofdm symbol size \n");
assert(0);
}
if( dmrss == 2) // update time statistics for last PBCH symbol if( dmrss == 2) // update time statistics for last PBCH symbol
{ {
// do ifft of channel estimate // do ifft of channel estimate
for (aarx=0; aarx<ue->frame_parms.nb_antennas_rx; aarx++) LOG_D(PHY,"Channel Impulse Computation Slot %d Symbol %d ch_offset %d\n", Ns, symbol, ch_offset);
for (p=0; p<ue->frame_parms.nb_antenna_ports_gNB; p++) { idft(idftsizeidx,
if (ue->pbch_vars[gNB_id]->dl_ch_estimates[(p*ue->frame_parms.nb_antennas_rx)+aarx]) (int16_t*) &dl_ch_estimates[aarx][ch_offset],
{ (int16_t*) dl_ch_estimates_time[aarx],
LOG_D(PHY,"Channel Impulse Computation Slot %d ThreadId %d Symbol %d ch_offset %d\n", Ns, proc->thread_id, symbol, ch_offset); 1);
idft(idftsizeidx, }
(int16_t*) &ue->pbch_vars[gNB_id]->dl_ch_estimates[(p*ue->frame_parms.nb_antennas_rx)+aarx][ch_offset], }
(int16_t*) ue->pbch_vars[gNB_id]->dl_ch_estimates_time[(p*ue->frame_parms.nb_antennas_rx)+aarx],1); if (dmrss == 2)
} UEscopeCopy(ue, pbchDlChEstimateTime, (void*)dl_ch_estimates_time, sizeof(struct complex16), ue->frame_parms.nb_antennas_rx, idftsizeidx);
}
}
}
return(0); return(0);
} }
......
...@@ -56,7 +56,10 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue, ...@@ -56,7 +56,10 @@ int nr_pbch_dmrs_correlation(PHY_VARS_NR_UE *ue,
NR_UE_SSB *current_ssb); NR_UE_SSB *current_ssb);
int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue, int nr_pbch_channel_estimation(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, int estimateSz,
struct complex16 dl_ch_estimates [][estimateSz],
struct complex16 dl_ch_estimates_time [][estimateSz],
UE_nr_rxtx_proc_t *proc,
uint8_t gNB_id, uint8_t gNB_id,
unsigned char Ns, unsigned char Ns,
unsigned char symbol, unsigned char symbol,
...@@ -79,6 +82,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue, ...@@ -79,6 +82,8 @@ int nr_pdsch_channel_estimation(PHY_VARS_NR_UE *ue,
void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms, void nr_adjust_synch_ue(NR_DL_FRAME_PARMS *frame_parms,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
module_id_t gNB_id, module_id_t gNB_id,
int estimateSz,
struct complex16 dl_ch_estimates_time [][estimateSz],
uint8_t frame, uint8_t frame,
uint8_t subframe, uint8_t subframe,
unsigned char clear, unsigned char clear,
......
...@@ -146,17 +146,23 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini ...@@ -146,17 +146,23 @@ int nr_pbch_detection(UE_nr_rxtx_proc_t * proc, PHY_VARS_NR_UE *ue, int pbch_ini
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
// computing channel estimation for selected best ssb // computing channel estimation for selected best ssb
const int estimateSz=7*2*frame_parms->ofdm_symbol_size;
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz];
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz];
for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++) for(int i=pbch_initial_symbol; i<pbch_initial_symbol+3;i++)
nr_pbch_channel_estimation(ue,proc,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf); nr_pbch_channel_estimation(ue,estimateSz, dl_ch_estimates, dl_ch_estimates_time,
proc,0,0,i,i-pbch_initial_symbol,temp_ptr->i_ssb,temp_ptr->n_hf);
stop_meas(&ue->dlsch_channel_estimation_stats); stop_meas(&ue->dlsch_channel_estimation_stats);
fapiPbch_t result;
ret = nr_rx_pbch(ue, ret = nr_rx_pbch(ue,
proc, proc,
ue->pbch_vars[0], estimateSz, dl_ch_estimates,
ue->pbch_vars[0],
frame_parms, frame_parms,
0, 0,
temp_ptr->i_ssb, temp_ptr->i_ssb,
SISO); SISO,
&result);
temp_ptr=temp_ptr->next_ssb; temp_ptr=temp_ptr->next_ssb;
} }
......
...@@ -36,28 +36,30 @@ ...@@ -36,28 +36,30 @@
#include "PHY/LTE_REFSIG/lte_refsig.h" #include "PHY/LTE_REFSIG/lte_refsig.h"
#include "PHY/INIT/phy_init.h" #include "PHY/INIT/phy_init.h"
#include "openair1/SCHED_NR_UE/defs.h" #include "openair1/SCHED_NR_UE/defs.h"
#include <openair1/PHY/NR_UE_TRANSPORT/nr_transport_proto_ue.h>
#include <openair1/PHY/TOOLS/phy_scope_interface.h>
//#define DEBUG_PBCH //#define DEBUG_PBCH
//#define DEBUG_PBCH_ENCODING //#define DEBUG_PBCH_ENCODING
//#include "PHY_INTERFACE/defs.h" //#include "PHY_INTERFACE/defs.h"
#define PBCH_A 24 #define PBCH_A 24
#define PBCH_MAX_RE_PER_SYMBOL (20*12)
#define PBCH_MAX_RE (PBCH_MAX_RE_PER_SYMBOL*4)
#define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7]) #define print_shorts(s,x) printf("%s : %d,%d,%d,%d,%d,%d,%d,%d\n",s,((int16_t*)x)[0],((int16_t*)x)[1],((int16_t*)x)[2],((int16_t*)x)[3],((int16_t*)x)[4],((int16_t*)x)[5],((int16_t*)x)[6],((int16_t*)x)[7])
uint16_t nr_pbch_extract(int **rxdataF, static uint16_t nr_pbch_extract(int **rxdataF,
int **dl_ch_estimates, const int estimateSz,
int **rxdataF_ext, struct complex16 dl_ch_estimates[][estimateSz],
int **dl_ch_estimates_ext, struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL],
uint32_t symbol, struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
uint32_t s_offset, uint32_t symbol,
NR_DL_FRAME_PARMS *frame_parms) { uint32_t s_offset,
NR_DL_FRAME_PARMS *frame_parms) {
uint16_t rb; uint16_t rb;
uint8_t i,j,aarx; uint8_t i,j,aarx;
int32_t *dl_ch0,*dl_ch0_ext,*rxF,*rxF_ext;
int nushiftmod4 = frame_parms->nushift; int nushiftmod4 = frame_parms->nushift;
AssertFatal(symbol>=1 && symbol<5, AssertFatal(symbol>=1 && symbol<5,
"symbol %d illegal for PBCH extraction\n", "symbol %d illegal for PBCH extraction\n",
symbol); symbol);
...@@ -65,9 +67,8 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -65,9 +67,8 @@ uint16_t nr_pbch_extract(int **rxdataF,
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier; unsigned int rx_offset = frame_parms->first_carrier_offset + frame_parms->ssb_start_subcarrier;
rx_offset = (rx_offset)%(frame_parms->ofdm_symbol_size); rx_offset = (rx_offset)%(frame_parms->ofdm_symbol_size);
struct complex16 *rxF = (struct complex16 *)&rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size];
rxF = &rxdataF[aarx][(symbol+s_offset)*frame_parms->ofdm_symbol_size]; struct complex16 *rxF_ext = rxdataF_ext[aarx];
rxF_ext = &rxdataF_ext[aarx][symbol*20*12];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("extract_rbs (nushift %d): rx_offset=%d, symbol %u\n",frame_parms->nushift, printf("extract_rbs (nushift %d): rx_offset=%d, symbol %u\n",frame_parms->nushift,
(rx_offset + ((symbol+s_offset)*(frame_parms->ofdm_symbol_size))),symbol); (rx_offset + ((symbol+s_offset)*(frame_parms->ofdm_symbol_size))),symbol);
...@@ -76,7 +77,6 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -76,7 +77,6 @@ uint16_t nr_pbch_extract(int **rxdataF,
for (int i =0; i<8; i++) { for (int i =0; i<8; i++) {
printf("rxF [%d]= %d\n",i,rxF[i]); printf("rxF [%d]= %d\n",i,rxF[i]);
printf("pbch extract rxF %d %d addr %p\n", p[2*i], p[2*i+1], &p[2*i]); printf("pbch extract rxF %d %d addr %p\n", p[2*i], p[2*i+1], &p[2*i]);
printf("rxF ext addr %p\n", &rxF_ext[i]);
} }
#endif #endif
...@@ -91,19 +91,18 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -91,19 +91,18 @@ uint16_t nr_pbch_extract(int **rxdataF,
(i!=(nushiftmod4+8))) { (i!=(nushiftmod4+8))) {
rxF_ext[j]=rxF[rx_offset]; rxF_ext[j]=rxF[rx_offset];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(9*rb) + j, printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",
((int16_t *)&rxF_ext[j])[0], (9*rb) + j,
((int16_t *)&rxF_ext[j])[1], rxF_ext[j].r, rxF_ext[j].i,
rx_offset, rx_offset,
((int16_t *)&rxF[rx_offset])[0], rxF[rx_offset].r,rxF[rx_offset].j;
((int16_t *)&rxF[rx_offset])[1]);
#endif #endif
j++; j++;
} }
rx_offset=(rx_offset+1)%(frame_parms->ofdm_symbol_size); rx_offset=(rx_offset+1)%(frame_parms->ofdm_symbol_size);
//rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1); //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 1) : (rx_offset+1);
} }
rxF_ext+=9; rxF_ext+=9;
} else { //symbol 2 } else { //symbol 2
...@@ -115,11 +114,9 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -115,11 +114,9 @@ uint16_t nr_pbch_extract(int **rxdataF,
rxF_ext[j]=rxF[rx_offset]; rxF_ext[j]=rxF[rx_offset];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j, printf("rxF ext[%d] = (%d,%d) rxF [%u]= (%d,%d)\n",(rb<4) ? (9*rb) + j : (9*(rb-12))+j,
((int16_t *)&rxF_ext[j])[0], rxF_ext[j].r, rxF_ext[j].i,
((int16_t *)&rxF_ext[j])[1],
rx_offset, rx_offset,
((int16_t *)&rxF[rx_offset])[0], rxF[rx_offset].r,rxF[rx_offset].j;
((int16_t *)&rxF[rx_offset])[1]);
#endif #endif
j++; j++;
} }
...@@ -129,16 +126,16 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -129,16 +126,16 @@ uint16_t nr_pbch_extract(int **rxdataF,
} }
rxF_ext+=9; rxF_ext+=9;
} else{ //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12); } else { //rx_offset = (rx_offset >= frame_parms->ofdm_symbol_size) ? (rx_offset - frame_parms->ofdm_symbol_size + 12) : (rx_offset+12);
rx_offset = (rx_offset+12)%(frame_parms->ofdm_symbol_size); rx_offset = (rx_offset+12)%(frame_parms->ofdm_symbol_size);
} }
} }
} }
dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))]; struct complex16 *dl_ch0 = &dl_ch_estimates[aarx][((symbol+s_offset)*(frame_parms->ofdm_symbol_size))];
//printf("dl_ch0 addr %p\n",dl_ch0); //printf("dl_ch0 addr %p\n",dl_ch0);
dl_ch0_ext = &dl_ch_estimates_ext[aarx][symbol*20*12]; struct complex16 *dl_ch0_ext = dl_ch_estimates_ext[aarx];
for (rb=0; rb<20; rb++) { for (rb=0; rb<20; rb++) {
j=0; j=0;
...@@ -150,15 +147,11 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -150,15 +147,11 @@ uint16_t nr_pbch_extract(int **rxdataF,
(i!=(nushiftmod4+8))) { (i!=(nushiftmod4+8))) {
dl_ch0_ext[j]=dl_ch0[i]; dl_ch0_ext[j]=dl_ch0[i];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
if ((rb==0) && (i<2)) if ((rb==0) && (i<2))
printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j,
((int16_t *)&dl_ch0_ext[j])[0], dl_ch0_ext[j].r, dl_ch0_ext[j].i,
((int16_t *)&dl_ch0_ext[j])[1],
i, i,
((int16_t *)&dl_ch0[i])[0], dl_ch0[j].r, dl_ch0[j].i,
((int16_t *)&dl_ch0[i])[1]);
#endif #endif
j++; j++;
} }
...@@ -175,11 +168,9 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -175,11 +168,9 @@ uint16_t nr_pbch_extract(int **rxdataF,
dl_ch0_ext[j]=dl_ch0[i]; dl_ch0_ext[j]=dl_ch0[i];
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j, printf("dl ch0 ext[%d] = (%d,%d) dl_ch0 [%d]= (%d,%d)\n",j,
((int16_t *)&dl_ch0_ext[j])[0], dl_ch0_ext[j].r, dl_ch0_ext[j].i,
((int16_t *)&dl_ch0_ext[j])[1],
i, i,
((int16_t *)&dl_ch0[i])[0], dl_ch0[j].r, dl_ch0[j].i,
((int16_t *)&dl_ch0[i])[1]);
#endif #endif
j++; j++;
} }
...@@ -199,11 +190,10 @@ uint16_t nr_pbch_extract(int **rxdataF, ...@@ -199,11 +190,10 @@ uint16_t nr_pbch_extract(int **rxdataF,
//__m128i avg128; //__m128i avg128;
//compute average channel_level on each (TX,RX) antenna pair //compute average channel_level on each (TX,RX) antenna pair
int nr_pbch_channel_level(int **dl_ch_estimates_ext, int nr_pbch_channel_level(struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint32_t symbol) { int nb_re) {
int16_t rb, nb_rb=20; int16_t nb_rb=nb_re/12;
uint8_t aarx;
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
__m128i avg128; __m128i avg128;
__m128i *dl_ch128; __m128i *dl_ch128;
...@@ -213,22 +203,23 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext, ...@@ -213,22 +203,23 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext,
#endif #endif
int avg1=0,avg2=0; int avg1=0,avg2=0;
for (aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
//clear average level //clear average level
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
avg128 = _mm_setzero_si128(); avg128 = _mm_setzero_si128();
dl_ch128=(__m128i *)&dl_ch_estimates_ext[aarx][symbol*20*12]; dl_ch128=(__m128i *)dl_ch_estimates_ext[aarx];
#elif defined(__arm__) #elif defined(__arm__)
avg128 = vdupq_n_s32(0); avg128 = vdupq_n_s32(0);
dl_ch128=(int16x8_t *)&dl_ch_estimates_ext[aarx][symbol*20*12]; dl_ch128=(int16x8_t *)dl_ch_estimates_ext[aarx];
#endif #endif
for (rb=0; rb<nb_rb; rb++) { for (int rb=0; rb<nb_rb; rb++) {
#if defined(__x86_64__) || defined(__i386__) #if defined(__x86_64__) || defined(__i386__)
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[0],dl_ch128[0]));
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[1],dl_ch128[1]));
avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2])); avg128 = _mm_add_epi32(avg128,_mm_madd_epi16(dl_ch128[2],dl_ch128[2]));
#elif defined(__arm__) #elif defined(__arm__)
abort();
// to be filled in // to be filled in
#endif #endif
dl_ch128+=3; dl_ch128+=3;
...@@ -251,35 +242,19 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext, ...@@ -251,35 +242,19 @@ int nr_pbch_channel_level(int **dl_ch_estimates_ext,
//LOG_I(PHY,"Channel level : %d, %d\n",avg1, avg2); //LOG_I(PHY,"Channel level : %d, %d\n",avg1, avg2);
} }
#if defined(__x86_64__) || defined(__i386__)
_mm_empty();
_m_empty();
#endif
return(avg2); return(avg2);
} }
void nr_pbch_channel_compensation(int **rxdataF_ext, static void nr_pbch_channel_compensation(struct complex16 rxdataF_ext[][PBCH_MAX_RE_PER_SYMBOL],
int **dl_ch_estimates_ext, struct complex16 dl_ch_estimates_ext[][PBCH_MAX_RE_PER_SYMBOL],
int **rxdataF_comp, int nb_re,
NR_DL_FRAME_PARMS *frame_parms, struct complex16 rxdataF_comp[][PBCH_MAX_RE_PER_SYMBOL],
uint32_t symbol, NR_DL_FRAME_PARMS *frame_parms,
uint8_t output_shift) { uint8_t output_shift) {
const uint16_t nb_re=symbol == 2 ? 72 : 180;
AssertFatal((symbol > 0 && symbol < 4),
"symbol %d is illegal for PBCH DM-RS\n",
symbol);
// printf("comp: symbol %d : nb_re %d\n",symbol,nb_re);
for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) { for (int aarx=0; aarx<frame_parms->nb_antennas_rx; aarx++) {
vect128 *dl_ch128 = (vect128 *)&dl_ch_estimates_ext[aarx][symbol*20*12]; vect128 *dl_ch128 = (vect128 *)dl_ch_estimates_ext[aarx];
vect128 *rxdataF128 = (vect128 *)&rxdataF_ext[aarx][symbol*20*12]; vect128 *rxdataF128 = (vect128 *)rxdataF_ext[aarx];
vect128 *rxdataF_comp128 = (vect128 *)&rxdataF_comp[aarx][symbol*20*12]; vect128 *rxdataF_comp128 = (vect128 *)rxdataF_comp[aarx];
/*
printf("ch compensation dl_ch ext addr %p \n", &dl_ch_estimates_ext[aarx][symbol*20*12]);
printf("rxdataf ext addr %p symbol %d\n", &rxdataF_ext[aarx][symbol*20*12], symbol);
printf("rxdataf_comp addr %p\n",&rxdataF_comp[aarx][symbol*20*12]);
*/
for (int re=0; re<nb_re; re+=12) { for (int re=0; re<nb_re; re+=12) {
*rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift); *rxdataF_comp128++ = mulByConjugate128(rxdataF128++, dl_ch128++, output_shift);
...@@ -327,16 +302,18 @@ void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms, ...@@ -327,16 +302,18 @@ void nr_pbch_detection_mrc(NR_DL_FRAME_PARMS *frame_parms,
} }
static void nr_pbch_unscrambling(NR_UE_PBCH *pbch, static void nr_pbch_unscrambling(NR_UE_PBCH *pbch,
uint16_t Nid, int16_t *demod_pbch_e,
uint8_t nushift, uint16_t Nid,
uint16_t M, uint8_t nushift,
uint16_t length, uint16_t M,
uint8_t bitwise, uint16_t length,
uint32_t unscrambling_mask) { uint8_t bitwise,
uint32_t unscrambling_mask,
uint32_t pbch_a_prime,
uint32_t *pbch_a_interleaved) {
uint8_t reset, offset; uint8_t reset, offset;
uint32_t x1, x2, s=0; uint32_t x1, x2, s=0;
uint8_t k=0; uint8_t k=0;
int16_t *demod_pbch_e = pbch->llr;
reset = 1; reset = 1;
// x1 is set in first call to lte_gold_generic // x1 is set in first call to lte_gold_generic
x2 = Nid; //this is c_init x2 = Nid; //this is c_init
...@@ -361,10 +338,10 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch, ...@@ -361,10 +338,10 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch,
reset = 0; reset = 0;
} }
(pbch->pbch_a_interleaved) ^= ((unscrambling_mask>>i)&1)? ((pbch->pbch_a_prime>>i)&1)<<i : (((pbch->pbch_a_prime>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<<i; *pbch_a_interleaved ^= ((unscrambling_mask>>i)&1)? ((pbch_a_prime>>i)&1)<<i : (((pbch_a_prime>>i)&1) ^ ((s>>((k+offset)&0x1f))&1))<<i;
k += (!((unscrambling_mask>>i)&1)); k += (!((unscrambling_mask>>i)&1));
#ifdef DEBUG_PBCH_ENCODING #ifdef DEBUG_PBCH_ENCODING
printf("i %d k %d offset %d (unscrambling_mask>>i)&1) %d s: %08x\t pbch_a_interleaved 0x%08x (!((unscrambling_mask>>i)&1)) %d\n", i, k, offset, (unscrambling_mask>>i)&1, s, pbch->pbch_a_interleaved, printf("i %d k %d offset %d (unscrambling_mask>>i)&1) %d s: %08x\t pbch_a_interleaved 0x%08x (!((unscrambling_mask>>i)&1)) %d\n", i, k, offset, (unscrambling_mask>>i)&1, s, *pbch_a_interleaved,
(!((unscrambling_mask>>i)&1))); (!((unscrambling_mask>>i)&1)));
#endif #endif
} else { } else {
...@@ -386,18 +363,16 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch, ...@@ -386,18 +363,16 @@ static void nr_pbch_unscrambling(NR_UE_PBCH *pbch,
} }
} }
void nr_pbch_quantize(int16_t *pbch_llr8, static void nr_pbch_quantize(int16_t *pbch_llr8,
int16_t *pbch_llr, int16_t *pbch_llr,
uint16_t len) { uint16_t len) {
uint16_t i; for (int i=0; i<len; i++) {
for (i=0; i<len; i++) {
if (pbch_llr[i]>31) if (pbch_llr[i]>31)
pbch_llr8[i]=32; pbch_llr8[i]=32;
else if (pbch_llr[i]<-31) else if (pbch_llr[i]<-31)
pbch_llr8[i]=-32; pbch_llr8[i]=-32;
else else
pbch_llr8[i] = (char)(pbch_llr[i]); pbch_llr8[i]=pbch_llr[i];
} }
} }
/* /*
...@@ -410,36 +385,33 @@ uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,7,29,25,27,5,8,24,9,10,11, ...@@ -410,36 +385,33 @@ uint8_t pbch_deinterleaving_pattern[32] = {28,0,31,30,7,29,25,27,5,8,24,9,10,11,
int nr_rx_pbch( PHY_VARS_NR_UE *ue, int nr_rx_pbch( PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
int estimateSz, struct complex16 dl_ch_estimates [][estimateSz],
NR_UE_PBCH *nr_ue_pbch_vars, NR_UE_PBCH *nr_ue_pbch_vars,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint8_t gNB_id, uint8_t gNB_id,
uint8_t i_ssb, uint8_t i_ssb,
MIMO_mode_t mimo_mode) { MIMO_mode_t mimo_mode,
fapiPbch_t *result) {
NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars; NR_UE_COMMON *nr_ue_common_vars = &ue->common_vars;
int max_h=0; int max_h=0;
int symbol; int symbol;
//uint8_t pbch_a[64]; //uint8_t pbch_a[64];
//FT ?? cppcheck doesn't like pbch_a allocation because of line 525..and i don't get what this variable is for.. //FT ?? cppcheck doesn't like pbch_a allocation because of line 525..and i don't get what this variable is for..
//uint8_t *pbch_a = malloc(sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); //uint8_t *pbch_a = malloc(sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS);
//uint32_t pbch_a_prime;
int16_t *pbch_e_rx;
uint8_t *decoded_output = nr_ue_pbch_vars->decoded_output;
uint8_t nushift; uint8_t nushift;
uint16_t M; uint16_t M;
uint8_t Lmax=frame_parms->Lmax; uint8_t Lmax=frame_parms->Lmax;
//uint16_t crc; //uint16_t crc;
//unsigned short idx_demod =0; //unsigned short idx_demod =0;
uint32_t decoderState=0; uint32_t decoderState=0;
//uint8_t decoderListSize = 8, pathMetricAppr = 0; //uint8_t decoderListSize = 8, pathMetricAppr = 0;
//time_stats_t polar_decoder_init,polar_rate_matching,decoding,bit_extraction,deinterleaving; //time_stats_t polar_decoder_init,polar_rate_matching,decoding,bit_extraction,deinterleaving;
//time_stats_t path_metric,sorting,update_LLR; //time_stats_t path_metric,sorting,update_LLR;
// FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS); // FT ?? cppcheck fix memset(&pbch_a[0], 0, sizeof(uint8_t) * NR_POLAR_PBCH_PAYLOAD_BITS);
//printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell); //printf("nr_pbch_ue nid_cell %d\n",frame_parms->Nid_cell);
int16_t pbch_e_rx[960]= {0}; //Fixme: previous version erase only NR_POLAR_PBCH_E bytes
pbch_e_rx = &nr_ue_pbch_vars->llr[0]; int16_t pbch_unClipped[960]= {0};
// clear LLR buffer int pbch_e_rx_idx=0;
memset(nr_ue_pbch_vars->llr,0,NR_POLAR_PBCH_E);
int symbol_offset=1; int symbol_offset=1;
if (ue->is_synchronized > 0) if (ue->is_synchronized > 0)
...@@ -447,20 +419,24 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -447,20 +419,24 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
else else
symbol_offset=0; symbol_offset=0;
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
//printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF); //printf("address dataf %p",nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF);
write_output("rxdataF0_pbch.m","rxF0pbch", write_output("rxdataF0_pbch.m","rxF0pbch",
&nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1); &nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF[0][(symbol_offset+1)*frame_parms->ofdm_symbol_size],frame_parms->ofdm_symbol_size*3,1,1);
#endif #endif
// symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot // symbol refers to symbol within SSB. symbol_offset is the offset of the SSB wrt start of slot
for (symbol=1; symbol<4; symbol++) { double log2_maxh;
for (symbol=1; symbol<4; symbol++) {
const uint16_t nb_re=symbol == 2 ? 72 : 180;
struct complex16 rxdataF_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
struct complex16 dl_ch_estimates_ext[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
memset(dl_ch_estimates_ext,0, sizeof dl_ch_estimates_ext);
nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF, nr_pbch_extract(nr_ue_common_vars->common_vars_rx_data_per_thread[proc->thread_id].rxdataF,
nr_ue_pbch_vars->dl_ch_estimates, estimateSz,
nr_ue_pbch_vars->rxdataF_ext, dl_ch_estimates,
nr_ue_pbch_vars->dl_ch_estimates_ext, rxdataF_ext,
dl_ch_estimates_ext,
symbol, symbol,
symbol_offset, symbol_offset,
frame_parms); frame_parms);
...@@ -470,142 +446,139 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue, ...@@ -470,142 +446,139 @@ int nr_rx_pbch( PHY_VARS_NR_UE *ue,
#endif #endif
if (symbol == 1) { if (symbol == 1) {
max_h = nr_pbch_channel_level(nr_ue_pbch_vars->dl_ch_estimates_ext, max_h = nr_pbch_channel_level(dl_ch_estimates_ext,
frame_parms, frame_parms,
symbol); nb_re);
nr_ue_pbch_vars->log2_maxh = 3+(log2_approx(max_h)/2); log2_maxh = 3+(log2_approx(max_h)/2);
} }
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
LOG_I(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",nr_ue_pbch_vars->log2_maxh,max_h); LOG_I(PHY,"[PHY] PBCH log2_maxh = %d (%d)\n",nr_ue_pbch_vars->log2_maxh,max_h);
#endif #endif
nr_pbch_channel_compensation(nr_ue_pbch_vars->rxdataF_ext, struct complex16 rxdataF_comp[frame_parms->nb_antennas_rx][PBCH_MAX_RE_PER_SYMBOL];
nr_ue_pbch_vars->dl_ch_estimates_ext, nr_pbch_channel_compensation(rxdataF_ext,
nr_ue_pbch_vars->rxdataF_comp, dl_ch_estimates_ext,
nb_re,
rxdataF_comp,
frame_parms, frame_parms,
symbol, log2_maxh); // log2_maxh+I0_shift
nr_ue_pbch_vars->log2_maxh); // log2_maxh+I0_shift
/*if (frame_parms->nb_antennas_rx > 1) /*if (frame_parms->nb_antennas_rx > 1)
pbch_detection_mrc(frame_parms, pbch_detection_mrc(frame_parms,
nr_ue_pbch_vars->rxdataF_comp, rxdataF_comp,
symbol);*/ symbol);*/
/* /*
if (mimo_mode == ALAMOUTI) { if (mimo_mode == ALAMOUTI) {
nr_pbch_alamouti(frame_parms,nr_ue_pbch_vars->rxdataF_comp,symbol); nr_pbch_alamouti(frame_parms,rxdataF_comp,symbol);
} else if (mimo_mode != SISO) { } else if (mimo_mode != SISO) {
LOG_I(PHY,"[PBCH][RX] Unsupported MIMO mode\n"); LOG_I(PHY,"[PBCH][RX] Unsupported MIMO mode\n");
return(-1); return(-1);
} }
*/ */
if (symbol==2) { int nb=symbol==2 ? 144 : 360;
nr_pbch_quantize(pbch_e_rx, nr_pbch_quantize(pbch_e_rx+pbch_e_rx_idx,
(short *)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]), (short *)rxdataF_comp[0],
144); nb);
pbch_e_rx+=144; memcpy(pbch_unClipped+pbch_e_rx_idx, rxdataF_comp[0], nb*sizeof(int16_t));
} else { pbch_e_rx_idx+=nb;
nr_pbch_quantize(pbch_e_rx,
(short *)&(nr_ue_pbch_vars->rxdataF_comp[0][symbol*240]),
360);
pbch_e_rx+=360;
}
} }
// legacy code use int16, but it is complex16
UEscopeCopy(ue, pbchRxdataF_comp, pbch_unClipped, sizeof(struct complex16), frame_parms->nb_antennas_rx, pbch_e_rx_idx/2);
UEscopeCopy(ue, pbchLlr, pbch_e_rx, sizeof(int16_t), frame_parms->nb_antennas_rx, pbch_e_rx_idx);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
write_output("rxdataF_comp.m","rxFcomp",&nr_ue_pbch_vars->rxdataF_comp[0][240],240*3,1,1); write_output("rxdataF_comp.m","rxFcomp",rxdataF_comp[0],240*3,1,1);
#endif short *p = (short *)rxdataF_comp[0]);
pbch_e_rx = nr_ue_pbch_vars->llr;
//demod_pbch_e = nr_ue_pbch_vars->demod_pbch_e;
// FT?? cppcheck fix - pbch_a = nr_ue_pbch_vars->pbch_a;
#ifdef DEBUG_PBCH
//pbch_e_rx = &nr_ue_pbch_vars->llr[0];
short *p = (short *)&(nr_ue_pbch_vars->rxdataF_comp[0][20*12]);
for (int cnt = 0; cnt < 864 ; cnt++) for (int cnt = 0; cnt < 864 ; cnt++)
printf("pbch rx llr %d\n",*(pbch_e_rx+cnt)); printf("pbch rx llr %d\n",*(pbch_e_rx+cnt));
#endif #endif
//un-scrambling //un-scrambling
M = NR_POLAR_PBCH_E; M = NR_POLAR_PBCH_E;
nushift = (Lmax==4)? i_ssb&3 : i_ssb&7; nushift = (Lmax==4)? i_ssb&3 : i_ssb&7;
uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041; uint32_t unscrambling_mask = (Lmax==64)?0x100006D:0x1000041;
uint32_t pbch_a_interleaved=0;
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_E,0,0); uint32_t pbch_a_prime=0;
nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_E,
0, 0, pbch_a_prime, &pbch_a_interleaved);
//polar decoding de-rate matching //polar decoding de-rate matching
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&nr_ue_pbch_vars->pbch_a_prime,0, uint64_t tmp=0;
decoderState = polar_decoder_int16(pbch_e_rx,(uint64_t *)&tmp,0,
NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL); NR_POLAR_PBCH_MESSAGE_TYPE, NR_POLAR_PBCH_PAYLOAD_BITS, NR_POLAR_PBCH_AGGREGATION_LEVEL);
pbch_a_prime=tmp;
if(decoderState)
return(decoderState);
if(decoderState) return(decoderState); // printf("polar decoder output 0x%08x\n",pbch_a_prime);
// printf("polar decoder output 0x%08x\n",nr_ue_pbch_vars->pbch_a_prime);
// Decoder reversal // Decoder reversal
uint32_t a_reversed=0; uint32_t a_reversed=0;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
a_reversed |= (((uint64_t)nr_ue_pbch_vars->pbch_a_prime>>i)&1)<<(31-i); a_reversed |= (((uint64_t)pbch_a_prime>>i)&1)<<(31-i);
nr_ue_pbch_vars->pbch_a_prime = a_reversed; pbch_a_prime = a_reversed;
//payload un-scrambling //payload un-scrambling
nr_ue_pbch_vars->pbch_a_interleaved=0;
M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3); M = (Lmax == 64)? (NR_POLAR_PBCH_PAYLOAD_BITS - 6) : (NR_POLAR_PBCH_PAYLOAD_BITS - 3);
nushift = ((nr_ue_pbch_vars->pbch_a_prime>>24)&1) ^ (((nr_ue_pbch_vars->pbch_a_prime>>6)&1)<<1); nushift = ((pbch_a_prime>>24)&1) ^ (((pbch_a_prime>>6)&1)<<1);
nr_pbch_unscrambling(nr_ue_pbch_vars,frame_parms->Nid_cell,nushift,M,NR_POLAR_PBCH_PAYLOAD_BITS,1,unscrambling_mask); pbch_a_interleaved=0;
//printf("nushift %d sfn 3rd %d 2nd %d", nushift,((nr_ue_pbch_vars->pbch_a_prime>>6)&1), ((nr_ue_pbch_vars->pbch_a_prime>>24)&1) ); nr_pbch_unscrambling(nr_ue_pbch_vars, pbch_e_rx, frame_parms->Nid_cell, nushift, M, NR_POLAR_PBCH_PAYLOAD_BITS,
1, unscrambling_mask, pbch_a_prime, &pbch_a_interleaved);
//printf("nushift %d sfn 3rd %d 2nd %d", nushift,((pbch_a_prime>>6)&1), ((pbch_a_prime>>24)&1) );
//payload deinterleaving //payload deinterleaving
//uint32_t in=0; //uint32_t in=0;
uint32_t out=0; uint32_t out=0;
for (int i=0; i<32; i++) { for (int i=0; i<32; i++) {
out |= ((nr_ue_pbch_vars->pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]); out |= ((pbch_a_interleaved>>i)&1)<<(pbch_deinterleaving_pattern[i]);
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, nr_ue_pbch_vars->pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (nr_ue_pbch_vars->pbch_a_interleaved>>i)&1); printf("i %d in 0x%08x out 0x%08x ilv %d (in>>i)&1) 0x%08x\n", i, pbch_a_interleaved, out, pbch_deinterleaving_pattern[i], (pbch_a_interleaved>>i)&1);
#endif #endif
} }
uint32_t payload = 0; uint32_t payload = 0;
//uint8_t xtra_byte = 0; result->xtra_byte = (out>>24)&0xff;
nr_ue_pbch_vars->xtra_byte = (out>>24)&0xff;
for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++) for (int i=0; i<NR_POLAR_PBCH_PAYLOAD_BITS; i++)
payload |= ((out>>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1); payload |= ((out>>i)&1)<<(NR_POLAR_PBCH_PAYLOAD_BITS-i-1);
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff); result->decoded_output[i] = (uint8_t)((payload>>((3-i)<<3))&0xff);
frame_parms->half_frame_bit = ((nr_ue_pbch_vars->xtra_byte>>4)&0x01); // computing the half frame index from the extra byte frame_parms->half_frame_bit = (result->xtra_byte>>4)&0x01; // computing the half frame index from the extra byte
frame_parms->ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8 frame_parms->ssb_index = i_ssb; // ssb index corresponds to i_ssb for Lmax = 4,8
if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte if (Lmax == 64) { // for Lmax = 64 ssb index 4th,5th and 6th bits are in extra byte
for (int i=0; i<3; i++) for (int i=0; i<3; i++)
frame_parms->ssb_index += (((nr_ue_pbch_vars->xtra_byte>>(7-i))&0x01)<<(3+i)); frame_parms->ssb_index += (((result->xtra_byte>>(7-i))&0x01)<<(3+i));
} }
ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms,frame_parms->ssb_index); ue->symbol_offset = nr_get_ssb_start_symbol(frame_parms,frame_parms->ssb_index);
if (frame_parms->half_frame_bit) if (frame_parms->half_frame_bit)
ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot; ue->symbol_offset += (frame_parms->slots_per_frame>>1)*frame_parms->symbols_per_slot;
uint8_t frame_number_4lsb = 0; uint8_t frame_number_4lsb = 0;
for (int i=0; i<4; i++)
frame_number_4lsb |= ((nr_ue_pbch_vars->xtra_byte>>i)&1)<<(3-i);
for (int i=0; i<4; i++)
frame_number_4lsb |= ((result->xtra_byte>>i)&1)<<(3-i);
proc->decoded_frame_rx = frame_number_4lsb; proc->decoded_frame_rx = frame_number_4lsb;
#ifdef DEBUG_PBCH #ifdef DEBUG_PBCH
printf("xtra_byte %x payload %x\n", nr_ue_pbch_vars->xtra_byte, payload); printf("xtra_byte %x payload %x\n", xtra_byte, payload);
for (int i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) { for (int i=0; i<(NR_POLAR_PBCH_PAYLOAD_BITS>>3); i++) {
// printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]); // printf("unscrambling pbch_a[%d] = %x \n", i,pbch_a[i]);
printf("[PBCH] decoder payload[%d] = %x\n",i,decoded_output[i]); printf("[PBCH] decoder payload[%d] = %x\n",i,result->decoded_output[i]);
} }
#endif
#endif
nr_downlink_indication_t dl_indication; nr_downlink_indication_t dl_indication;
fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1); fapi_nr_rx_indication_t *rx_ind=calloc(sizeof(*rx_ind),1);
uint16_t number_pdus = 1; uint16_t number_pdus = 1;
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc); nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SSB, gNB_id, ue, NULL, NULL, number_pdus, proc,(void *)result);
if (ue->if_inst && ue->if_inst->dl_indication) if (ue->if_inst && ue->if_inst->dl_indication)
ue->if_inst->dl_indication(&dl_indication, NULL); ue->if_inst->dl_indication(&dl_indication, NULL);
......
...@@ -1152,11 +1152,14 @@ int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uin ...@@ -1152,11 +1152,14 @@ int rx_sss(PHY_VARS_NR_UE *phy_vars_ue,int32_t *tot_metric,uint8_t *flip_max,uin
*/ */
int nr_rx_pbch( PHY_VARS_NR_UE *ue, int nr_rx_pbch( PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
const int estimateSz,
struct complex16 dl_ch_estimates[][estimateSz],
NR_UE_PBCH *nr_ue_pbch_vars, NR_UE_PBCH *nr_ue_pbch_vars,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
uint8_t eNB_id, uint8_t eNB_id,
uint8_t i_ssb, uint8_t i_ssb,
MIMO_mode_t mimo_mode); MIMO_mode_t mimo_mode,
fapiPbch_t* result);
int nr_pbch_detection(UE_nr_rxtx_proc_t *proc, int nr_pbch_detection(UE_nr_rxtx_proc_t *proc,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
......
...@@ -861,7 +861,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain ...@@ -861,7 +861,7 @@ int pss_search_time_nr(int **rxdata, ///rx data in time domain
/* perform correlation of rx data and pss sequence ie it is a dot product */ /* perform correlation of rx data and pss sequence ie it is a dot product */
result = dot_product64((short*)primary_synchro_time_nr[pss_index], result = dot_product64((short*)primary_synchro_time_nr[pss_index],
(short*) &(rxdata[ar][n+is*frame_parms->samples_per_frame]), (short*)&(rxdata[ar][n+is*frame_parms->samples_per_frame]),
frame_parms->ofdm_symbol_size, frame_parms->ofdm_symbol_size,
shift); shift);
pss_corr_ue[pss_index][n] += abs64(result); pss_corr_ue[pss_index][n] += abs64(result);
......
...@@ -40,6 +40,13 @@ const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED}; ...@@ -40,6 +40,13 @@ const FL_COLOR water_colors[4] = {FL_BLUE,FL_GREEN,FL_YELLOW,FL_RED};
typedef struct complex16 scopeSample_t; typedef struct complex16 scopeSample_t;
#define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i) #define SquaredNorm(VaR) ((VaR).r*(VaR).r+(VaR).i*(VaR).i)
typedef struct {
int dataSize;
int elementSz;
int colSz;
int lineSz;
} scopeGraphData_t;
typedef struct OAIgraph { typedef struct OAIgraph {
FL_OBJECT *graph; FL_OBJECT *graph;
FL_OBJECT *text; FL_OBJECT *text;
...@@ -56,7 +63,7 @@ typedef struct OAIgraph { ...@@ -56,7 +63,7 @@ typedef struct OAIgraph {
boolean_t initDone; boolean_t initDone;
int iteration; int iteration;
void (*gNBfunct) (struct OAIgraph *graph, scopeData_t *p, int UE_id); void (*gNBfunct) (struct OAIgraph *graph, scopeData_t *p, int UE_id);
void (*nrUEfunct)(struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id); void (*nrUEfunct)(scopeGraphData_t **data, struct OAIgraph *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id);
} OAIgraph_t; } OAIgraph_t;
/* Forms and Objects */ /* Forms and Objects */
...@@ -140,7 +147,7 @@ static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, scopeData_t ...@@ -140,7 +147,7 @@ static OAIgraph_t gNBcommonGraph( void (*funct) (OAIgraph_t *graph, scopeData_t
return graph; return graph;
} }
static OAIgraph_t nrUEcommonGraph( void (*funct) (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id), static OAIgraph_t nrUEcommonGraph( void (*funct) (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id),
int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) { int type, FL_Coord x, FL_Coord y, FL_Coord w, FL_Coord h, const char *label, FL_COLOR pointColor) {
OAIgraph_t graph; OAIgraph_t graph;
commonGraph(&graph, type, x, y, w, h, label, pointColor); commonGraph(&graph, type, x, y, w, h, label, pointColor);
...@@ -341,7 +348,7 @@ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { ...@@ -341,7 +348,7 @@ static void timeResponse (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
static void gNBfreqWaterFall (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) { static void gNBfreqWaterFall (OAIgraph_t *graph, scopeData_t *p, int nb_UEs) {
NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms; NR_DL_FRAME_PARMS *frame_parms=&p->gNB->frame_parms;
//use 1st antenna //use 1st antenna
genericWaterFall(graph, (scopeSample_t *)p->rxdataF, frame_parms->samples_per_frame_wCP, genericWaterFall(graph, (scopeSample_t *)p->liveData, frame_parms->samples_per_frame_wCP,
frame_parms->slots_per_frame, frame_parms->slots_per_frame,
"X axis: Frequency domain, one subframe"); "X axis: Frequency domain, one subframe");
} }
...@@ -515,6 +522,7 @@ void phy_scope_gNB(OAI_phy_scope_t *form, ...@@ -515,6 +522,7 @@ void phy_scope_gNB(OAI_phy_scope_t *form,
//fl_check_forms(); //fl_check_forms();
} }
static void *scope_thread_gNB(void *arg) { static void *scope_thread_gNB(void *arg) {
scopeData_t *p=(scopeData_t *) arg; scopeData_t *p=(scopeData_t *) arg;
size_t stksize=0; size_t stksize=0;
...@@ -539,11 +547,12 @@ static void *scope_thread_gNB(void *arg) { ...@@ -539,11 +547,12 @@ static void *scope_thread_gNB(void *arg) {
return NULL; return NULL;
} }
static void copyRxdataF(int32_t *data, int slot, void *scopeData) { static void copyRxdataF(int32_t *data, int slot, void *scopeData) {
scopeData_t *scope=(scopeData_t *)scopeData; scopeData_t *scope=(scopeData_t *)scopeData;
memcpy(scope->rxdataF + slot*scope->gNB->frame_parms.samples_per_slot_wCP, memcpy(((int32_t *)scope->liveData) + slot*scope->gNB->frame_parms.samples_per_slot_wCP,
data, data,
scope->gNB->frame_parms.samples_per_slot_wCP); scope->gNB->frame_parms.samples_per_slot_wCP*sizeof(int32_t));
} }
void gNBinitScope(scopeParms_t *p) { void gNBinitScope(scopeParms_t *p) {
...@@ -554,11 +563,11 @@ void gNBinitScope(scopeParms_t *p) { ...@@ -554,11 +563,11 @@ void gNBinitScope(scopeParms_t *p) {
scope->ru=p->ru; scope->ru=p->ru;
scope->gNB=p->gNB; scope->gNB=p->gNB;
scope->slotFunc=copyRxdataF; scope->slotFunc=copyRxdataF;
AssertFatal(scope->rxdataF=(int32_t *) calloc(p->gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t),1),""); AssertFatal(scope->liveData= calloc(p->gNB->frame_parms.samples_per_frame_wCP*sizeof(int32_t),1),"");
pthread_t forms_thread; pthread_t forms_thread;
threadCreate(&forms_thread, scope_thread_gNB, p->gNB->scopeData, "scope", -1, OAI_PRIORITY_RT_LOW); threadCreate(&forms_thread, scope_thread_gNB, p->gNB->scopeData, "scope", -1, OAI_PRIORITY_RT_LOW);
} }
static void ueWaterFall (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void ueWaterFall (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// Received signal in time domain of receive antenna 0 // Received signal in time domain of receive antenna 0
genericWaterFall(graph, genericWaterFall(graph,
(scopeSample_t *) phy_vars_ue->common_vars.rxdata[0], (scopeSample_t *) phy_vars_ue->common_vars.rxdata[0],
...@@ -574,13 +583,19 @@ static void ueTimeResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int ...@@ -574,13 +583,19 @@ static void ueTimeResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int
phy_vars_ue->frame_parms.samples_per_frame); phy_vars_ue->frame_parms.samples_per_frame);
} }
*/ */
static void ueChannelResponse (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
static void ueChannelResponse (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// Channel Impulse Response // Channel Impulse Response
genericPowerPerAntena(graph, phy_vars_ue->frame_parms.nb_antennas_rx, if (!data[pbchDlChEstimateTime])
(const scopeSample_t **) phy_vars_ue->pbch_vars[eNB_id]->dl_ch_estimates_time, return;
phy_vars_ue->frame_parms.ofdm_symbol_size>>3);
const scopeSample_t *tmp=(scopeSample_t *)(data[pbchDlChEstimateTime]+1);
genericPowerPerAntena(graph, data[pbchDlChEstimateTime]->colSz,
&tmp,
data[pbchDlChEstimateTime]->lineSz);
} }
static void ueFreqWaterFall (OAIgraph_t *graph,PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id ) {
static void ueFreqWaterFall (scopeGraphData_t **data, OAIgraph_t *graph,PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id ) {
NR_DL_FRAME_PARMS *frame_parms=&phy_vars_ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms=&phy_vars_ue->frame_parms;
//use 1st antenna //use 1st antenna
genericWaterFall(graph, genericWaterFall(graph,
...@@ -624,56 +639,44 @@ static void uePbchFrequencyResp (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue ...@@ -624,56 +639,44 @@ static void uePbchFrequencyResp (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue
oai_xygraph(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,0,10); oai_xygraph(graph,freq,chest_f_abs,frame_parms->ofdm_symbol_size,0,10);
} }
*/ */
static void uePbchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void uePbchLLR (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PBCH LLRs // PBCH LLRs
if ( !phy_vars_ue->pbch_vars[eNB_id]->llr) if ( !data[pbchLlr])
return; return;
int16_t *pbch_llr = (int16_t *) phy_vars_ue->pbch_vars[eNB_id]->llr; const int sz=data[pbchLlr]->lineSz;
//const int antennas=data[pbchLlr]->colSz;
// We take the first antenna only for now
int16_t *llrs = (int16_t *) (data[pbchLlr]+1);
float *llr_pbch, *bit_pbch; float *llr_pbch, *bit_pbch;
oai_xygraph_getbuff(graph, &bit_pbch, &llr_pbch, 864, 0); oai_xygraph_getbuff(graph, &bit_pbch, &llr_pbch, sz, 0);
for (int i=0; i<864; i++) { for (int i=0; i<sz; i++) {
llr_pbch[i] = (float) pbch_llr[i]; llr_pbch[i] = llrs[i];
} }
oai_xygraph(graph,bit_pbch,llr_pbch,864,0,10); oai_xygraph(graph,bit_pbch,llr_pbch,sz,0,10);
} }
static void uePbchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
static void uePbchIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PBCH I/Q of MF Output // PBCH I/Q of MF Output
if (!phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]) if (!data[pbchRxdataF_comp])
return; return;
scopeSample_t *pbch_comp = (scopeSample_t *) phy_vars_ue->pbch_vars[eNB_id]->rxdataF_comp[0]; scopeSample_t *pbch_comp = (scopeSample_t *) (data[pbchRxdataF_comp]+1);
const int sz=data[pbchRxdataF_comp]->lineSz;
float *I, *Q; float *I, *Q;
oai_xygraph_getbuff(graph, &I, &Q, 180*3, 0); oai_xygraph_getbuff(graph, &I, &Q, sz, 0);
memset(I,0,180*3*sizeof(*I));
memset(Q,0,180*3*sizeof(*Q));
int first_symbol=1;
int base=0;
for (int symbol=first_symbol; symbol<(first_symbol+3); symbol++) {
int nb_re;
if (symbol == 2 || symbol == 6)
nb_re = 72;
else
nb_re = 180;
AssertFatal(base+nb_re<180*3,"");
for (int i=0; i<nb_re; i++) {
I[base+i] = pbch_comp[symbol*20*12+i].r;
Q[base+i] = pbch_comp[symbol*20*12+i].i;
}
base+=nb_re; for (int i=0; i<sz; i++) {
I[i]=pbch_comp[i].r;
Q[i]=pbch_comp[i].i;
} }
AssertFatal(base <= 180*3,""); oai_xygraph(graph, I, Q, sz, 0, true);
oai_xygraph(graph,I,Q,base,0, 10);
} }
static void uePcchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
static void uePcchLLR (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PDCCH LLRs // PDCCH LLRs
if (!phy_vars_ue->pdcch_vars[0][eNB_id]->llr) if (!phy_vars_ue->pdcch_vars[0][eNB_id]->llr)
return; return;
...@@ -698,7 +701,7 @@ static void uePcchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_ ...@@ -698,7 +701,7 @@ static void uePcchLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_
AssertFatal(base <= coded_bits_per_codeword*RX_NB_TH_MAX, ""); AssertFatal(base <= coded_bits_per_codeword*RX_NB_TH_MAX, "");
oai_xygraph(graph,bit,llr,base,0,10); oai_xygraph(graph,bit,llr,base,0,10);
} }
static void uePcchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void uePcchIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PDCCH I/Q of MF Output // PDCCH I/Q of MF Output
if (!phy_vars_ue->pdcch_vars[0][eNB_id]->rxdataF_comp[0]) if (!phy_vars_ue->pdcch_vars[0][eNB_id]->rxdataF_comp[0])
return; return;
...@@ -722,7 +725,7 @@ static void uePcchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i ...@@ -722,7 +725,7 @@ static void uePcchIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_i
AssertFatal(base <= nb*RX_NB_TH_MAX, ""); AssertFatal(base <= nb*RX_NB_TH_MAX, "");
oai_xygraph(graph,I,Q,base,0,10); oai_xygraph(graph,I,Q,base,0,10);
} }
static void uePdschLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void uePdschLLR (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PDSCH LLRs // PDSCH LLRs
if (!phy_vars_ue->pdsch_vars[0][eNB_id]->llr[0]) if (!phy_vars_ue->pdsch_vars[0][eNB_id]->llr[0])
return; return;
...@@ -749,7 +752,7 @@ static void uePdschLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB ...@@ -749,7 +752,7 @@ static void uePdschLLR (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB
//fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword); //fl_set_xyplot_xbounds(form->pdsch_llr,0,coded_bits_per_codeword);
oai_xygraph(graph,bit,llr,base,0,10); oai_xygraph(graph,bit,llr,base,0,10);
} }
static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void uePdschIQ (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
// PDSCH I/Q of MF Output // PDSCH I/Q of MF Output
if (!phy_vars_ue->pdsch_vars[0][eNB_id]->rxdataF_comp0[0]) if (!phy_vars_ue->pdsch_vars[0][eNB_id]->rxdataF_comp0[0])
return; return;
...@@ -776,7 +779,7 @@ static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_ ...@@ -776,7 +779,7 @@ static void uePdschIQ (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_
AssertFatal(base <= sz*RX_NB_TH_MAX, ""); AssertFatal(base <= sz*RX_NB_TH_MAX, "");
oai_xygraph(graph,I,Q,sz*RX_NB_TH_MAX,0,10); oai_xygraph(graph,I,Q,sz*RX_NB_TH_MAX,0,10);
} }
static void uePdschThroughput (OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) { static void uePdschThroughput (scopeGraphData_t **data, OAIgraph_t *graph, PHY_VARS_NR_UE *phy_vars_ue, int eNB_id, int UE_id) {
/* /*
float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_time_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}}; float tput_ue[NUMBER_OF_UE_MAX][TPUT_WINDOW_LENGTH] = {{0}};
...@@ -869,7 +872,9 @@ static OAI_phy_scope_t *create_phy_scope_nrue( int ID ) { ...@@ -869,7 +872,9 @@ static OAI_phy_scope_t *create_phy_scope_nrue( int ID ) {
fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, buf); fl_show_form (fdui->phy_scope, FL_PLACE_HOTSPOT, FL_FULLBORDER, buf);
return fdui; return fdui;
} }
void phy_scope_nrUE(OAI_phy_scope_t *form,
void phy_scope_nrUE(scopeGraphData_t **UEliveData,
OAI_phy_scope_t *form,
PHY_VARS_NR_UE *phy_vars_ue, PHY_VARS_NR_UE *phy_vars_ue,
int eNB_id, int eNB_id,
int UE_id) { int UE_id) {
...@@ -886,26 +891,29 @@ void phy_scope_nrUE(OAI_phy_scope_t *form, ...@@ -886,26 +891,29 @@ void phy_scope_nrUE(OAI_phy_scope_t *form,
int i=0; int i=0;
while (form->graph[i].graph) { while (form->graph[i].graph) {
form->graph[i].nrUEfunct(form->graph+i, phy_vars_ue, eNB_id, UE_id); form->graph[i].nrUEfunct(UEliveData, form->graph+i, phy_vars_ue, eNB_id, UE_id);
i++; i++;
} }
//fl_check_forms(); //fl_check_forms();
} }
static void *nrUEscopeThread(void *arg) { static void *nrUEscopeThread(void *arg) {
PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg; PHY_VARS_NR_UE *ue=(PHY_VARS_NR_UE *)arg;
size_t stksize; size_t stksize;
pthread_attr_t atr={0}; pthread_attr_t atr= {0};
pthread_attr_getstacksize(&atr, &stksize); pthread_attr_getstacksize(&atr, &stksize);
pthread_attr_setstacksize(&atr,32*1024*1024 ); pthread_attr_setstacksize(&atr,32*1024*1024 );
int fl_argc=1; int fl_argc=1;
char *name="5G-UE-scope"; char *name="5G-UE-scope";
fl_initialize (&fl_argc, &name, NULL, 0, 0); fl_initialize (&fl_argc, &name, NULL, 0, 0);
OAI_phy_scope_t *form_nrue=create_phy_scope_nrue(0); OAI_phy_scope_t *form_nrue=create_phy_scope_nrue(0);
(( scopeData_t *)ue->scopeData)->liveData=calloc(sizeof(scopeGraphData_t *), UEdataTypeNumberOfItems);
while (!oai_exit) { while (!oai_exit) {
fl_freeze_form(form_nrue->phy_scope); fl_freeze_form(form_nrue->phy_scope);
phy_scope_nrUE(form_nrue, phy_scope_nrUE((( scopeData_t *)ue->scopeData)->liveData,
form_nrue,
ue, ue,
0,0); 0,0);
fl_unfreeze_form(form_nrue->phy_scope); fl_unfreeze_form(form_nrue->phy_scope);
...@@ -915,10 +923,41 @@ static void *nrUEscopeThread(void *arg) { ...@@ -915,10 +923,41 @@ static void *nrUEscopeThread(void *arg) {
pthread_exit((void *)arg); pthread_exit((void *)arg);
} }
void UEcopyData(PHY_VARS_NR_UE *ue, enum UEdataType type, void *dataIn, int elementSz, int colSz, int lineSz) {
scopeData_t *tmp=(scopeData_t *)ue->scopeData;
if (tmp) {
scopeGraphData_t *live= ((scopeGraphData_t **)tmp->liveData)[type];
if (live == NULL || live->dataSize < elementSz*colSz*lineSz) {
scopeGraphData_t *ptr=realloc(live, sizeof(scopeGraphData_t) + elementSz*colSz*lineSz);
if (!ptr) {
LOG_E(PHY,"can't realloc\n");
return;
} else {
live=ptr;
}
}
live->dataSize=elementSz*colSz*lineSz;
live->elementSz=elementSz;
live->colSz=colSz;
live->lineSz=lineSz;
memcpy(live+1, dataIn, elementSz*colSz*lineSz);
((scopeGraphData_t **)tmp->liveData)[type]=live;
}
}
void nrUEinitScope(PHY_VARS_NR_UE *ue) { void nrUEinitScope(PHY_VARS_NR_UE *ue) {
AssertFatal(ue->scopeData=malloc(sizeof(scopeData_t)),"");
scopeData_t *scope=(scopeData_t *) ue->scopeData;
scope->copyData=UEcopyData;
pthread_t forms_thread; pthread_t forms_thread;
threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW); threadCreate(&forms_thread, nrUEscopeThread, ue, "scope", -1, OAI_PRIORITY_RT_LOW);
} }
void nrscope_autoinit(void *dataptr) { void nrscope_autoinit(void *dataptr) {
AssertFatal( (IS_SOFTMODEM_GNB_BIT||IS_SOFTMODEM_5GUE_BIT),"Scope cannot find NRUE or GNB context"); AssertFatal( (IS_SOFTMODEM_GNB_BIT||IS_SOFTMODEM_5GUE_BIT),"Scope cannot find NRUE or GNB context");
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
#ifndef __PHY_SCOPE_INTERFACE_H__ #ifndef __PHY_SCOPE_INTERFACE_H__
#define __PHY_SCOPE_INTERFACE_H__ #define __PHY_SCOPE_INTERFACE_H__
#include <openair1/PHY/defs_gNB.h> #include <openair1/PHY/defs_gNB.h>
#include <openair1/PHY/defs_nr_UE.h>
typedef struct { typedef struct {
int *argc; int *argc;
char **argv; char **argv;
...@@ -39,16 +41,25 @@ typedef struct { ...@@ -39,16 +41,25 @@ typedef struct {
PHY_VARS_gNB *gNB; PHY_VARS_gNB *gNB;
} scopeParms_t; } scopeParms_t;
enum UEdataType {
pbchDlChEstimateTime,
pbchLlr,
pbchRxdataF_comp,
UEdataTypeNumberOfItems
};
typedef struct scopeData_s { typedef struct scopeData_s {
int *argc; int *argc;
char **argv; char **argv;
RU_t *ru; RU_t *ru;
PHY_VARS_gNB *gNB; PHY_VARS_gNB *gNB;
int32_t * rxdataF; void *liveData;
void (*slotFunc)(int32_t* data, int slot, void * scopeData); void (*slotFunc)(int32_t *data, int slot, void *scopeData);
void (*copyData)(PHY_VARS_NR_UE *,enum UEdataType, void *data, int elementSz, int colSz, int lineSz);
} scopeData_t; } scopeData_t;
int load_softscope(char *exectype, void *initarg); int load_softscope(char *exectype, void *initarg);
int end_forms(void) ; int end_forms(void) ;
#define UEscopeCopy(ue, type, ...) if(ue->scopeData) ((scopeData_t*)ue->scopeData)->copyData(ue, type, ##__VA_ARGS__);
#endif #endif
...@@ -837,6 +837,7 @@ typedef struct { ...@@ -837,6 +837,7 @@ typedef struct {
/// RF and Interface devices per CC /// RF and Interface devices per CC
openair0_device rfdevice; openair0_device rfdevice;
void *scopeData;
} PHY_VARS_UE; } PHY_VARS_UE;
/* this structure is used to pass both UE phy vars and /* this structure is used to pass both UE phy vars and
......
...@@ -654,40 +654,6 @@ typedef struct { ...@@ -654,40 +654,6 @@ typedef struct {
#define PBCH_A 24 #define PBCH_A 24
typedef struct { typedef struct {
/// \brief Pointers to extracted PBCH symbols in frequency-domain.
/// - first index: rx antenna [0..nb_antennas_rx[
/// - second index: ? [0..287] (hard coded)
int32_t **rxdataF_ext;
/// \brief Pointers to extracted and compensated PBCH symbols in frequency-domain.
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..287] (hard coded)
int32_t **rxdataF_comp;
/// \brief Hold the channel estimates in frequency domain.
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: samples? [0..symbols_per_tti*(ofdm_symbol_size+LTE_CE_FILTER_LENGTH)[
int32_t **dl_ch_estimates;
/// \brief Pointers to downlink channel estimates in frequency-domain extracted in PRBS.
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: ? [0..287] (hard coded)
int32_t **dl_ch_estimates_ext;
/// \brief Hold the channel estimates in time domain (used for tracking).
/// - first index: ? [0..7] (hard coded) FIXME! accessed via \c nb_antennas_rx
/// - second index: samples? [0..2*ofdm_symbol_size[
int32_t **dl_ch_estimates_time;
int log2_maxh;
uint8_t pbch_a[NR_POLAR_PBCH_PAYLOAD_BITS>>3];
uint32_t pbch_a_interleaved;
uint32_t pbch_a_prime;
uint8_t pbch_e[NR_POLAR_PBCH_E];
int16_t demod_pbch_e[NR_POLAR_PBCH_E];
/// \brief Pointer to PBCH llrs.
/// - first index: ? [0..1919] (hard coded)
int16_t *llr;
/// \brief Pointer to PBCH decoded output.
/// - first index: ? [0..63] (hard coded)
uint8_t *decoded_output;
/// \brief PBCH additional bits
uint8_t xtra_byte;
/// \brief Total number of PDU errors. /// \brief Total number of PDU errors.
uint32_t pdu_errors; uint32_t pdu_errors;
/// \brief Total number of PDU errors 128 frames ago. /// \brief Total number of PDU errors 128 frames ago.
...@@ -695,7 +661,7 @@ typedef struct { ...@@ -695,7 +661,7 @@ typedef struct {
/// \brief Total number of consecutive PDU errors. /// \brief Total number of consecutive PDU errors.
uint32_t pdu_errors_conseq; uint32_t pdu_errors_conseq;
/// \brief FER (in percent) . /// \brief FER (in percent) .
uint32_t pdu_fer; //uint32_t pdu_fer;
} NR_UE_PBCH; } NR_UE_PBCH;
typedef struct { typedef struct {
...@@ -1073,7 +1039,7 @@ typedef struct { ...@@ -1073,7 +1039,7 @@ typedef struct {
#endif #endif
int dl_stats[5]; int dl_stats[5];
void* scopeData;
} PHY_VARS_NR_UE; } PHY_VARS_NR_UE;
/* this structure is used to pass both UE phy vars and /* this structure is used to pass both UE phy vars and
......
...@@ -82,6 +82,11 @@ ...@@ -82,6 +82,11 @@
#define DAQ_AGC_OFF 0 #define DAQ_AGC_OFF 0
typedef struct {
uint8_t decoded_output[64];
uint8_t xtra_byte;
} fapiPbch_t;
/** @addtogroup _PHY_PROCEDURES_ /** @addtogroup _PHY_PROCEDURES_
* @{ * @{
*/ */
...@@ -395,7 +400,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, ...@@ -395,7 +400,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch0,
NR_UE_DLSCH_t *dlsch1, NR_UE_DLSCH_t *dlsch1,
uint16_t n_pdus, uint16_t n_pdus,
UE_nr_rxtx_proc_t *proc); UE_nr_rxtx_proc_t *proc,
void * typeSpecific);
bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,
......
...@@ -118,7 +118,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, ...@@ -118,7 +118,8 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch0,
NR_UE_DLSCH_t *dlsch1, NR_UE_DLSCH_t *dlsch1,
uint16_t n_pdus, uint16_t n_pdus,
UE_nr_rxtx_proc_t *proc ){ UE_nr_rxtx_proc_t *proc,
void * typeSpecific){
NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; NR_DL_FRAME_PARMS *frame_parms = &ue->frame_parms;
...@@ -162,8 +163,11 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, ...@@ -162,8 +163,11 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8; rx_ind->rx_indication_body[n_pdus - 1].pdsch_pdu.pdu_length = dlsch0->harq_processes[dlsch0->current_harq_pid]->TBS / 8;
break; break;
case FAPI_NR_RX_PDU_TYPE_SSB: case FAPI_NR_RX_PDU_TYPE_SSB:
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu = ue->pbch_vars[gNB_id]->decoded_output; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu=malloc(sizeof(((fapiPbch_t*)typeSpecific)->decoded_output));
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.additional_bits = ue->pbch_vars[gNB_id]->xtra_byte; memcpy(rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.pdu,
((fapiPbch_t*)typeSpecific)->decoded_output,
sizeof(((fapiPbch_t*)typeSpecific)->decoded_output));
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.additional_bits = ((fapiPbch_t*)typeSpecific)->xtra_byte;
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_index = (frame_parms->ssb_index)&0x7; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_index = (frame_parms->ssb_index)&0x7;
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.ssb_length = frame_parms->Lmax;
rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell; rx_ind->rx_indication_body[n_pdus - 1].ssb_pdu.cell_id = frame_parms->Nid_cell;
...@@ -353,10 +357,9 @@ void nr_ue_measurement_procedures(uint16_t l, ...@@ -353,10 +357,9 @@ void nr_ue_measurement_procedures(uint16_t l,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_MEASUREMENT_PROCEDURES, VCD_FUNCTION_OUT);
} }
void nr_ue_pbch_procedures(uint8_t gNB_id, static void nr_ue_pbch_procedures(uint8_t gNB_id,
PHY_VARS_NR_UE *ue, PHY_VARS_NR_UE *ue,
UE_nr_rxtx_proc_t *proc, UE_nr_rxtx_proc_t *proc,int estimateSz, struct complex16 dl_ch_estimates[][estimateSz])
uint8_t abstraction_flag)
{ {
int ret = 0; int ret = 0;
...@@ -368,13 +371,15 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, ...@@ -368,13 +371,15 @@ void nr_ue_pbch_procedures(uint8_t gNB_id,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_PBCH_PROCEDURES, VCD_FUNCTION_IN);
LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,nr_slot_rx,ue->frame_parms.Nid_cell,gNB_id); LOG_D(PHY,"[UE %d] Frame %d Slot %d, Trying PBCH (NidCell %d, gNB_id %d)\n",ue->Mod_id,frame_rx,nr_slot_rx,ue->frame_parms.Nid_cell,gNB_id);
fapiPbch_t result;
ret = nr_rx_pbch(ue, proc, ret = nr_rx_pbch(ue, proc,
estimateSz, dl_ch_estimates,
ue->pbch_vars[gNB_id], ue->pbch_vars[gNB_id],
&ue->frame_parms, &ue->frame_parms,
gNB_id, gNB_id,
(ue->frame_parms.ssb_index)&7, (ue->frame_parms.ssb_index)&7,
SISO); SISO,
&result);
if (ret==0) { if (ret==0) {
...@@ -444,7 +449,6 @@ void nr_ue_pbch_procedures(uint8_t gNB_id, ...@@ -444,7 +449,6 @@ void nr_ue_pbch_procedures(uint8_t gNB_id,
} }
if (frame_rx % 100 == 0) { if (frame_rx % 100 == 0) {
ue->pbch_vars[gNB_id]->pdu_fer = ue->pbch_vars[gNB_id]->pdu_errors - ue->pbch_vars[gNB_id]->pdu_errors_last;
ue->pbch_vars[gNB_id]->pdu_errors_last = ue->pbch_vars[gNB_id]->pdu_errors; ue->pbch_vars[gNB_id]->pdu_errors_last = ue->pbch_vars[gNB_id]->pdu_errors;
} }
...@@ -795,16 +799,16 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue, ...@@ -795,16 +799,16 @@ bool nr_ue_dlsch_procedures(PHY_VARS_NR_UE *ue,
switch (pdsch) { switch (pdsch) {
case RA_PDSCH: case RA_PDSCH:
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc); nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_RAR, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
ue->UE_mode[gNB_id] = RA_RESPONSE; ue->UE_mode[gNB_id] = RA_RESPONSE;
break; break;
case PDSCH: case PDSCH:
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc); nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_DLSCH, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
break; break;
case SI_PDSCH: case SI_PDSCH:
nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id); nr_fill_dl_indication(&dl_indication, NULL, rx_ind, proc, ue, gNB_id);
nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc); nr_fill_rx_indication(rx_ind, FAPI_NR_RX_PDU_TYPE_SIB, gNB_id, ue, dlsch0, NULL, number_pdus, proc, NULL);
break; break;
default: default:
break; break;
...@@ -1400,6 +1404,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1400,6 +1404,9 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
if (slot_ssb) { if (slot_ssb) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_SLOT_FEP_PBCH, VCD_FUNCTION_IN);
LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); LOG_D(PHY," ------ PBCH ChannelComp/LLR: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
const int estimateSz=7*2*sizeof(int)*fp->ofdm_symbol_size;
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[fp->nb_antennas_rx][estimateSz];
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[fp->nb_antennas_rx][estimateSz];
for (int i=1; i<4; i++) { for (int i=1; i<4; i++) {
nr_slot_fep(ue, nr_slot_fep(ue,
...@@ -1409,7 +1416,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1409,7 +1416,7 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
start_meas(&ue->dlsch_channel_estimation_stats); start_meas(&ue->dlsch_channel_estimation_stats);
nr_pbch_channel_estimation(ue,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit); nr_pbch_channel_estimation(ue, estimateSz, dl_ch_estimates, dl_ch_estimates_time,proc,gNB_id,nr_slot_rx,(ue->symbol_offset+i)%(fp->symbols_per_slot),i-1,(fp->ssb_index)&7,fp->half_frame_bit);
stop_meas(&ue->dlsch_channel_estimation_stats); stop_meas(&ue->dlsch_channel_estimation_stats);
} }
...@@ -1418,13 +1425,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue, ...@@ -1418,13 +1425,14 @@ int phy_procedures_nrUE_RX(PHY_VARS_NR_UE *ue,
if ((ue->decode_MIB == 1) && slot_pbch) { if ((ue->decode_MIB == 1) && slot_pbch) {
LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx); LOG_D(PHY," ------ Decode MIB: frame.slot %d.%d ------ \n", frame_rx%1024, nr_slot_rx);
nr_ue_pbch_procedures(gNB_id, ue, proc, 0); nr_ue_pbch_procedures(gNB_id, ue, proc, estimateSz, dl_ch_estimates);
if (ue->no_timing_correction==0) { if (ue->no_timing_correction==0) {
LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction); LOG_D(PHY,"start adjust sync slot = %d no timing %d\n", nr_slot_rx, ue->no_timing_correction);
nr_adjust_synch_ue(fp, nr_adjust_synch_ue(fp,
ue, ue,
gNB_id, gNB_id,
estimateSz, dl_ch_estimates_time,
frame_rx, frame_rx,
nr_slot_rx, nr_slot_rx,
0, 0,
......
#include "nfapi/oai_integration/vendor_ext.h" #include "nfapi/oai_integration/vendor_ext.h"
int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0); } int oai_nfapi_hi_dci0_req(nfapi_hi_dci0_request_t *hi_dci0_req) { return(0); }
int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); } int oai_nfapi_tx_req(nfapi_tx_request_t *tx_req) { return(0); }
int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { return(0); } int oai_nfapi_dl_config_req(nfapi_dl_config_request_t *dl_config_req) { return(0); }
...@@ -35,4 +36,5 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind, ...@@ -35,4 +36,5 @@ void nr_fill_rx_indication(fapi_nr_rx_indication_t *rx_ind,
NR_UE_DLSCH_t *dlsch0, NR_UE_DLSCH_t *dlsch0,
NR_UE_DLSCH_t *dlsch1, NR_UE_DLSCH_t *dlsch1,
uint16_t n_pdus, uint16_t n_pdus,
UE_nr_rxtx_proc_t *proc) {} UE_nr_rxtx_proc_t *proc,
void * typeSpecific ) {}
...@@ -438,6 +438,7 @@ int main(int argc, char **argv) ...@@ -438,6 +438,7 @@ int main(int argc, char **argv)
printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL); printf("Initializing gNodeB for mu %d, N_RB_DL %d\n",mu,N_RB_DL);
RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *)); RC.gNB = (PHY_VARS_gNB**) malloc(sizeof(PHY_VARS_gNB *));
RC.gNB[0] = malloc16_clear(sizeof(*(RC.gNB[0]))); RC.gNB[0] = malloc16_clear(sizeof(*(RC.gNB[0])));
gNB = RC.gNB[0]; gNB = RC.gNB[0];
...@@ -531,13 +532,13 @@ int main(int argc, char **argv) ...@@ -531,13 +532,13 @@ int main(int argc, char **argv)
s_im = malloc(2*sizeof(double*)); s_im = malloc(2*sizeof(double*));
r_re = malloc(2*sizeof(double*)); r_re = malloc(2*sizeof(double*));
r_im = malloc(2*sizeof(double*)); r_im = malloc(2*sizeof(double*));
txdata = malloc(2*sizeof(int*)); txdata = calloc(2,sizeof(int*));
for (i=0; i<2; i++) { for (i=0; i<2; i++) {
s_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); s_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
s_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); s_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
r_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); r_re[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
r_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double)); r_im[i] = malloc16_clear(frame_length_complex_samples*sizeof(double));
printf("Allocating %d samples for txdata\n",frame_length_complex_samples); printf("Allocating %d samples for txdata\n",frame_length_complex_samples);
...@@ -550,6 +551,7 @@ int main(int argc, char **argv) ...@@ -550,6 +551,7 @@ int main(int argc, char **argv)
//configure UE //configure UE
UE = malloc16_clear(sizeof(*UE)); UE = malloc16_clear(sizeof(*UE));
memcpy(&UE->frame_parms,frame_parms,sizeof(UE->frame_parms)); memcpy(&UE->frame_parms,frame_parms,sizeof(UE->frame_parms));
//phy_init_nr_top(UE); //called from init_nr_ue_signal //phy_init_nr_top(UE); //called from init_nr_ue_signal
...@@ -722,6 +724,9 @@ int main(int argc, char **argv) ...@@ -722,6 +724,9 @@ int main(int argc, char **argv)
UE_nr_rxtx_proc_t proc={0}; UE_nr_rxtx_proc_t proc={0};
UE->rx_offset=0; UE->rx_offset=0;
uint8_t ssb_index = 0; uint8_t ssb_index = 0;
const int estimateSz=7*2*sizeof(int)*frame_parms->ofdm_symbol_size;
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates[frame_parms->nb_antennas_rx][estimateSz];
__attribute__ ((aligned(32))) struct complex16 dl_ch_estimates_time[frame_parms->nb_antennas_rx][estimateSz];
while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb while (!((SSB_positions >> ssb_index) & 0x01)) ssb_index++; // to select the first transmitted ssb
UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index); UE->symbol_offset = nr_get_ssb_start_symbol(frame_parms,ssb_index);
...@@ -732,17 +737,20 @@ int main(int argc, char **argv) ...@@ -732,17 +737,20 @@ int main(int argc, char **argv)
i%frame_parms->symbols_per_slot, i%frame_parms->symbols_per_slot,
ssb_slot); ssb_slot);
nr_pbch_channel_estimation(UE,&proc,0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf); nr_pbch_channel_estimation(UE,estimateSz, dl_ch_estimates, dl_ch_estimates_time, &proc,
0,ssb_slot,i%frame_parms->symbols_per_slot,i-(UE->symbol_offset+1),ssb_index%8,n_hf);
} }
fapiPbch_t result;
ret = nr_rx_pbch(UE, ret = nr_rx_pbch(UE,
&proc, &proc,
UE->pbch_vars[0], estimateSz, dl_ch_estimates,
UE->pbch_vars[0],
frame_parms, frame_parms,
0, 0,
ssb_index%8, ssb_index%8,
SISO); SISO,
&result);
if (ret==0) { if (ret==0) {
//UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically //UE->rx_ind.rx_indication_body->mib_pdu.ssb_index; //not yet detected automatically
...@@ -751,9 +759,9 @@ int main(int argc, char **argv) ...@@ -751,9 +759,9 @@ int main(int argc, char **argv)
for (int i=0; i<8; i++) for (int i=0; i<8; i++)
gNB_xtra_byte |= ((gNB->pbch.pbch_a>>(31-i))&1)<<(7-i); gNB_xtra_byte |= ((gNB->pbch.pbch_a>>(31-i))&1)<<(7-i);
payload_ret = (UE->pbch_vars[0]->xtra_byte == gNB_xtra_byte); payload_ret = (result.xtra_byte == gNB_xtra_byte);
for (i=0;i<3;i++){ for (i=0;i<3;i++){
payload_ret += (UE->pbch_vars[0]->decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff)); payload_ret += (result.decoded_output[i] == ((msgDataTx.ssb[ssb_index].ssb_pdu.ssb_pdu_rel15.bchPayload>>(8*i)) & 0xff));
} }
//printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->pbch_vars[0]->xtra_byte); //printf("xtra byte gNB: 0x%02x UE: 0x%02x\n",gNB_xtra_byte, UE->pbch_vars[0]->xtra_byte);
//printf("ret %d\n", payload_ret); //printf("ret %d\n", payload_ret);
......
...@@ -1175,7 +1175,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_ ...@@ -1175,7 +1175,7 @@ int nr_ue_dl_indication(nr_downlink_indication_t *dl_info, NR_UL_TIME_ALIGNMENT_
(dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_length, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_length,
(dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_start_subcarrier, (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.ssb_start_subcarrier,
(dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.cell_id)) << FAPI_NR_RX_PDU_TYPE_SSB; (dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.cell_id)) << FAPI_NR_RX_PDU_TYPE_SSB;
free((dl_info->rx_ind->rx_indication_body+i)->ssb_pdu.pdu);
break; break;
case FAPI_NR_RX_PDU_TYPE_SIB: case FAPI_NR_RX_PDU_TYPE_SIB:
ret_mask |= (handle_bcch_dlsch(dl_info->module_id, ret_mask |= (handle_bcch_dlsch(dl_info->module_id,
......
...@@ -905,30 +905,27 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP( ...@@ -905,30 +905,27 @@ rrc_gNB_send_NGAP_PDUSESSION_SETUP_RESP(
for (pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) { for (pdusession = 0; pdusession < ue_context_pP->ue_context.setup_pdu_sessions; pdusession++) {
// if (xid == ue_context_pP->ue_context.pdusession[pdusession].xid) { // if (xid == ue_context_pP->ue_context.pdusession[pdusession].xid) {
if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) { if (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_DONE) {
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id; pdusession_setup_t * tmp=&NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession];
// NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].pdusession_id = 1; tmp->pdusession_id = ue_context_pP->ue_context.pduSession[pdusession].param.pdusession_id;
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos; // tmp->pdusession_id = 1;
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession]; tmp->nb_of_qos_flow = ue_context_pP->ue_context.pduSession[pdusession].param.nb_qos;
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.pdu_session_type = PDUSessionType_ipv4; tmp->gtp_teid = ue_context_pP->ue_context.gnb_gtp_teid[pdusession];
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.length = ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].length; tmp->gNB_addr.pdu_session_type = PDUSessionType_ipv4;
memcpy(NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].gNB_addr.buffer, tmp->gNB_addr.length = ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].length;
ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, sizeof(uint8_t)*20); memcpy(tmp->gNB_addr.buffer,
for (qos_flow_index = 0; qos_flow_index < NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].nb_of_qos_flow; qos_flow_index++) { ue_context_pP->ue_context.gnb_gtp_addrs[pdusession].buffer, tmp->gNB_addr.length);
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qfi = for (qos_flow_index = 0; qos_flow_index < tmp->nb_of_qos_flow; qos_flow_index++) {
tmp->associated_qos_flows[qos_flow_index].qfi =
ue_context_pP->ue_context.pduSession[pdusession].param.qos[qos_flow_index].qfi; ue_context_pP->ue_context.pduSession[pdusession].param.qos[qos_flow_index].qfi;
NGAP_PDUSESSION_SETUP_RESP(msg_p).pdusessions[pdusession].associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL; tmp->associated_qos_flows[qos_flow_index].qos_flow_mapping_ind = QOSFLOW_MAPPING_INDICATION_DL;
} }
ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED; ue_context_pP->ue_context.pduSession[pdusession].status = PDU_SESSION_STATUS_ESTABLISHED;
LOG_I (NR_RRC,"gnb_gtp_addr (msg index %d, pdu_sessions index %d, status %d, xid %d): nb_of_pdusessions %d, pdusession_id %d, teid: %u, addr: %d.%d.%d.%d \n ", LOG_I (NR_RRC,"gnb_gtp_addr (msg index %d, pdu_sessions index %d, status %d, xid %d): nb_of_pdusessions %d, pdusession_id %d, teid: %u \n ",
pdu_sessions_done, pdusession, ue_context_pP->ue_context.pduSession[pdusession].status, xid, pdu_sessions_done, pdusession, ue_context_pP->ue_context.pduSession[pdusession].status, xid,
ue_context_pP->ue_context.nb_of_pdusessions, ue_context_pP->ue_context.nb_of_pdusessions,
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].pdusession_id, NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].pdusession_id,
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gtp_teid, NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gtp_teid);
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[0],
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[1],
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[2],
NGAP_PDUSESSION_SETUP_RESP (msg_p).pdusessions[pdu_sessions_done].gNB_addr.buffer[3]);
pdu_sessions_done++; pdu_sessions_done++;
} else if ((ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_NEW) || } else if ((ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_NEW) ||
(ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_ESTABLISHED)) { (ue_context_pP->ue_context.pduSession[pdusession].status == PDU_SESSION_STATUS_ESTABLISHED)) {
......
...@@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP) ...@@ -43,7 +43,7 @@ list_init (list_t * listP, char *nameP)
{ {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
if (nameP) { if (nameP) {
strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 );
listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string
} }
......
...@@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP) ...@@ -53,7 +53,7 @@ list2_init (list2_t * listP, char *nameP)
{ {
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
if (nameP) { if (nameP) {
strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR ); strncpy( listP->name, nameP, LIST_NAME_MAX_CHAR-1 );
listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string listP->name[LIST_NAME_MAX_CHAR-1] = 0; // terminate string
} }
......
...@@ -680,24 +680,20 @@ int ngap_gNB_initial_ctxt_resp( ...@@ -680,24 +680,20 @@ int ngap_gNB_initial_ctxt_resp(
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel; pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel;
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = (NGAP_GTPTunnel_t *)calloc(1, sizeof(NGAP_GTPTunnel_t)); pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = (NGAP_GTPTunnel_t *)calloc(1, sizeof(NGAP_GTPTunnel_t));
GTP_TEID_TO_ASN1(initial_ctxt_resp_p->pdusessions[i].gtp_teid, &pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->gTP_TEID); struct NGAP_GTPTunnel *tmp=pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel;
GTP_TEID_TO_ASN1(initial_ctxt_resp_p->pdusessions[i].gtp_teid, &tmp->gTP_TEID);
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf = malloc(initial_ctxt_resp_p->pdusessions[i].gNB_addr.length); tmp->transportLayerAddress.buf = malloc(initial_ctxt_resp_p->pdusessions[i].gNB_addr.length);
memcpy(pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf, memcpy(tmp->transportLayerAddress.buf,
initial_ctxt_resp_p->pdusessions[i].gNB_addr.buffer, initial_ctxt_resp_p->pdusessions[i].gNB_addr.buffer,
initial_ctxt_resp_p->pdusessions[i].gNB_addr.length); initial_ctxt_resp_p->pdusessions[i].gNB_addr.length);
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size = initial_ctxt_resp_p->pdusessions[i].gNB_addr.length; tmp->transportLayerAddress.size = initial_ctxt_resp_p->pdusessions[i].gNB_addr.length;
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.bits_unused = 0; tmp->transportLayerAddress.bits_unused = 0;
NGAP_DEBUG("initial_ctxt_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n", NGAP_DEBUG("initial_ctxt_resp_p: pdusession ID %ld\n",
item->pDUSessionID, item->pDUSessionID);
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[0],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[1],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[2],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[3],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size);
/* associatedQosFlowList. number of 1? */ /* associatedQosFlowList. number of 1? */
for(int j=0; j < initial_ctxt_resp_p->pdusessions[i].nb_of_qos_flow; j++) { for(int j=0; j < initial_ctxt_resp_p->pdusessions[i].nb_of_qos_flow; j++) {
...@@ -987,24 +983,25 @@ int ngap_gNB_pdusession_setup_resp(instance_t instance, ...@@ -987,24 +983,25 @@ int ngap_gNB_pdusession_setup_resp(instance_t instance,
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel; pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.present = NGAP_UPTransportLayerInformation_PR_gTPTunnel;
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel = pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel =
calloc(1, sizeof(struct NGAP_GTPTunnel)); calloc(1, sizeof(struct NGAP_GTPTunnel));
struct NGAP_GTPTunnel *tmp=pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel;
GTP_TEID_TO_ASN1(pdusession_setup_resp_p->pdusessions[i].gtp_teid, &pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->gTP_TEID); GTP_TEID_TO_ASN1(pdusession_setup_resp_p->pdusessions[i].gtp_teid, &tmp->gTP_TEID);
if (pdusession_setup_resp_p->pdusessions[i].gNB_addr.length) {
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf = malloc(pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); tmp->transportLayerAddress.buf = malloc(pdusession_setup_resp_p->pdusessions[i].gNB_addr.length);
memcpy(pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf, memcpy(tmp->transportLayerAddress.buf,
pdusession_setup_resp_p->pdusessions[i].gNB_addr.buffer, pdusession_setup_resp_p->pdusessions[i].gNB_addr.buffer,
pdusession_setup_resp_p->pdusessions[i].gNB_addr.length); pdusession_setup_resp_p->pdusessions[i].gNB_addr.length);
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size = pdusession_setup_resp_p->pdusessions[i].gNB_addr.length; tmp->transportLayerAddress.size = pdusession_setup_resp_p->pdusessions[i].gNB_addr.length;
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.bits_unused = 0; tmp->transportLayerAddress.bits_unused = 0;
NGAP_DEBUG("pdusession_setup_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n", NGAP_DEBUG("pdusession_setup_resp_p: pdusession ID %ld, gnb_addr %d.%d.%d.%d, SIZE %ld \n",
item->pDUSessionID, item->pDUSessionID,
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[0], tmp->transportLayerAddress.buf[0],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[1], tmp->transportLayerAddress.buf[1],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[2], tmp->transportLayerAddress.buf[2],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.buf[3], tmp->transportLayerAddress.buf[3],
pdusessionTransfer_p->dLQosFlowPerTNLInformation.uPTransportLayerInformation.choice.gTPTunnel->transportLayerAddress.size); tmp->transportLayerAddress.size);
}
/* associatedQosFlowList. number of 1? */ /* associatedQosFlowList. number of 1? */
for(int j=0; j < pdusession_setup_resp_p->pdusessions[i].nb_of_qos_flow; j++) { for(int j=0; j < pdusession_setup_resp_p->pdusessions[i].nb_of_qos_flow; j++) {
......
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