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
This commit is contained in:
@@ -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,"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) {
|
||||
int stroff=0;
|
||||
|
||||
for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;i++) {
|
||||
for (int aa=0;aa<gNB->frame_parms.nb_antennas_rx;aa++)
|
||||
stroff+=sprintf(output+stroff,"ULSCH RNTI %x: ulsch_power[%d] %d, ulsch_noise_power[%d] %d\n",
|
||||
gNB->ulsch_stats[i].rnti, aa,gNB->ulsch_stats[i].power[aa],aa,gNB->ulsch_stats[i].noise_power[aa]);
|
||||
AssertFatal(stroff<(STATSTRLEN-1000),"Increase STATSTRLEN\n");
|
||||
if (gNB->ulsch_stats[i].rnti>0) {
|
||||
for (int aa=0;aa<gNB->frame_parms.nb_antennas_rx;aa++)
|
||||
if (aa==0) stroff+=sprintf(output+stroff,"ULSCH RNTI %4x: ulsch_power[%d] %d,%d ulsch_noise_power[%d] %d.%d\n",
|
||||
gNB->ulsch_stats[i].rnti,
|
||||
aa,gNB->ulsch_stats[i].power[aa]/10,gNB->ulsch_stats[i].power[aa]%10,
|
||||
aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10);
|
||||
else stroff+=sprintf(output+stroff," ulsch_power[%d] %d.%d, ulsch_noise_power[%d] %d.%d\n",
|
||||
aa,gNB->ulsch_stats[i].noise_power[aa]/10,gNB->ulsch_stats[i].noise_power[aa]%10);
|
||||
|
||||
if (gNB->ulsch_stats[i].rnti>0)
|
||||
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",
|
||||
gNB->ulsch_stats[i].rnti,
|
||||
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],
|
||||
(double)gNB->ulsch_stats[i].round_trials[1]/gNB->ulsch_stats[i].round_trials[0],
|
||||
gNB->ulsch_stats[i].round_trials[1],
|
||||
@@ -159,10 +164,12 @@ void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB) {
|
||||
gNB->ulsch_stats[i].round_trials[2],
|
||||
(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].DTX,
|
||||
gNB->ulsch_stats[i].current_Qm,
|
||||
gNB->ulsch_stats[i].current_RI,
|
||||
gNB->ulsch_stats[i].total_bytes_rx,
|
||||
gNB->ulsch_stats[i].total_bytes_tx);
|
||||
}
|
||||
}
|
||||
fprintf(fd,"%s",output);
|
||||
}
|
||||
@@ -172,3 +179,20 @@ void clear_pusch_stats(PHY_VARS_gNB *gNB) {
|
||||
for (int i=0;i<NUMBER_OF_NR_ULSCH_MAX;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);
|
||||
void dump_pusch_stats(FILE *fd,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) {
|
||||
}
|
||||
|
||||
uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
|
||||
uint8_t UE_id,
|
||||
uint8_t ULSCH_id,
|
||||
short *ulsch_llr,
|
||||
NR_DL_FRAME_PARMS *frame_parms,
|
||||
nfapi_nr_pusch_pdu_t *pusch_pdu,
|
||||
@@ -471,7 +471,8 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
|
||||
#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];
|
||||
|
||||
if (!harq_process) {
|
||||
@@ -557,9 +558,11 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
|
||||
if (stats) {
|
||||
stats->rnti = ulsch->rnti;
|
||||
stats->round_trials[harq_process->round]++;
|
||||
}
|
||||
if (harq_process->round == 0) {
|
||||
if (stats) {
|
||||
for (int aarx=0;aarx<frame_parms->nb_antennas_rx;aarx++) {
|
||||
stats->power[aarx]=dB_fixed_x10(pusch->ulsch_power[aarx]);
|
||||
stats->noise_power[aarx]=dB_fixed_x10(pusch->ulsch_noise_power[aarx]);
|
||||
}
|
||||
if (harq_process->round == 0) {
|
||||
stats->current_Qm = Qm;
|
||||
stats->current_RI = n_layers;
|
||||
stats->total_bytes_tx += harq_process->TBS;
|
||||
@@ -639,7 +642,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
|
||||
rdata->Tbslbrm = Tbslbrm;
|
||||
rdata->offset = offset;
|
||||
rdata->ulsch = ulsch;
|
||||
rdata->ulsch_id = UE_id;
|
||||
rdata->ulsch_id = ULSCH_id;
|
||||
pushTpool(phy_vars_gNB->threadPool,req);
|
||||
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,
|
||||
}
|
||||
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);
|
||||
if (gNB->pusch_vars[ulsch_id]->ulsch_power[aarx]==1) return (1);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
stop_meas(&gNB->ulsch_channel_estimation_stats);
|
||||
//----------------------------------------------------------
|
||||
|
||||
@@ -135,6 +135,7 @@ typedef struct {
|
||||
int current_RI;
|
||||
int power[NB_ANTENNAS_RX];
|
||||
int noise_power[NB_ANTENNAS_RX];
|
||||
int DTX;
|
||||
} NR_gNB_SCH_STATS_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -511,6 +512,8 @@ typedef struct {
|
||||
int16_t *ul_valid_re_per_slot;
|
||||
/// flag to verify if channel level computation is done
|
||||
uint8_t cl_done;
|
||||
/// flag to indicate DTX on reception
|
||||
int DTX;
|
||||
} NR_gNB_PUSCH;
|
||||
|
||||
/// Context data structure for RX/TX portion of slot processing
|
||||
@@ -830,6 +833,7 @@ typedef struct PHY_VARS_gNB_s {
|
||||
int prach_energy_counter;
|
||||
|
||||
int pucch0_thres;
|
||||
int pusch_thres;
|
||||
int prach_thres;
|
||||
uint64_t bad_pucch;
|
||||
/*
|
||||
|
||||
@@ -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++) {
|
||||
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ULSCH_id][0];
|
||||
int harq_pid;
|
||||
int no_sig;
|
||||
NR_UL_gNB_HARQ_t *ulsch_harq;
|
||||
|
||||
if ((ulsch) &&
|
||||
@@ -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_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);
|
||||
start_meas(&gNB->rx_pusch_stats);
|
||||
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);
|
||||
if (no_sig) {
|
||||
LOG_I(PHY, "PUSCH not detected in symbol %d\n",symbol);
|
||||
nr_fill_indication(gNB,frame_rx, slot_rx, ULSCH_id, harq_pid, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
start_meas(&gNB->rx_pusch_stats);
|
||||
for(uint8_t symbol = symbol_start; symbol < symbol_end; symbol++) {
|
||||
nr_rx_pusch(gNB, ULSCH_id, frame_rx, slot_rx, symbol, harq_pid);
|
||||
}
|
||||
int ulsch_power=0,ulsch_noise_power=0;
|
||||
for (int aarx=0;aarx<gNB->frame_parms.nb_antennas_rx;aarx++) {
|
||||
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;
|
||||
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);
|
||||
//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);
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#define CONFIG_STRING_L1_PUSCH_PROC_THREADS "pusch_proc_threads"
|
||||
#define CONFIG_STRING_L1_PUCCH0_DTX_THRESHOLD "pucch0_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 */
|
||||
/* optname helpstr paramflags XXXptr defXXXval type numelt */
|
||||
@@ -65,7 +66,8 @@
|
||||
{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_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_TRANSPORT_N_PREFERENCE_IDX 1
|
||||
@@ -79,6 +81,7 @@
|
||||
#define L1_PUSCH_PROC_THREADS 9
|
||||
#define L1_PUCCH0_DTX_THRESHOLD 10
|
||||
#define L1_PRACH_DTX_THRESHOLD 11
|
||||
#define L1_PUSCH_DTX_THRESHOLD 12
|
||||
|
||||
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
|
||||
#endif
|
||||
|
||||
@@ -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]->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]->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) {
|
||||
//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) {
|
||||
|
||||
@@ -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,
|
||||
bwpid);
|
||||
|
||||
|
||||
|
||||
// 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];
|
||||
|
||||
|
||||
@@ -236,7 +236,7 @@ void nr_process_mac_pdu(
|
||||
mac_sdu_len = (uint16_t)((NR_MAC_SUBHEADER_SHORT *)pdu_ptr)->L;
|
||||
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,
|
||||
rnti,
|
||||
module_idP,
|
||||
@@ -406,20 +406,20 @@ void handle_nr_ul_harq(module_id_t mod_id,
|
||||
} else {
|
||||
harq->round++;
|
||||
if (harq->round == MAX_HARQ_ROUNDS) {
|
||||
harq->ndi ^= 1;
|
||||
harq->round = 0;
|
||||
LOG_D(NR_MAC,
|
||||
"RNTI %04x: Ulharq id %d crc failed in all rounds\n",
|
||||
crc_pdu->rnti,
|
||||
harq_pid);
|
||||
UE_info->mac_stats[UE_id].ulsch_errors++;
|
||||
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
|
||||
} else {
|
||||
LOG_D(MAC,
|
||||
"Ulharq id %d crc failed for RNTI %04x\n",
|
||||
harq_pid,
|
||||
crc_pdu->rnti);
|
||||
add_tail_nr_list(&sched_ctrl->retrans_ul_harq, harq_pid);
|
||||
harq->ndi ^= 1;
|
||||
harq->round = 0;
|
||||
LOG_D(NR_MAC,
|
||||
"RNTI %04x: Ulharq id %d crc failed in all rounds\n",
|
||||
crc_pdu->rnti,
|
||||
harq_pid);
|
||||
UE_info->mac_stats[UE_id].ulsch_errors++;
|
||||
add_tail_nr_list(&sched_ctrl->available_ul_harq, harq_pid);
|
||||
} else {
|
||||
LOG_D(NR_MAC,
|
||||
"Ulharq id %d crc failed for RNTI %04x\n",
|
||||
harq_pid,
|
||||
crc_pdu->rnti);
|
||||
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,
|
||||
header_size + size + integrity_size, sdu_id);
|
||||
}
|
||||
|
||||
static void nr_pdcp_entity_set_integrity_key(nr_pdcp_entity_t *entity,
|
||||
char *key)
|
||||
static void nr_pdcp_entity_set_security(nr_pdcp_entity_t *entity,
|
||||
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__);
|
||||
exit(1);
|
||||
//memcpy(entity->integrity_key, key, 16);
|
||||
if (integrity_algorithm != -1)
|
||||
entity->integrity_algorithm = integrity_algorithm;
|
||||
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)
|
||||
@@ -310,10 +318,10 @@ nr_pdcp_entity_t *new_nr_pdcp_entity(
|
||||
|
||||
ret->type = type;
|
||||
|
||||
ret->recv_pdu = nr_pdcp_entity_recv_pdu;
|
||||
ret->recv_sdu = nr_pdcp_entity_recv_sdu;
|
||||
ret->set_integrity_key = nr_pdcp_entity_set_integrity_key;
|
||||
ret->set_time = nr_pdcp_entity_set_time;
|
||||
ret->recv_pdu = nr_pdcp_entity_recv_pdu;
|
||||
ret->recv_sdu = nr_pdcp_entity_recv_sdu;
|
||||
ret->set_security = nr_pdcp_entity_set_security;
|
||||
ret->set_time = nr_pdcp_entity_set_time;
|
||||
|
||||
ret->delete = nr_pdcp_entity_delete;
|
||||
|
||||
|
||||
@@ -40,7 +40,16 @@ typedef struct nr_pdcp_entity_t {
|
||||
void (*recv_sdu)(struct nr_pdcp_entity_t *entity, char *buffer, int size,
|
||||
int sdu_id);
|
||||
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);
|
||||
|
||||
/* callbacks provided to the PDCP module */
|
||||
|
||||
@@ -1044,6 +1044,12 @@ void pdcp_config_set_security(
|
||||
uint8_t *const kRRCint_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);
|
||||
|
||||
if ((security_modeP >= 0) && (security_modeP <= 0x77)) {
|
||||
@@ -1073,6 +1079,33 @@ void pdcp_config_set_security(
|
||||
PROTOCOL_PDCP_CTXT_ARGS(ctxt_pP,pdcp_pP),
|
||||
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(
|
||||
uint8_t *kRRCenc = NULL;
|
||||
uint8_t *kRRCint = NULL;
|
||||
uint8_t *kUPenc = NULL;
|
||||
uint8_t *k_kdf = NULL;
|
||||
pdcp_t *pdcp_p = NULL;
|
||||
static int print_keys= 1;
|
||||
hashtable_rc_t h_rc;
|
||||
hash_key_t key;
|
||||
|
||||
#ifndef PHYSIM
|
||||
/* Derive the keys from kgnb */
|
||||
if (SRB_configList != NULL) {
|
||||
nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm,
|
||||
ue_context_pP->ue_context.kgnb,
|
||||
&kUPenc);
|
||||
}
|
||||
/* Derive the keys from kgnb */
|
||||
if (SRB_configList != NULL) {
|
||||
k_kdf = NULL;
|
||||
nr_derive_key_up_enc(ue_context_pP->ue_context.ciphering_algorithm,
|
||||
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,
|
||||
ue_context_pP->ue_context.kgnb,
|
||||
&kRRCenc);
|
||||
nr_derive_key_rrc_int(ue_context_pP->ue_context.integrity_algorithm,
|
||||
ue_context_pP->ue_context.kgnb,
|
||||
&kRRCint);
|
||||
k_kdf = NULL;
|
||||
nr_derive_key_rrc_enc(ue_context_pP->ue_context.ciphering_algorithm,
|
||||
ue_context_pP->ue_context.kgnb,
|
||||
&k_kdf);
|
||||
/* kRRCenc: last 128 bits of key derivation function which returns 256 bits */
|
||||
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
|
||||
if (!IS_SOFTMODEM_IQPLAYER) {
|
||||
SET_LOG_DUMP(DEBUG_SECURITY) ;
|
||||
@@ -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) {
|
||||
|
||||
return NR_IntegrityProtAlgorithm_nia1;
|
||||
//only NIA2 supported for now
|
||||
return NR_IntegrityProtAlgorithm_nia2;
|
||||
|
||||
if (algorithms & NGAP_INTEGRITY_NIA3_MASK) {
|
||||
return NR_IntegrityProtAlgorithm_nia3;
|
||||
|
||||
@@ -90,8 +90,6 @@ pthread_mutex_t nfapi_sync_mutex;
|
||||
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
|
||||
|
||||
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;
|
||||
uint64_t num_missed_slots=0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user