Commit d645536c authored by Florian Kaltenberger's avatar Florian Kaltenberger

multi TRP SRS estimation

parent f47cba09
......@@ -1730,6 +1730,14 @@ typedef struct {
uint32_t value[16384]; // tag=0: Only the most significant bytes of the size indicated by ‘length’ field are valid. Remaining bytes are zero padded to the nearest 32-bit bit boundary; Tag=2 Offset from the end of the control portion of the message to the payload is in the value field. Occupies 32-bits.
} nfapi_srs_report_tlv_t;
typedef enum{
NFAPI_NR_SRS_usage_beamManagement = 0,
NFAPI_NR_SRS_usage_codebook = 1,
NFAPI_NR_SRS_usage_nonCodebook = 2,
NFAPI_NR_SRS_usage_antennaSwitching = 3,
NFAPI_NR_SRS_usage_localization = 4
} nfapi_nr_srs_usage_type_e;
typedef struct {
uint32_t handle; // The handle passed to the PHY in the the UL_TTI.request SRS PDU.
uint16_t rnti; // The RNTI passed to the PHY in the UL_TTI.request SRS PDU. Value: 1 -> 65535.
......
......@@ -46,8 +46,9 @@
/* Generic function to find the peak of channel estimation buffer */
int32_t nr_est_toa_ns_srs(NR_DL_FRAME_PARMS *frame_parms,
uint8_t N_ap,
int32_t srs_estimated_channel_freq[N_ap][frame_parms->ofdm_symbol_size])
uint8_t N_ap,
int32_t srs_estimated_channel_freq[N_ap][frame_parms->ofdm_symbol_size],
int16_t *srs_toa_ns)
{
int32_t chF_interpol[N_ap][NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size] __attribute__((aligned(32)));
......@@ -71,19 +72,30 @@ int32_t nr_est_toa_ns_srs(NR_DL_FRAME_PARMS *frame_parms,
(int16_t*) chT_interpol[p_index]);
}
for(int k = 0; k < NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size; k++) {
abs_val = 0;
for (int p_index = 0; p_index < N_ap; p_index++) {
for (int p_index = 0; p_index < N_ap; p_index++) {
for(int k = 0; k < NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size; k++) {
abs_val = 0;
abs_val += squaredMod(((c16_t*)chT_interpol[p_index])[k]);
}
mean_val += (abs_val - mean_val)/(k+1);
if(abs_val > max_val)
{
max_val = abs_val;
max_idx = k;
mean_val += (abs_val - mean_val)/(k+1);
if(abs_val > max_val) {
max_val = abs_val;
max_idx = k;
}
}
}
if(max_idx > NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size >>1)
max_idx = max_idx - NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size;
// Check for detection threshold
LOG_D(PHY, "SRS ToA estimator (ant %d): max_val %d, mean_val %d, max_idx %d\n", p_index, max_val, mean_val, max_idx);
if ((mean_val != 0) && (max_val / mean_val > 10)) {
srs_toa_ns[p_index] = (max_idx*1e9)/(NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->samples_per_frame*100);
} else {
srs_toa_ns[p_index] = 0xFFFF;
}
}
// Add T tracer to log these chF and chT
/*
T(T_GNB_PHY_UL_FREQ_CHANNEL_ESTIMATE_OVER_SAMPLING,
......@@ -103,17 +115,8 @@ int32_t nr_est_toa_ns_srs(NR_DL_FRAME_PARMS *frame_parms,
T_BUFFER(chT_interpol[0][0], NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size * sizeof(int32_t)));
*/
if(max_idx > NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size >>1)
max_idx = max_idx - NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->ofdm_symbol_size;
// Check for detection threshold
LOG_D(PHY, "SRS ToA estimator: max_val %d, mean_val %d, max_idx %d\n", max_val, mean_val, max_idx);
if ((mean_val != 0) && (max_val / mean_val > 10)) {
return (max_idx*1e9)/(NR_SRS_IDFT_OVERSAMP_FACTOR*frame_parms->samples_per_frame*100);
} else {
return 0xFFFF;
}
// return toa of first antenna for backward compatibility
return srs_toa_ns[0];
}
__attribute__((always_inline)) inline c16_t c32x16cumulVectVectWithSteps(c16_t *in1,
......
......@@ -66,8 +66,9 @@ int nr_est_timing_advance_srs(const NR_DL_FRAME_PARMS *frame_parms,
const int32_t srs_estimated_channel_time[N_ap][frame_parms->ofdm_symbol_size]);
int32_t nr_est_toa_ns_srs(NR_DL_FRAME_PARMS *frame_parms,
uint8_t N_ap,
int32_t srs_estimated_channel_freq[N_ap][frame_parms->ofdm_symbol_size]);
uint8_t N_ap,
int32_t srs_estimated_channel_freq[N_ap][frame_parms->ofdm_symbol_size],
int16_t *srs_toa_ns);
void nr_pusch_ptrs_processing(PHY_VARS_gNB *gNB,
NR_DL_FRAME_PARMS *frame_parms,
......
......@@ -29,6 +29,7 @@
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_interface.h"
#include "nfapi/open-nFAPI/nfapi/public_inc/nfapi_nr_interface.h"
#include "fapi_nr_l1.h"
#include "nfapi.h"
#include "common/utils/LOG/log.h"
#include "common/utils/LOG/vcd_signal_dumper.h"
#include "PHY/INIT/nr_phy_init.h"
......@@ -1022,29 +1023,33 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
srs_indication->rnti = srs_pdu->rnti;
uint8_t N_ap = 1<<srs_pdu->num_ant_ports;
int16_t srs_toa_ns[N_ap];
start_meas(&gNB->srs_timing_advance_stats);
srs_indication->timing_advance_offset = srs_est >= 0 ? nr_est_timing_advance_srs(frame_parms, N_ap, srs_estimated_channel_time[0]) : 0xFFFF;
stop_meas(&gNB->srs_timing_advance_stats);
srs_indication->timing_advance_offset_nsec = srs_est >= 0 ? nr_est_toa_ns_srs(frame_parms, N_ap, srs_estimated_channel_freq[0]) : 0xFFFF;
srs_indication->timing_advance_offset_nsec = srs_est >= 0 ? nr_est_toa_ns_srs(frame_parms, N_ap, srs_estimated_channel_freq[0], srs_toa_ns) : 0xFFFF;
//(int16_t)((((int32_t)srs_indication->timing_advance_offset - 31) * ((int32_t)TC_NSEC_x32768)) >> 15) : 0xFFFF;
switch (srs_pdu->srs_parameters_v4.usage) {
case 0:
LOG_W(NR_PHY, "SRS report was not requested by MAC\n");
return 0;
case 1 << NR_SRS_ResourceSet__usage_beamManagement:
case 1 << NFAPI_NR_SRS_usage_beamManagement:
srs_indication->srs_usage = NR_SRS_ResourceSet__usage_beamManagement;
break;
case 1 << NR_SRS_ResourceSet__usage_codebook:
case 1 << NFAPI_NR_SRS_usage_codebook:
srs_indication->srs_usage = NR_SRS_ResourceSet__usage_codebook;
break;
case 1 << NR_SRS_ResourceSet__usage_nonCodebook:
case 1 << NFAPI_NR_SRS_usage_nonCodebook:
srs_indication->srs_usage = NR_SRS_ResourceSet__usage_nonCodebook;
break;
case 1 << NR_SRS_ResourceSet__usage_antennaSwitching:
case 1 << NFAPI_NR_SRS_usage_antennaSwitching:
srs_indication->srs_usage = NR_SRS_ResourceSet__usage_antennaSwitching;
break;
case 1 << NFAPI_NR_SRS_usage_localization: //bit 4 is reserved in the standard
srs_indication->srs_usage = NFAPI_NR_SRS_usage_localization;
break;
default:
LOG_E(NR_PHY, "Invalid srs_pdu->srs_parameters_v4.usage %i\n", srs_pdu->srs_parameters_v4.usage);
}
......@@ -1149,6 +1154,18 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx)
LOG_W(NR_PHY, "PHY procedures for this SRS usage are not implemented yet!\n");
break;
case NFAPI_NR_SRS_usage_localization: {
// this is a custom usage not in the standard
// we send Timing advance offset in nanoseconds for each TRP (= antenna)
uint8_t *pWritePackedMessage = (uint8_t*) report_tlv->value;
uint8_t *end = (uint8_t*) report_tlv->value + sizeof(report_tlv->value);
for (int p_index = 0; p_index < N_ap; p_index++) {
report_tlv->length += push16(srs_toa_ns[p_index],&pWritePackedMessage,end);
}
break;
}
default:
AssertFatal(1 == 0, "Invalid SRS usage\n");
}
......
......@@ -524,7 +524,7 @@ static void nr_configure_srs_f1ap(nfapi_nr_srs_pdu_t *srs_pdu,
// TODO: This should be completed
srs_pdu->srs_parameters_v4.srs_bandwidth_size = m_SRS[srs_pdu->config_index];
srs_pdu->srs_parameters_v4.usage = 1; //codebook - to be checked
srs_pdu->srs_parameters_v4.usage = 1 << NFAPI_NR_SRS_usage_localization;
srs_pdu->srs_parameters_v4.report_type[0] = 1;
srs_pdu->srs_parameters_v4.iq_representation = 1;
srs_pdu->srs_parameters_v4.prg_size = 1;
......
......@@ -1222,7 +1222,24 @@ void handle_nr_srs_measurements(const module_id_t module_id,
if (srs_ind->rnti == NON_UE_ASSOCIATED_SRS_DUMMY_RNTI) {
LOG_I(NR_MAC, "Received Non-UE associated SRS with ToA %d (ns)\n",srs_ind->timing_advance_offset_nsec);
nrmac->meas_pos_info.toa_ns = srs_ind->timing_advance_offset_nsec;
nrmac->meas_pos_info.toa_ns[0] = srs_ind->timing_advance_offset_nsec;
if (srs_ind->srs_usage != NFAPI_NR_SRS_usage_localization) {
LOG_W(NR_MAC,"received SRS indication with NON_UE_ASSOCIATED but SRS usage not for localization");
} else {
uint32_t *pReadPackedMessage = srs_ind->report_tlv.value;
uint32_t *endReadPackedMessage = srs_ind->report_tlv.value+srs_ind->report_tlv.length;
uint16_t bytesRead = 0;
memset(nrmac->meas_pos_info.toa_ns, 0, sizeof(nrmac->meas_pos_info.toa_ns));
for (int p_index = 0; p_index < srs_ind->report_tlv.length/2; p_index++) {
bytesRead += pull16(&pReadPackedMessage, &nrmac->meas_pos_info.toa_ns[p_index], endReadPackedMessage);
}
}
f1ap_measurement_req_t *req = nrmac->f1ap_meas_req;
/* response has same type as request... */
......@@ -1265,7 +1282,7 @@ void handle_nr_srs_measurements(const module_id_t module_id,
nfapi_srs_report_tlv_t *report_tlv = &srs_ind->report_tlv;
switch (srs_ind->srs_usage) {
case NR_SRS_ResourceSet__usage_beamManagement: {
case NFAPI_NR_SRS_usage_beamManagement: {
nfapi_nr_srs_beamforming_report_t nr_srs_bf_report;
unpack_nr_srs_beamforming_report(report_tlv->value,
report_tlv->length,
......@@ -1313,7 +1330,7 @@ void handle_nr_srs_measurements(const module_id_t module_id,
break;
}
case NR_SRS_ResourceSet__usage_codebook: {
case NFAPI_NR_SRS_usage_codebook: {
nfapi_nr_srs_normalized_channel_iq_matrix_t nr_srs_channel_iq_matrix;
unpack_nr_srs_normalized_channel_iq_matrix(report_tlv->value,
report_tlv->length,
......@@ -1369,8 +1386,8 @@ void handle_nr_srs_measurements(const module_id_t module_id,
break;
}
case NR_SRS_ResourceSet__usage_nonCodebook:
case NR_SRS_ResourceSet__usage_antennaSwitching:
case NFAPI_NR_SRS_usage_nonCodebook:
case NFAPI_NR_SRS_usage_antennaSwitching:
LOG_W(NR_MAC, "MAC procedures for this SRS usage are not implemented yet!\n");
break;
......
......@@ -710,7 +710,7 @@ typedef struct {
uint8_t pos_report_characteristics; // (M) // ondemand = 0, periodic = 1
uint8_t pos_measurement_periodicity; //(C) if report characteristics periodic ms120=0, ms240=1, ms480=2, ms640=3, ms1024=4, ms20
uint8_t pos_report_valid; // (C) if report has been received from L1 sets this to 1 and once response is sent its set back to 0
int16_t toa_ns; // for the moment we only support toa measurements, others can be added here later
int16_t toa_ns[NB_ANTENNAS_RX]; // for the moment we only support toa measurements, others can be added here later
} NR_meas_pos_t;
/*! \brief UE list used by gNB to order UEs/CC for scheduling*/
......
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