Commit e1ef4e2d authored by rmagueta's avatar rmagueta

Merge remote-tracking branch 'origin/NR_SA_F1AP_5GRECORDS' into develop-NR_SA_F1AP_5GRECORDS

# Conflicts:
#	openair1/PHY/NR_TRANSPORT/nr_ulsch_demodulation.c
#	openair1/SCHED_NR/phy_procedures_nr_gNB.c
#	openair2/GNB_APP/L1_nr_paramdef.h
#	openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c
#	openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c
#	openair2/SIMULATION/NR_RRC/itti_sim.c
parents 63663ac4 458f199d
...@@ -90,7 +90,7 @@ void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) { ...@@ -90,7 +90,7 @@ void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB) {
fprintf(fd,"\nmax_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, gNB->measurements.n0_subband_power_avg_dB); fprintf(fd,"\nmax_I0 %d (rb %d), min_I0 %d (rb %d), avg I0 %d\n", max_I0, amax, min_I0, amin, gNB->measurements.n0_subband_power_avg_dB);
fprintf(fd,"prach_I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10); fprintf(fd,"PRACH I0 = %d.%d dB\n",gNB->measurements.prach_I0/10,gNB->measurements.prach_I0%10);
} }
......
...@@ -144,14 +144,19 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { ...@@ -144,14 +144,19 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) {
int stroff=0; int stroff=0;
for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;i++) { for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;i++) {
for (int aa=0;aa<gNB->frame_parms.nb_antennas_rx;aa++) if (gNB->ulsch_stats[i].rnti>0) {
stroff+=sprintf(output+stroff,"ULSCH RNTI %x: ulsch_power[%d] %d, ulsch_noise_power[%d] %d\n", for (int aa=0;aa<gNB->frame_parms.nb_antennas_rx;aa++)
gNB->ulsch_stats[i].rnti, aa,gNB->ulsch_stats[i].power[aa],aa,gNB->ulsch_stats[i].noise_power[aa]); if (aa==0) stroff+=sprintf(output+stroff,"ULSCH RNTI %4x: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d\n",
AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n"); gNB->ulsch_stats[i].rnti,
aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10,
if (gNB->ulsch_stats[i].rnti>0) aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10);
stroff+=sprintf(output+stroff,"ULSCH RNTI %x: round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n", else stroff+=sprintf(output+stroff," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n",
gNB->ulsch_stats[i].rnti, aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10);
AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n");
stroff+=sprintf(output+stroff," round_trials %d(%1.1e):%d(%1.1e):%d(%1.1e):%d, DTX %d, current_Qm %d, current_RI %d, total_bytes RX/SCHED %d/%d\n",
gNB->ulsch_stats[i].round_trials[0], gNB->ulsch_stats[i].round_trials[0],
(double)gNB->ulsch_stats[i].round_trials[1]/gNB->ulsch_stats[i].round_trials[0], (double)gNB->ulsch_stats[i].round_trials[1]/gNB->ulsch_stats[i].round_trials[0],
gNB->ulsch_stats[i].round_trials[1], gNB->ulsch_stats[i].round_trials[1],
...@@ -159,10 +164,12 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) { ...@@ -159,10 +164,12 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) {
gNB->ulsch_stats[i].round_trials[2], gNB->ulsch_stats[i].round_trials[2],
(double)gNB->ulsch_stats[i].round_trials[3]/gNB->ulsch_stats[i].round_trials[0], (double)gNB->ulsch_stats[i].round_trials[3]/gNB->ulsch_stats[i].round_trials[0],
gNB->ulsch_stats[i].round_trials[3], gNB->ulsch_stats[i].round_trials[3],
gNB->ulsch_stats[i].DTX,
gNB->ulsch_stats[i].current_Qm, gNB->ulsch_stats[i].current_Qm,
gNB->ulsch_stats[i].current_RI, gNB->ulsch_stats[i].current_RI,
gNB->ulsch_stats[i].total_bytes_rx, gNB->ulsch_stats[i].total_bytes_rx,
gNB->ulsch_stats[i].total_bytes_tx); gNB->ulsch_stats[i].total_bytes_tx);
}
} }
fprintf(fd,"%s",output); fprintf(fd,"%s",output);
} }
...@@ -172,3 +179,20 @@ void clear_pusch_stats(PHY_VARS_gNB *gNB) { ...@@ -172,3 +179,20 @@ void clear_pusch_stats(PHY_VARS_gNB *gNB) {
for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;i++) for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;i++)
memset((void*)&gNB->ulsch_stats[i],0,sizeof(gNB->ulsch_stats[i])); memset((void*)&gNB->ulsch_stats[i],0,sizeof(gNB->ulsch_stats[i]));
} }
NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch) {
NR_gNB_SCH_STATS_t *stats=NULL;
int first_free=-1;
for (int i=0;i<NUMBER_OF_NR_SCH_STATS_MAX;i++) {
if (gNB->ulsch_stats[i].rnti == 0 && first_free == -1) {
first_free = i;
stats=&gNB->ulsch_stats[i];
}
if (gNB->ulsch_stats[i].rnti == ulsch->rnti) {
stats=&gNB->ulsch_stats[i];
break;
}
}
return(stats);
}
...@@ -92,3 +92,5 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type); ...@@ -92,3 +92,5 @@ int16_t find_nr_ulsch(uint16_t rnti, PHY_VARS_gNB *gNB,find_type_t type);
void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB); void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB);
void clear_pusch_stats(PHY_VARS_gNB *gNB); void clear_pusch_stats(PHY_VARS_gNB *gNB);
NR_gNB_SCH_STATS_t *get_ulsch_stats(PHY_VARS_gNB *gNB,NR_gNB_ULSCH_t *ulsch);
...@@ -449,7 +449,7 @@ void nr_processULSegment(void* arg) { ...@@ -449,7 +449,7 @@ void nr_processULSegment(void* arg) {
} }
uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
uint8_t UE_id, uint8_t ULSCH_id,
short *ulsch_llr, short *ulsch_llr,
NR_DL_FRAME_PARMS *frame_parms, NR_DL_FRAME_PARMS *frame_parms,
nfapi_nr_pusch_pdu_t *pusch_pdu, nfapi_nr_pusch_pdu_t *pusch_pdu,
...@@ -471,7 +471,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -471,7 +471,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
#endif #endif
NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[UE_id][0]; NR_gNB_ULSCH_t *ulsch = phy_vars_gNB->ulsch[ULSCH_id][0];
NR_gNB_PUSCH *pusch = phy_vars_gNB->pusch_vars[ULSCH_id];
NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid]; NR_UL_gNB_HARQ_t *harq_process = ulsch->harq_processes[harq_pid];
if (!harq_process) { if (!harq_process) {
...@@ -557,9 +558,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -557,9 +558,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
if (stats) { if (stats) {
stats->rnti = ulsch->rnti; stats->rnti = ulsch->rnti;
stats->round_trials[harq_process->round]++; stats->round_trials[harq_process->round]++;
} for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
if (harq_process->round == 0) { stats->power[aarx]=dB_fixed_x10(pusch->ulsch_power[aarx]);
if (stats) { stats->noise_power[aarx]=dB_fixed_x10(pusch->ulsch_noise_power[aarx]);
}
if (harq_process->round == 0) {
stats->current_Qm = Qm; stats->current_Qm = Qm;
stats->current_RI = n_layers; stats->current_RI = n_layers;
stats->total_bytes_tx += harq_process->TBS; stats->total_bytes_tx += harq_process->TBS;
...@@ -639,7 +642,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB, ...@@ -639,7 +642,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
rdata->Tbslbrm = Tbslbrm; rdata->Tbslbrm = Tbslbrm;
rdata->offset = offset; rdata->offset = offset;
rdata->ulsch = ulsch; rdata->ulsch = ulsch;
rdata->ulsch_id = UE_id; rdata->ulsch_id = ULSCH_id;
pushTpool(phy_vars_gNB->threadPool,req); pushTpool(phy_vars_gNB->threadPool,req);
phy_vars_gNB->nbDecode++; phy_vars_gNB->nbDecode++;
LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode); LOG_D(PHY,"Added a block to decode, in pipe: %d\n",phy_vars_gNB->nbDecode);
......
...@@ -1226,11 +1226,11 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB, ...@@ -1226,11 +1226,11 @@ int nr_rx_pusch(PHY_VARS_gNB *gNB,
} }
gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc(&gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol*frame_parms->ofdm_symbol_size], gNB->pusch_vars[ulsch_id]->ulsch_power[aarx] += signal_energy_nodc(&gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aarx][symbol*frame_parms->ofdm_symbol_size],
rel15_ul->rb_size*12); rel15_ul->rb_size*12);
if (gNB->pusch_vars[ulsch_id]->ulsch_power[aarx]==1) return (1);
for (int rb=0;rb<rel15_ul->rb_size;rb++) { for (int rb=0;rb<rel15_ul->rb_size;rb++) {
gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]+=gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start+rel15_ul->rb_start+rb]/rel15_ul->rb_size; gNB->pusch_vars[ulsch_id]->ulsch_noise_power[aarx]+=gNB->measurements.n0_subband_power[aarx][rel15_ul->bwp_start+rel15_ul->rb_start+rb]/rel15_ul->rb_size;
} }
}
}
} }
stop_meas(&gNB->ulsch_channel_estimation_stats); stop_meas(&gNB->ulsch_channel_estimation_stats);
//---------------------------------------------------------- //----------------------------------------------------------
......
...@@ -135,6 +135,7 @@ typedef struct { ...@@ -135,6 +135,7 @@ typedef struct {
int current_RI; int current_RI;
int power[NB_ANTENNAS_RX]; int power[NB_ANTENNAS_RX];
int noise_power[NB_ANTENNAS_RX]; int noise_power[NB_ANTENNAS_RX];
int DTX;
} NR_gNB_SCH_STATS_t; } NR_gNB_SCH_STATS_t;
typedef struct { typedef struct {
...@@ -511,6 +512,8 @@ typedef struct { ...@@ -511,6 +512,8 @@ typedef struct {
int16_t *ul_valid_re_per_slot; int16_t *ul_valid_re_per_slot;
/// flag to verify if channel level computation is done /// flag to verify if channel level computation is done
uint8_t cl_done; uint8_t cl_done;
/// flag to indicate DTX on reception
int DTX;
} NR_gNB_PUSCH; } NR_gNB_PUSCH;
/// Context data structure for RX/TX portion of slot processing /// Context data structure for RX/TX portion of slot processing
...@@ -830,6 +833,7 @@ typedef struct PHY_VARS_gNB_s { ...@@ -830,6 +833,7 @@ typedef struct PHY_VARS_gNB_s {
int prach_energy_counter; int prach_energy_counter;
int pucch0_thres; int pucch0_thres;
int pusch_thres;
int prach_thres; int prach_thres;
uint64_t bad_pucch; uint64_t bad_pucch;
/* /*
......
...@@ -609,7 +609,6 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) ...@@ -609,7 +609,6 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
for (int ULSCH_id=0;ULSCH_id<NUMBER_OF_NR_ULSCH_MAX;ULSCH_id++) { for (int ULSCH_id=0;ULSCH_id<NUMBER_OF_NR_ULSCH_MAX;ULSCH_id++) {
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0]; NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0];
int harq_pid; int harq_pid;
int no_sig;
NR_UL_gNB_HARQ_t *ulsch_harq; NR_UL_gNB_HARQ_t *ulsch_harq;
if ((ulsch) && if ((ulsch) &&
...@@ -658,20 +657,29 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) ...@@ -658,20 +657,29 @@ void phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index; uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols; uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,1); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,1);
start_meas(&gNB->rx_pusch_stats); start_meas(&gNB->rx_pusch_stats);
for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) { for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) {
no_sig = nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid); nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid);
if (no_sig) { }
LOG_I(PHY, "PUSCH not detected in symbol %d\n",symbol); int ulsch_power=0,ulsch_noise_power=0;
nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
return;
}
}
for (int aarx=0;aarx<gNB->frame_parms.nb_antennas_rx;aarx++) { for (int aarx=0;aarx<gNB->frame_parms.nb_antennas_rx;aarx++) {
gNB->pusch_vars[ULSCH_id]->ulsch_power[aarx]/=num_dmrs; gNB->pusch_vars[ULSCH_id]->ulsch_power[aarx]/=num_dmrs;
ulsch_power += gNB->pusch_vars[ULSCH_id]->ulsch_power[aarx];
gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[aarx]/=num_dmrs; gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[aarx]/=num_dmrs;
ulsch_noise_power += gNB->pusch_vars[ULSCH_id]->ulsch_noise_power[aarx];
} }
stop_meas(&gNB->rx_pusch_stats); if (dB_fixed_x10(ulsch_power) < dB_fixed_x10(ulsch_noise_power) + gNB->pusch_thres) {
NR_gNB_SCH_STATS_t *stats=get_ulsch_stats(gNB,ulsch);
LOG_D(PHY, "PUSCH not detected in %d.%d (%d,%d,%d)\n",frame_rx,slot_rx,
dB_fixed_x10(ulsch_power),dB_fixed_x10(ulsch_noise_power),gNB->pusch_thres);
nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
gNB->pusch_vars[ULSCH_id]->DTX=1;
stats->DTX++;
return;
} else gNB->pusch_vars[ULSCH_id]->DTX=0;
stop_meas(&gNB->rx_pusch_stats);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_NR_RX_PUSCH,0);
//LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1); //LOG_M("rxdataF_comp.m","rxF_comp",gNB->pusch_vars[0]->rxdataF_comp[0],6900,1,1);
//LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1); //LOG_M("rxdataF_ext.m","rxF_ext",gNB->pusch_vars[0]->rxdataF_ext[0],6900,1,1);
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads" #define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads"
#define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_dtx_threshold" #define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_dtx_threshold"
#define CONFIG_STRING_L1_PRACH_DTX_THRESHOLD "prach_dtx_threshold" #define CONFIG_STRING_L1_PRACH_DTX_THRESHOLD "prach_dtx_threshold"
#define CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD "pusch_dtx_threshold"
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/
/* L1 configuration parameters */ /* L1 configuration parameters */
/* optname helpstr paramflags XXXptr defXXXval type numelt */ /* optname helpstr paramflags XXXptr defXXXval type numelt */
...@@ -65,7 +66,8 @@ ...@@ -65,7 +66,8 @@
{CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_REMOTE_N_PORTD, NULL, 0, uptr:NULL, defintval:50031, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUSCH_PROC_THREADS, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \ {CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:100, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:200, TYPE_UINT, 0} \ {CONFIG_STRING_L1_PRACH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:200, TYPE_UINT, 0}, \
{CONFIG_STRING_L1_PUSCH_DTX_THRESHOLD, NULL, 0, uptr:NULL, defintval:50, TYPE_UINT, 0} \
} }
#define L1_CC_IDX 0 #define L1_CC_IDX 0
#define L1_TRANSPORT_N_PREFERENCE_IDX 1 #define L1_TRANSPORT_N_PREFERENCE_IDX 1
...@@ -79,6 +81,7 @@ ...@@ -79,6 +81,7 @@
#define L1_PUSCH_PROC_THREADS 9 #define L1_PUSCH_PROC_THREADS 9
#define L1_PUCCH0_DTX_THRESHOLD 10 #define L1_PUCCH0_DTX_THRESHOLD 10
#define L1_PRACH_DTX_THRESHOLD 11 #define L1_PRACH_DTX_THRESHOLD 11
#define L1_PUSCH_DTX_THRESHOLD 12
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------------------------------------------------------------------------*/
#endif #endif
...@@ -603,6 +603,7 @@ void RCconfig_NR_L1(void) { ...@@ -603,6 +603,7 @@ void RCconfig_NR_L1(void) {
RC.gNB[j]->pusch_proc_threads = *(L1_ParamList.paramarray[j][L1_PUSCH_PROC_THREADS].uptr); RC.gNB[j]->pusch_proc_threads = *(L1_ParamList.paramarray[j][L1_PUSCH_PROC_THREADS].uptr);
RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr); RC.gNB[j]->pucch0_thres = *(L1_ParamList.paramarray[j][L1_PUCCH0_DTX_THRESHOLD].uptr);
RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr); RC.gNB[j]->prach_thres = *(L1_ParamList.paramarray[j][L1_PRACH_DTX_THRESHOLD].uptr);
RC.gNB[j]->pusch_thres = *(L1_ParamList.paramarray[j][L1_PUSCH_DTX_THRESHOLD].uptr);
if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) { if(strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_mac") == 0) {
//sf_ahead = 2; // Need 4 subframe gap between RX and TX //sf_ahead = 2; // Need 4 subframe gap between RX and TX
}else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) { }else if (strcmp(*(L1_ParamList.paramarray[j][L1_TRANSPORT_N_PREFERENCE_IDX].strptr), "nfapi") == 0) {
......
...@@ -1120,8 +1120,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra ...@@ -1120,8 +1120,6 @@ void nr_generate_Msg2(module_id_t module_idP, int CC_id, frame_t frameP, sub_fra
pdsch_pdu_rel15->BWPSize, pdsch_pdu_rel15->BWPSize,
bwpid); bwpid);
// DL TX request // DL TX request
nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs]; nfapi_nr_pdu_t *tx_req = &nr_mac->TX_req[CC_id].pdu_list[nr_mac->TX_req[CC_id].Number_of_PDUs];
......
...@@ -236,7 +236,7 @@ void nr_process_mac_pdu( ...@@ -236,7 +236,7 @@ void nr_process_mac_pdu(
mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L; mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
mac_subheader_len = 2; mac_subheader_len = 2;
} }
LOG_I(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, rnti); LOG_D(NR_MAC, "[UE %d] Frame %d : ULSCH -> UL-DCCH %d (gNB %d, %d bytes), rnti: %d \n", module_idP, frameP, rx_lcid, module_idP, mac_sdu_len, rnti);
mac_rlc_data_ind(module_idP, mac_rlc_data_ind(module_idP,
rnti, rnti,
module_idP, module_idP,
...@@ -406,20 +406,20 @@ void handle_nr_ul_harq(module_id_t mod_id, ...@@ -406,20 +406,20 @@ void handle_nr_ul_harq(module_id_t mod_id,
} else { } else {
harq->round++; harq->round++;
if (harq->round == MAX_HARQ_ROUNDS) { if (harq->round == MAX_HARQ_ROUNDS) {
harq->ndi ^= 1; harq->ndi ^= 1;
harq->round = 0; harq->round = 0;
LOG_D(NR_MAC, LOG_D(NR_MAC,
"RNTI %04x: Ulharq id %d crc failed in all rounds\n", "RNTI %04x: Ulharq id %d crc failed in all rounds\n",
crc_pdu->rnti, crc_pdu->rnti,
harq_pid); harq_pid);
UE_info->mac_stats[UE_id].ulsch_errors++; UE_info->mac_stats[UE_id].ulsch_errors++;
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid); add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
} else { } else {
LOG_D(MAC, LOG_D(NR_MAC,
"Ulharq id %d crc failed for RNTI %04x\n", "Ulharq id %d crc failed for RNTI %04x\n",
harq_pid, harq_pid,
crc_pdu->rnti); crc_pdu->rnti);
add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid); add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid);
} }
} }
} }
......
...@@ -212,12 +212,20 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity, ...@@ -212,12 +212,20 @@ static void nr_pdcp_entity_recv_sdu(nr_pdcp_entity_t *entity,
header_size + size + integrity_size, sdu_id); header_size + size + integrity_size, sdu_id);
} }
static void nr_pdcp_entity_set_integrity_key(nr_pdcp_entity_t *entity, static void nr_pdcp_entity_set_security(nr_pdcp_entity_t *entity,
char *key) int integrity_algorithm,
char *integrity_key,
int ciphering_algorithm,
char *ciphering_key)
{ {
LOG_E(PDCP, "%s: %d: %s: TODO? to remove?\n", __FILE__, __LINE__, __FUNCTION__); if (integrity_algorithm != -1)
exit(1); entity->integrity_algorithm = integrity_algorithm;
//memcpy(entity->integrity_key, key, 16); if (ciphering_algorithm != -1)
entity->ciphering_algorithm = ciphering_algorithm;
if (integrity_key != NULL)
memcpy(entity->integrity_key, integrity_key, 16);
if (ciphering_key != NULL)
memcpy(entity->ciphering_key, ciphering_key, 16);
} }
static void check_t_reordering(nr_pdcp_entity_t *entity) static void check_t_reordering(nr_pdcp_entity_t *entity)
...@@ -310,10 +318,10 @@ nr_pdcp_entity_t *new_nr_pdcp_entity( ...@@ -310,10 +318,10 @@ nr_pdcp_entity_t *new_nr_pdcp_entity(
ret->type = type; ret->type = type;
ret->recv_pdu = nr_pdcp_entity_recv_pdu; ret->recv_pdu = nr_pdcp_entity_recv_pdu;
ret->recv_sdu = nr_pdcp_entity_recv_sdu; ret->recv_sdu = nr_pdcp_entity_recv_sdu;
ret->set_integrity_key = nr_pdcp_entity_set_integrity_key; ret->set_security = nr_pdcp_entity_set_security;
ret->set_time = nr_pdcp_entity_set_time; ret->set_time = nr_pdcp_entity_set_time;
ret->delete = nr_pdcp_entity_delete; ret->delete = nr_pdcp_entity_delete;
......
...@@ -40,7 +40,16 @@ typedef struct nr_pdcp_entity_t { ...@@ -40,7 +40,16 @@ typedef struct nr_pdcp_entity_t {
void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size, void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size,
int sdu_id); int sdu_id);
void (*delete)(struct nr_pdcp_entity_t *entity); void (*delete)(struct nr_pdcp_entity_t *entity);
void (*set_integrity_key)(struct nr_pdcp_entity_t *entity, char *key); /* set_security: pass -1 to integrity_algorithm / ciphering_algorithm
* to keep the current algorithm
* pass NULL to integrity_key / ciphering_key
* to keep the current key
*/
void (*set_security)(struct nr_pdcp_entity_t *entity,
int integrity_algorithm,
char *integrity_key,
int ciphering_algorithm,
char *ciphering_key);
void (*set_time)(struct nr_pdcp_entity_t *entity, uint64_t now); void (*set_time)(struct nr_pdcp_entity_t *entity, uint64_t now);
/* callbacks provided to the PDCP module */ /* callbacks provided to the PDCP module */
......
...@@ -1044,6 +1044,12 @@ void pdcp_config_set_security( ...@@ -1044,6 +1044,12 @@ void pdcp_config_set_security(
uint8_t *const kRRCint_pP, uint8_t *const kRRCint_pP,
uint8_t *const kUPenc_pP) uint8_t *const kUPenc_pP)
{ {
nr_pdcp_ue_t *ue;
nr_pdcp_entity_t *rb;
int rnti = ctxt_pP->rnti;
int integrity_algorithm;
int ciphering_algorithm;
DevAssert(pdcp_pP != NULL); DevAssert(pdcp_pP != NULL);
if ((security_modeP >= 0) && (security_modeP <= 0x77)) { if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
...@@ -1073,6 +1079,33 @@ void pdcp_config_set_security( ...@@ -1073,6 +1079,33 @@ void pdcp_config_set_security(
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP), PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
security_modeP); security_modeP);
} }
nr_pdcp_manager_lock(nr_pdcp_ue_manager);
ue = nr_pdcp_manager_get_ue(nr_pdcp_ue_manager, rnti);
/* TODO: proper handling of DRBs, for the moment only SRBs are handled */
if (rb_id >= 1 && rb_id <= 3) {
rb = ue->srb[rb_id - 1];
if (rb == NULL) {
LOG_E(PDCP, "%s:%d:%s: no SRB found (rnti %d, rb_id %ld)\n",
__FILE__, __LINE__, __FUNCTION__, rnti, rb_id);
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
return;
}
integrity_algorithm = (security_modeP>>4) & 0xf;
ciphering_algorithm = security_modeP & 0x0f;
rb->set_security(rb, integrity_algorithm, (char *)kRRCint_pP,
ciphering_algorithm, (char *)kRRCenc_pP);
} else {
LOG_E(PDCP, "%s:%d:%s: TODO\n", __FILE__, __LINE__, __FUNCTION__);
exit(1);
}
nr_pdcp_manager_unlock(nr_pdcp_ue_manager);
} }
......
...@@ -304,25 +304,45 @@ nr_rrc_pdcp_config_security( ...@@ -304,25 +304,45 @@ nr_rrc_pdcp_config_security(
uint8_t *kRRCenc = NULL; uint8_t *kRRCenc = NULL;
uint8_t *kRRCint = NULL; uint8_t *kRRCint = NULL;
uint8_t *kUPenc = NULL; uint8_t *kUPenc = NULL;
uint8_t *k_kdf = NULL;
pdcp_t *pdcp_p = NULL; pdcp_t *pdcp_p = NULL;
static int print_keys= 1; static int print_keys= 1;
hashtable_rc_t h_rc; hashtable_rc_t h_rc;
hash_key_t key; hash_key_t key;
#ifndef PHYSIM #ifndef PHYSIM
/* Derive the keys from kgnb */ /* Derive the keys from kgnb */
if (SRB_configList != NULL) { if (SRB_configList != NULL) {
nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm, k_kdf = NULL;
ue_context_pP->ue_context.kgnb, nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm,
&kUPenc); ue_context_pP->ue_context.kgnb,
} &k_kdf);
/* kUPenc: last 128 bits of key derivation function which returns 256 bits */
kUPenc = malloc(16);
if (kUPenc == NULL) exit(1);
memcpy(kUPenc, k_kdf+16, 16);
free(k_kdf);
}
nr_derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm, k_kdf = NULL;
ue_context_pP->ue_context.kgnb, nr_derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm,
&kRRCenc); ue_context_pP->ue_context.kgnb,
nr_derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm, &k_kdf);
ue_context_pP->ue_context.kgnb, /* kRRCenc: last 128 bits of key derivation function which returns 256 bits */
&kRRCint); kRRCenc = malloc(16);
if (kRRCenc == NULL) exit(1);
memcpy(kRRCenc, k_kdf+16, 16);
free(k_kdf);
k_kdf = NULL;
nr_derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
ue_context_pP->ue_context.kgnb,
&k_kdf);
/* kRRCint: last 128 bits of key derivation function which returns 256 bits */
kRRCint = malloc(16);
if (kRRCint == NULL) exit(1);
memcpy(kRRCint, k_kdf+16, 16);
free(k_kdf);
#endif #endif
if (!IS_SOFTMODEM_IQPLAYER) { if (!IS_SOFTMODEM_IQPLAYER) {
SET_LOG_DUMP(DEBUG_SECURITY) ; SET_LOG_DUMP(DEBUG_SECURITY) ;
...@@ -648,7 +668,8 @@ static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering(uint16_t algorithms) { ...@@ -648,7 +668,8 @@ static NR_CipheringAlgorithm_t rrc_gNB_select_ciphering(uint16_t algorithms) {
static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(uint16_t algorithms) { static e_NR_IntegrityProtAlgorithm rrc_gNB_select_integrity(uint16_t algorithms) {
return NR_IntegrityProtAlgorithm_nia1; //only NIA2 supported for now
return NR_IntegrityProtAlgorithm_nia2;
if (algorithms & NGAP_INTEGRITY_NIA3_MASK) { if (algorithms & NGAP_INTEGRITY_NIA3_MASK) {
return NR_IntegrityProtAlgorithm_nia3; return NR_IntegrityProtAlgorithm_nia3;
......
...@@ -90,8 +90,6 @@ pthread_mutex_t nfapi_sync_mutex; ...@@ -90,8 +90,6 @@ pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
uint8_t nfapi_mode = 0; // Default to monolithic mode uint8_t nfapi_mode = 0; // Default to monolithic mode
uint32_t target_dl_mcs = 28;
uint32_t target_ul_mcs = 20;
uint32_t timing_advance = 0; uint32_t timing_advance = 0;
uint64_t num_missed_slots=0; uint64_t num_missed_slots=0;
......
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