Commit 12ccca72 authored by francescomani's avatar francescomani

further improvements

parent 6e936198
......@@ -175,18 +175,8 @@ void rx_func(void *param)
T(T_GNB_PHY_DL_TICK, T_INT(gNB->Mod_id), T_INT(frame_tx), T_INT(slot_tx));
// disactivate PHY stats if UE is inactive for a given number of frames
for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
NR_gNB_PHY_STATS_t *stats = &gNB->phy_stats[i];
if(stats->active && (((frame_tx - stats->frame + 1024) % 1024) > NUMBER_FRAMES_PHY_UE_INACTIVE))
stats->active = false;
}
// disactivate ULSCH structure if it is inactive for a given number of frames
for (int i = 0; i < gNB->max_nb_pusch; i++) {
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[i];
if (ulsch->active && (((frame_tx - ulsch->harq_process->frame + 1024) % 1024) > NUMBER_FRAMES_PHY_UE_INACTIVE))
ulsch->active = false;
}
reset_active_stats(gNB, frame_tx);
reset_active_ulsch(gNB, frame_tx);
// RX processing
int rx_slot_type = nr_slot_select(cfg,frame_rx,slot_rx);
......
......@@ -99,6 +99,16 @@ NR_gNB_PHY_STATS_t *get_phy_stats(PHY_VARS_gNB *gNB, uint16_t rnti)
return(stats);
}
void reset_active_stats(PHY_VARS_gNB *gNB, int frame)
{
// disactivate PHY stats if UE is inactive for a given number of frames
for (int i = 0; i < MAX_MOBILES_PER_GNB; i++) {
NR_gNB_PHY_STATS_t *stats = &gNB->phy_stats[i];
if(stats->active && (((frame - stats->frame + 1024) % 1024) > NUMBER_FRAMES_PHY_UE_INACTIVE))
stats->active = false;
}
}
int init_codebook_gNB(PHY_VARS_gNB *gNB) {
if(gNB->frame_parms.nb_antennas_tx>1){
......
......@@ -208,7 +208,7 @@ void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot, int first_symb,int num_symb
//
// Todo:
// - averaging IIR filter for RX power and noise
void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq_pid, unsigned char symbol, uint8_t nrOfLayers)
void nr_gnb_measurements(PHY_VARS_gNB *gNB, NR_gNB_ULSCH_t *ulsch, NR_gNB_PUSCH *pusch_vars, unsigned char symbol, uint8_t nrOfLayers)
{
int rx_power_tot = 0;
......@@ -220,8 +220,8 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
PHY_MEASUREMENTS_gNB *meas = &gNB->measurements;
NR_DL_FRAME_PARMS *fp = &gNB->frame_parms;
int ch_offset = fp->ofdm_symbol_size * symbol;
int N_RB_UL = gNB->ulsch[ulsch_id]->harq_process->ulsch_pdu.rb_size;
ulsch_measurements_gNB *ulsch_measurements = &gNB->ulsch[ulsch_id]->ulsch_measurements;
int N_RB_UL = ulsch->harq_process->ulsch_pdu.rb_size;
ulsch_measurements_gNB *ulsch_measurements = &ulsch->ulsch_measurements;
int rx_power[fp->nb_antennas_rx];
for (int aarx = 0; aarx < fp->nb_antennas_rx; aarx++){
......@@ -230,7 +230,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
for (int aatx = 0; aatx < nrOfLayers; aatx++){
ulsch_measurements->rx_spatial_power[aatx][aarx] = (signal_energy_nodc(&gNB->pusch_vars[ulsch_id]->ul_ch_estimates[aatx*fp->nb_antennas_rx+aarx][ch_offset], N_RB_UL * NR_NB_SC_PER_RB));
ulsch_measurements->rx_spatial_power[aatx][aarx] = (signal_energy_nodc(&pusch_vars->ul_ch_estimates[aatx*fp->nb_antennas_rx+aarx][ch_offset], N_RB_UL * NR_NB_SC_PER_RB));
if (ulsch_measurements->rx_spatial_power[aatx][aarx] < 0) {
ulsch_measurements->rx_spatial_power[aatx][aarx] = 0;
......@@ -240,7 +240,7 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
rx_power[aarx] += ulsch_measurements->rx_spatial_power[aatx][aarx];
}
LOG_D(PHY, "[ULSCH ID %d] RX power in antenna %d = %d\n", ulsch_id, aarx, rx_power[aarx]);
LOG_D(PHY, "[RNTI %04x] RX power in antenna %d = %d\n", ulsch->rnti, aarx, rx_power[aarx]);
rx_power_tot += rx_power[aarx];
......@@ -252,13 +252,12 @@ void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq
ulsch_measurements->wideband_cqi_tot = dB_fixed2(rx_power_tot, meas->n0_power_tot);
ulsch_measurements->rx_rssi_dBm = rx_power_avg_dB + 30 - 10 * log10(pow(2, 30)) - (rx_gain - rx_gain_offset) - dB_fixed(fp->ofdm_symbol_size);
LOG_D(PHY, "[ULSCH %d] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d, RX Power tot %d\n",
ulsch_id,
LOG_D(PHY, "[RNTI %04x] RSSI %d dBm/RE, RSSI (digital) %d dB (N_RB_UL %d), WBand CQI tot %d dB, N0 Power tot %d, RX Power tot %d\n",
ulsch->rnti,
ulsch_measurements->rx_rssi_dBm,
rx_power_avg_dB,
N_RB_UL,
ulsch_measurements->wideband_cqi_tot,
meas->n0_power_tot,
rx_power_tot);
}
......@@ -53,7 +53,7 @@ void dump_nr_I0_stats(FILE *fd,PHY_VARS_gNB *gNB);
void gNB_I0_measurements(PHY_VARS_gNB *gNB,int slot,int first_symb,int num_symb);
void nr_gnb_measurements(PHY_VARS_gNB *gNB, uint8_t ulsch_id, unsigned char harq_pid, unsigned char symbol, uint8_t nrOfLayers);
void nr_gnb_measurements(PHY_VARS_gNB *gNB, NR_gNB_ULSCH_t *ulsch, NR_gNB_PUSCH *pusch_vars, unsigned char symbol, uint8_t nrOfLayers);
void nr_est_timing_advance_pusch(const NR_DL_FRAME_PARMS *frame_parms, const int32_t *ul_ch_estimates_time, NR_ULSCH_delay_t *delay);
......
......@@ -580,9 +580,3 @@ void dump_pdsch_stats(FILE *fd,PHY_VARS_gNB *gNB) {
}
}
}
void clear_pdsch_stats(PHY_VARS_gNB *gNB)
{
for (int i = 0; i < MAX_MOBILES_PER_GNB;i++)
memset((void*)&gNB->phy_stats[i].dlsch_stats,0,sizeof(gNB->phy_stats[i].dlsch_stats));
}
......@@ -75,6 +75,4 @@ void nr_emulate_dlsch_payload(uint8_t* payload, uint16_t size);
void dump_pdsch_stats(FILE *fd,PHY_VARS_gNB *gNB);
void clear_pdsch_stats(PHY_VARS_gNB *gNB);
#endif
......@@ -270,6 +270,9 @@ void nr_ulsch_compute_llr(int32_t *rxdataF_comp,
uint8_t symbol,
uint8_t mod_order);
void reset_active_stats(PHY_VARS_gNB *gNB, int frame);
void reset_active_ulsch(PHY_VARS_gNB *gNB, int frame);
void nr_fill_ulsch(PHY_VARS_gNB *gNB,
int frame,
int slot,
......
......@@ -34,14 +34,15 @@
#include "PHY/NR_TRANSPORT/nr_transport_common_proto.h"
#include "PHY/NR_TRANSPORT/nr_ulsch.h"
int16_t find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid, int frame)
NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid)
{
int16_t first_free_index = -1;
AssertFatal(gNB != NULL,"gNB is null\n");
NR_gNB_ULSCH_t *ulsch = NULL;
for (int i = 0; i < gNB->max_nb_pusch; i++) {
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[i];
ulsch = gNB->ulsch[i];
AssertFatal(ulsch != NULL, "gNB->ulsch[%d] is null\n", i);
if(!ulsch->active) {
if (first_free_index == -1)
......@@ -50,10 +51,13 @@ int16_t find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid, int frame)
else {
// if there is already an active ULSCH for this RNTI and HARQ_PID
if ((ulsch->harq_pid == pid) && (ulsch->rnti == rnti))
return i;
return ulsch;
}
}
return first_free_index;
if (first_free_index != -1)
ulsch = gNB->ulsch[first_free_index];
return ulsch;
}
void nr_fill_ulsch(PHY_VARS_gNB *gNB,
......@@ -63,23 +67,20 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB,
{
int harq_pid = ulsch_pdu->pusch_data.harq_process_id;
int ulsch_id = find_nr_ulsch(gNB, ulsch_pdu->rnti, harq_pid, frame);
AssertFatal((ulsch_id >= 0) && (ulsch_id < gNB->max_nb_pusch),
"illegal or no ulsch_id found!!! rnti %04x ulsch_id %d\n",ulsch_pdu->rnti,ulsch_id);
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[ulsch_id];
NR_gNB_ULSCH_t *ulsch = find_nr_ulsch(gNB, ulsch_pdu->rnti, harq_pid);
AssertFatal(ulsch, "No ulsch_id found for rnti %04x\n", ulsch_pdu->rnti);
ulsch->rnti = ulsch_pdu->rnti;
ulsch->harq_pid = harq_pid;
ulsch->handled = 0;
ulsch->active = true;
ulsch->frame = frame;
ulsch->slot = slot;
NR_UL_gNB_HARQ_t *harq = ulsch->harq_process;
harq->frame = frame;
harq->slot = slot;
harq->new_rx = ulsch_pdu->pusch_data.new_data_indicator;
LOG_D(PHY,"%d.%d ULSCH ID %d RNTI %x HARQ PID %d new data indicator %d\n",
frame, slot, ulsch_id, ulsch_pdu->rnti, harq_pid, ulsch_pdu->pusch_data.new_data_indicator);
LOG_D(PHY,"%d.%d RNTI %x HARQ PID %d new data indicator %d\n",
frame, slot, ulsch_pdu->rnti, harq_pid, ulsch_pdu->pusch_data.new_data_indicator);
if (harq->new_rx)
harq->round = 0;
else
......@@ -87,7 +88,19 @@ void nr_fill_ulsch(PHY_VARS_gNB *gNB,
memcpy(&ulsch->harq_process->ulsch_pdu, ulsch_pdu, sizeof(ulsch->harq_process->ulsch_pdu));
LOG_D(PHY,"Initializing nFAPI for ULSCH, UE %d, harq_pid %d\n", ulsch_id, harq_pid);
LOG_D(PHY,"Initializing nFAPI for ULSCH, harq_pid %d\n", harq_pid);
}
void reset_active_ulsch(PHY_VARS_gNB *gNB, int frame)
{
// disactivate ULSCH structure after a given number of frames
// no activity on this structure for NUMBER_FRAMES_PHY_UE_INACTIVE
// assuming UE disconnected or some other error occurred
for (int i = 0; i < gNB->max_nb_pusch; i++) {
NR_gNB_ULSCH_t *ulsch = gNB->ulsch[i];
if (ulsch->active && (((frame - ulsch->frame + 1024) % 1024) > NUMBER_FRAMES_PHY_UE_INACTIVE))
ulsch->active = false;
}
}
void nr_ulsch_unscrambling(int16_t* llr, uint32_t size, uint32_t Nid, uint32_t n_RNTI)
......@@ -159,10 +172,4 @@ void dump_pusch_stats(FILE *fd, PHY_VARS_gNB *gNB)
}
}
void clear_pusch_stats(PHY_VARS_gNB *gNB)
{
for (int i = 0; i < MAX_MOBILES_PER_GNB; i++)
memset((void*)&gNB->phy_stats[i].ulsch_stats,0,sizeof(gNB->phy_stats[i].ulsch_stats));
}
......@@ -83,11 +83,10 @@ void nr_ulsch_procedures(PHY_VARS_gNB *gNB,
int UE_id,
uint8_t harq_pid);
int16_t find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid, int frame);
NR_gNB_ULSCH_t *find_nr_ulsch(PHY_VARS_gNB *gNB, uint16_t rnti, int pid);
void dump_pusch_stats(FILE *fd,PHY_VARS_gNB *gNB);
void dump_nr_I0_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);
......@@ -101,13 +101,14 @@ NR_gNB_ULSCH_t *new_gNB_ulsch(uint8_t max_ldpc_iterations, uint16_t N_RB_UL)
ulsch->harq_pid = -1;
ulsch->active = false;
ulsch->harq_process = malloc16_clear(sizeof(ulsch->harq_process));
ulsch->harq_process->b = malloc16_clear(ulsch_bytes);
ulsch->harq_process->c = malloc16_clear(a_segments*sizeof(uint8_t *));
ulsch->harq_process->d = malloc16_clear(a_segments*sizeof(int16_t *));
NR_UL_gNB_HARQ_t *harq = malloc16_clear(sizeof(harq));
ulsch->harq_process = harq;
harq->b = malloc16_clear(ulsch_bytes * sizeof(*harq->b));
harq->c = malloc16_clear(a_segments * sizeof(*harq->c));
harq->d = malloc16_clear(a_segments * sizeof(*harq->d));
for (int r = 0; r < a_segments; r++) {
ulsch->harq_process->c[r] = malloc16_clear(8448*sizeof(uint8_t));
ulsch->harq_process->d[r] = malloc16_clear((68*384)*sizeof(int16_t));
harq->c[r] = malloc16_clear(8448 * sizeof(*harq->c[r]));
harq->d[r] = malloc16_clear(68 * 384 * sizeof(*harq->d[r]));
}
return(ulsch);
}
......@@ -538,20 +539,20 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_gNB_ULSCH_DECODING, 0);
if (harq_process->processedSegments == (harq_process->C)) {
LOG_D(PHY, "[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", phy_vars_gNB->Mod_id, harq_process->slot, harq_process->TBS);
if (harq_process->processedSegments == harq_process->C) {
LOG_D(PHY, "[gNB %d] ULSCH: Setting ACK for slot %d TBS %d\n", phy_vars_gNB->Mod_id, ulsch->slot, harq_process->TBS);
ulsch->active = false;
harq_process->round = 0;
LOG_D(PHY, "ULSCH received ok \n");
nr_fill_indication(phy_vars_gNB, harq_process->frame, harq_process->slot, ULSCH_id, harq_pid, 0, 0);
nr_fill_indication(phy_vars_gNB, ulsch->frame, ulsch->slot, ULSCH_id, harq_pid, 0, 0);
} else {
LOG_D(PHY,
"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, status %d, round %d, TBS %d)\n",
phy_vars_gNB->Mod_id,
harq_process->frame,
harq_process->slot,
ulsch->frame,
ulsch->slot,
harq_pid,
ulsch->active,
harq_process->round,
......@@ -559,7 +560,7 @@ uint32_t nr_ulsch_decoding(PHY_VARS_gNB *phy_vars_gNB,
ulsch->handled = 1;
no_iteration_ldpc = ulsch->max_ldpc_iterations + 1;
LOG_D(PHY, "ULSCH %d in error\n", ULSCH_id);
nr_fill_indication(phy_vars_gNB, harq_process->frame, harq_process->slot, ULSCH_id, harq_pid, 1, 0);
nr_fill_indication(phy_vars_gNB, ulsch->frame, ulsch->slot, ULSCH_id, harq_pid, 1, 0);
}
ulsch->last_iteration_cnt = no_iteration_ldpc;
}
......
......@@ -1885,7 +1885,7 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
&max_ch);
}
nr_gnb_measurements(gNB, ulsch_id, harq_pid, symbol, rel15_ul->nrOfLayers);
nr_gnb_measurements(gNB, gNB->ulsch[ulsch_id], gNB->pusch_vars[ulsch_id], symbol, rel15_ul->nrOfLayers);
for (aarx = 0; aarx < frame_parms->nb_antennas_rx; aarx++) {
if (symbol == rel15_ul->start_symbol_index) {
......
......@@ -188,10 +188,6 @@ typedef struct {
typedef struct {
/// Nfapi ULSCH PDU
nfapi_nr_pusch_pdu_t ulsch_pdu;
/// Frame where current HARQ round was sent
uint32_t frame;
/// Slot where current HARQ round was sent
uint32_t slot;
/// Index of current HARQ round for this DLSCH
uint8_t round;
bool new_rx;
......@@ -261,6 +257,8 @@ typedef struct {
} NR_ULSCH_delay_t;
typedef struct {
uint32_t frame;
uint32_t slot;
/// Pointers to 16 HARQ processes for the ULSCH
NR_UL_gNB_HARQ_t *harq_process;
/// HARQ process mask, indicates which processes are currently active
......
......@@ -244,16 +244,16 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req)
if (rdata->nbSegments == ulsch_harq->processedSegments) {
if (decodeSuccess && !gNB->pusch_vars[rdata->ulsch_id]->DTX) {
LOG_D(PHY,"[gNB %d] ULSCH: Setting ACK for SFN/SF %d.%d (rnti %x, pid %d, ndi %d, status %d, round %d, TBS %d, Max interation (all seg) %d)\n",
gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot, ulsch->rnti, rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator,
gNB->Mod_id, ulsch->frame, ulsch->slot, ulsch->rnti, rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator,
ulsch->active, ulsch_harq->round, ulsch_harq->TBS, rdata->decodeIterations);
ulsch->active = false;
ulsch_harq->round = 0;
LOG_D(PHY, "ULSCH received ok \n");
nr_fill_indication(gNB, ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 0,0);
nr_fill_indication(gNB, ulsch->frame, ulsch->slot, rdata->ulsch_id, rdata->harq_pid, 0,0);
//dumpsig=1;
} else {
LOG_D(PHY,"[gNB %d] ULSCH: Setting NAK for SFN/SF %d/%d (pid %d, ndi %d, status %d, round %d, RV %d, prb_start %d, prb_size %d, TBS %d) r %d\n",
gNB->Mod_id, ulsch_harq->frame, ulsch_harq->slot,
gNB->Mod_id, ulsch->frame, ulsch->slot,
rdata->harq_pid, pusch_pdu->pusch_data.new_data_indicator, ulsch->active,
ulsch_harq->round,
ulsch_harq->ulsch_pdu.pusch_data.rv_index,
......@@ -263,7 +263,7 @@ void nr_postDecode(PHY_VARS_gNB *gNB, notifiedFIFO_elt_t *req)
r);
ulsch->handled = 1;
LOG_D(PHY, "ULSCH %d in error\n",rdata->ulsch_id);
nr_fill_indication(gNB,ulsch_harq->frame, ulsch_harq->slot, rdata->ulsch_id, rdata->harq_pid, 1,0);
nr_fill_indication(gNB, ulsch->frame, ulsch->slot, rdata->ulsch_id, rdata->harq_pid, 1,0);
// dumpsig=1;
}
/*
......@@ -558,8 +558,8 @@ void fill_ul_rb_mask(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
NR_UL_gNB_HARQ_t *ulsch_harq = ulsch->harq_process;
AssertFatal(ulsch_harq != NULL,"harq_pid %d is not allocated\n",harq_pid);
if ((ulsch->active == true) &&
(ulsch_harq->frame == frame_rx) &&
(ulsch_harq->slot == slot_rx) &&
(ulsch->frame == frame_rx) &&
(ulsch->slot == slot_rx) &&
(ulsch->handled == 0)) {
uint8_t symbol_start = ulsch_harq->ulsch_pdu.start_symbol_index;
uint8_t symbol_end = symbol_start + ulsch_harq->ulsch_pdu.nr_of_symbols;
......@@ -779,8 +779,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
AssertFatal(ulsch_harq != NULL, "harq_pid %d is not allocated\n", ulsch->harq_pid);
if ((ulsch->active == true) &&
(ulsch_harq->frame == frame_rx) &&
(ulsch_harq->slot == slot_rx) &&
(ulsch->frame == frame_rx) &&
(ulsch->slot == slot_rx) &&
(ulsch->handled == 0)) {
LOG_D(PHY, "PUSCH ID %d with RNTI %x detection started in frame %d slot %d\n",
......
......@@ -951,8 +951,6 @@ int main(int argc, char **argv)
reset_meas(&gNB->tparity);
reset_meas(&gNB->toutput);
clear_pdsch_stats(gNB);
uint32_t errors_scrambling[16] = {0};
int n_errors[16] = {0};
int round_trials[16] = {0};
......
......@@ -986,8 +986,6 @@ int main(int argc, char **argv)
double blerStats[16] = {0};
double berStats[16] = {0};
clear_pusch_stats(gNB);
uint64_t sum_pusch_delay = 0;
int min_pusch_delay = INT_MAX;
int max_pusch_delay = INT_MIN;
......@@ -1506,9 +1504,9 @@ int main(int argc, char **argv)
if (!crc_status)
effRate += ((double)TBS) / (double)round;
sum_pusch_delay += gNB->measurements.delay[UE_id].pusch_est_delay;
min_pusch_delay = gNB->measurements.delay[UE_id].pusch_est_delay < min_pusch_delay ? gNB->measurements.delay[UE_id].pusch_est_delay : min_pusch_delay;
max_pusch_delay = gNB->measurements.delay[UE_id].pusch_est_delay > max_pusch_delay ? gNB->measurements.delay[UE_id].pusch_est_delay : max_pusch_delay;
sum_pusch_delay += ulsch_gNB->delay.pusch_est_delay;
min_pusch_delay = ulsch_gNB->delay.pusch_est_delay < min_pusch_delay ? ulsch_gNB->delay.pusch_est_delay : min_pusch_delay;
max_pusch_delay = ulsch_gNB->delay.pusch_est_delay > max_pusch_delay ? ulsch_gNB->delay.pusch_est_delay : max_pusch_delay;
delay_pusch_est_count++;
} // trial loop
......
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