Commit a9c8b1b6 authored by 111's avatar 111

oxgrg changes for 4 ants

parent e4ed054c
......@@ -228,12 +228,16 @@ void rx_func(void *param) {
L1_nr_prach_procedures(gNB,frame_rx,slot_rx);
//apply the rx signal rotation here
for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) {
apply_nr_rotation_ul(&gNB->frame_parms,
gNB->common_vars.rxdataF[aa],
slot_rx,
0,
gNB->frame_parms.Ncp==EXTENDED?12:14);
//for (int aa = 0; aa < gNB->frame_parms.nb_antennas_rx; aa++) {
for (int aa = 0; aa < 4; aa++) {
if (gNB->common_vars.rxdataF[aa] != NULL)
{
apply_nr_rotation_ul(&gNB->frame_parms,
gNB->common_vars.rxdataF[aa],
slot_rx,
0,
gNB->frame_parms.Ncp==EXTENDED?12:14);
}
}
phy_procedures_gNB_uespec_RX(gNB, frame_rx, slot_rx);
}
......
......@@ -852,23 +852,36 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) {
for (i=0; i<ru->nb_tx; i++) {
if (ru->if_frequency == 0) {
cfg->tx_freq[i] = (double)fp->dl_CarrierFreq;
cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
} else if (ru->if_freq_offset) {
cfg->tx_freq[i] = (double)(ru->if_frequency);
cfg->rx_freq[i] = (double)(ru->if_frequency + ru->if_freq_offset);
LOG_I(PHY, "Setting IF TX frequency to %lu Hz with IF RX frequency offset %d Hz\n", ru->if_frequency, ru->if_freq_offset);
} else {
cfg->tx_freq[i] = (double)ru->if_frequency;
}
cfg->tx_gain[i] = ru->att_tx;
cfg->configFilename = rf_config_file;
LOG_I(PHY, "Channel %d: setting tx_gain offset %.0f, tx_freq %.0f Hz, tune_offset %.0f Hz, sample_rate %.0f Hz\n",
i, cfg->tx_gain[i],
cfg->tx_freq[i],
cfg->tune_offset,
cfg->sample_rate);
}
for (i=0; i<ru->nb_rx; i++) {
if (ru->if_frequency == 0) {
cfg->rx_freq[i] = (double)fp->ul_CarrierFreq;
} else if (ru->if_freq_offset) {
cfg->rx_freq[i] = (double)(ru->if_frequency + ru->if_freq_offset);
LOG_I(PHY, "Setting IF RX frequency to %lu Hz with IF RX frequency offset %d Hz\n", ru->if_frequency, ru->if_freq_offset);
} else {
cfg->rx_freq[i] = (double)(ru->if_frequency+fp->ul_CarrierFreq-fp->dl_CarrierFreq);
}
cfg->tx_gain[i] = ru->att_tx;
cfg->rx_gain[i] = ru->max_rxgain-ru->att_rx;
cfg->configFilename = rf_config_file;
LOG_I(PHY, "Channel %d: setting tx_gain offset %.0f, rx_gain offset %.0f, tx_freq %.0f Hz, rx_freq %.0f Hz, tune_offset %.0f Hz, sample_rate %.0f Hz\n",
i, cfg->tx_gain[i],
LOG_I(PHY, "Channel %d: setting rx_gain offset %.0f, trx_freq %.0f Hz, tune_offset %.0f Hz, sample_rate %.0f Hz\n",
i,
cfg->rx_gain[i],
cfg->tx_freq[i],
cfg->rx_freq[i],
cfg->tune_offset,
cfg->sample_rate);
......@@ -1422,7 +1435,7 @@ void init_RU_proc(RU_t *ru) {
pthread_mutex_init( &proc->mutex_emulateRF,NULL);
pthread_cond_init( &proc->cond_emulateRF, NULL);
threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "ru_thread", ru->tpcores[0], OAI_PRIORITY_RT_MAX );
threadCreate( &proc->pthread_FH, ru_thread, (void *)ru, "ru_thread", /*ru->tpcores[0]*/ 4, OAI_PRIORITY_RT_MAX );
if(emulate_rf)
threadCreate( &proc->pthread_emulateRF, emulatedRF_thread, (void *)proc, "emulateRF", -1, OAI_PRIORITY_RT );
if (opp_enabled == 1)
......
......@@ -181,6 +181,11 @@ void main()
printf("socket ERROR !!! \n\n\n");
return;
}
else if (recv_len == 32768)
{
recv_len = recv(iSocketFD, &buf[recv_len], RIC_INTERFACE_SOCKET_MAX_LEN, 0);
recv_len += 32768;
}
printf("Received(%d):, msg len %d, cnt %d\n", recv_len, pdata[0], pdata[1]);
// for(int i=0;i<20;i++)
......@@ -193,7 +198,7 @@ void main()
{
memcpy(buf_debug, buf, recv_len);
FILE *fd;
if ((fd = fopen("srs_data.am","w")) != NULL) {
if ((fd = fopen("srs_data_4ant.am","w")) != NULL) {
fwrite((void *)buf_debug,
sizeof(int32_t),
recv_len/4,
......
......@@ -622,9 +622,10 @@ int phy_init_nr_gNB(PHY_VARS_gNB *gNB)
/// Transport init necessary for NR synchro
init_nr_transport(gNB);
LOG_I(PHY, "prx %d~~~~~~~~~~~~~~~~~~~~\n", Prx);
common_vars->txdataF = (int32_t **)malloc16(Ptx*sizeof(int32_t*));
common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*));
//common_vars->rxdataF = (int32_t **)malloc16(Prx*sizeof(int32_t*));
common_vars->rxdataF = (int32_t **)malloc16(4*sizeof(int32_t*));
/* Do NOT allocate per-antenna txdataF/rxdataF: the gNB gets a pointer to the
* RU to copy/recover freq-domain memory from there */
common_vars->beam_id = (uint8_t **)malloc16(Ptx*sizeof(uint8_t*));
......
......@@ -2129,8 +2129,8 @@ void nr_rx_pusch(PHY_VARS_gNB *gNB,
uint pusch_amp;
if (symbol == (rel15_ul->start_symbol_index + rel15_ul->nr_of_symbols - 1)) {
static int cnt = 0;
//if (((cnt & 0x1F) == 0) && (cnt < 0x100))
if ( (cnt < 0x100))
if (((cnt & 0x7F) == 0) || (cnt < 0x80))
//if ( (cnt < 0x100))
{
pusch_amp = cal_amp(&gNB->pusch_vars[ulsch_id]->rxdataF_ext[0][symbol * nb_re_pusch], nb_re_pusch);
//LOG_I(PHY, "UL AMP frame %d %d, symbol %d, rbs %d, res %d, time %d, freq %d \n", frame, slot, symbol, nb_re_pusch/12, nb_re_pusch, g_ul_time_amp[symbol], g_ul_freq_amp[symbol], pusch_amp);
......
......@@ -242,21 +242,26 @@ int nr_cap_srs_signal(PHY_VARS_gNB *gNB,
int len = frame_parms->N_RB_DL * 6;
int32_t *dst = ns_srs_cap->dmrsData;
int32_t *src;
for (int ant = 0; ant < frame_parms->nb_antennas_rx; ant++)
int ant_num = 0;
for (int ant = 0; ant < 4; ant++)
{
for (int l_line = 0; l_line < N_symb_SRS; l_line++)
if (rxdataF[ant]!=NULL)
{
src = (int32_t *)&rxdataF[ant][symbol_offset + l_line * gNB->frame_parms.ofdm_symbol_size];
memcpy(dst, &src[gNB->frame_parms.ofdm_symbol_size - len], len*4);
dst += len;
memcpy(dst, &src[0], len*4);
dst += len;
}
for (int l_line = 0; l_line < N_symb_SRS; l_line++)
{
src = (int32_t *)&rxdataF[ant][symbol_offset + l_line * gNB->frame_parms.ofdm_symbol_size];
memcpy(dst, &src[gNB->frame_parms.ofdm_symbol_size - len], len*4);
dst += len;
memcpy(dst, &src[0], len*4);
dst += len;
}
ant_num++;
}
}
#ifdef SEND_BY_SOCKET
ric_send_buf = ns_srs_cap;
ric_send_len = 40*2+273*12*frame_parms->nb_antennas_rx*N_symb_SRS*4;//for test
ric_send_len = 40*2+273*12*ant_num*N_symb_SRS*4;//for test
sem_post(&ric_send_sem);
//LOG_I(PHY,"sem_post(&ric_send_sem) buf %p, size %d pos %d \n\n\n",ric_send_buf,ric_send_len, pos);
g_dmrs_cnt++;
......
......@@ -218,7 +218,7 @@ int generate_srs_nr(nfapi_nr_srs_pdu_t *srs_config_pdu,
uint16_t m_SRS_b = srs_bandwidth_config[C_SRS][B_SRS][0]; // Number of resource blocks
uint16_t M_sc_b_SRS = m_SRS_b * NR_NB_SC_PER_RB/K_TC; // Length of the SRS sequence
//#ifdef SRS_DEBUG
#ifdef SRS_DEBUG
if ((frame_number % 1024) == 8)
{
LOG_I(NR_PHY,"Frame = %i, slot = %i\n", frame_number, slot_number);
......@@ -243,7 +243,7 @@ if ((frame_number % 1024) == 8)
LOG_I(NR_PHY,"m_SRS_b = %i\n", m_SRS_b);
LOG_I(NR_PHY,"M_sc_b_SRS = %i\n", M_sc_b_SRS);
}
//#endif
#endif
// Validation of SRS config parameters
......
......@@ -865,7 +865,8 @@ int phy_procedures_gNB_uespec_RX(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx) {
NR_gNB_SRS_t *srs = gNB->srs[i];
if (srs) {
if ((srs->active == 1) && (srs->frame == frame_rx) && (srs->slot == slot_rx)) {
LOG_D(NR_PHY, "(%d.%d) gNB is waiting for SRS, id = %i\n", frame_rx, slot_rx, i);
LOG_D(NR_PHY, "(%d.%d) gNB is waiting for SRS, id = %i ant rx %d\n", frame_rx, slot_rx, i, gNB->frame_parms.nb_antennas_rx);
NR_DL_FRAME_PARMS *frame_parms = &gNB->frame_parms;
nfapi_nr_srs_pdu_t *srs_pdu = &srs->srs_pdu;
......
......@@ -386,6 +386,8 @@ int trx_oxgrf_set_gains(openair0_device* device, openair0_config_t *openair0_cfg
int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
int status;
int tx_rf_num = 1;
int rx_rf_num = 1;
oxgrf_state_t *oxgrf = (oxgrf_state_t*)malloc(sizeof(oxgrf_state_t));
......@@ -449,6 +451,11 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
oxgrf->rx_num_channels = openair0_cfg[0].rx_num_channels;
oxgrf->tx_num_channels = openair0_cfg[0].tx_num_channels;
if (oxgrf->rx_num_channels > 2)
rx_rf_num = 2;
if (oxgrf->tx_num_channels > 2)
tx_rf_num = 2;
int auxdac1 = 0;
char args[64];
if (openair0_cfg[0].sdr_addrs == NULL) {
......@@ -507,75 +514,81 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
oxgrf_set_duplex_select (oxgrf->dev, 0, FDD);
oxgrf_set_trxsw_fpga_enable(oxgrf->dev, 0, 0);
oxgrf_set_rx_ant_enable (oxgrf->dev, 0, 1);
oxgrf_set_tx_fir_en_dis (oxgrf->dev, 0, 0);
oxgrf_set_rx_fir_en_dis (oxgrf->dev, 0, 0);
// RX port Initialize
if ((status = oxgrf_set_rx_lo_freq(oxgrf->dev, 0, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[oxgrf] Failed to set RX frequency\n");
} else
printf("[oxgrf] set RX frequency to %lu\n",(uint64_t)(openair0_cfg->rx_freq[0]));
if ((status = oxgrf_set_rx_sampling_freq(oxgrf->dev, 0, (uint32_t)(openair0_cfg->sample_rate))) < 0) {
printf("[oxgrf] Failed to set RX sample rate\n");
} else
printf("[oxgrf] set RX sample rate to %u\n", (uint32_t)(openair0_cfg->sample_rate));
if ((status = oxgrf_set_rx_rf_bandwidth(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_bw))) < 0) {
printf("[oxgrf] Failed to set RX bandwidth\n");
} else
printf("[oxgrf] set RX bandwidth to %u\n",(uint32_t)(openair0_cfg->rx_bw));
if ((status = oxgrf_set_rx1_gain_control_mode(oxgrf->dev, 0, 0)) < 0){
printf("[oxgrf] Failed to set RX1 Gain Control Mode\n");
} else
printf("[oxgrf] set RX1 Gain Control Mode MGC\n");
if ((status = oxgrf_set_rx1_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[oxgrf] Failed to set RX1 gain\n");
} else
printf("[oxgrf] set RX1 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[0]));
for (int rfid = 0; rfid < rx_rf_num; rfid++)
{
oxgrf_set_rx_fir_en_dis (oxgrf->dev, 0, 0);
// RX port Initialize
if ((status = oxgrf_set_rx_lo_freq(oxgrf->dev, rfid, (uint64_t)(openair0_cfg->rx_freq[0]))) < 0) {
printf("[oxgrf %d] Failed to set RX frequency\n", rfid);
} else
printf("[oxgrf %d] set RX frequency to %lu\n", rfid,(uint64_t)(openair0_cfg->rx_freq[0]));
if ((status = oxgrf_set_rx_sampling_freq(oxgrf->dev, rfid, (uint32_t)(openair0_cfg->sample_rate))) < 0) {
printf("[oxgrf %d] Failed to set RX sample rate\n", rfid);
} else
printf("[oxgrf %d] set RX sample rate to %u\n", rfid, (uint32_t)(openair0_cfg->sample_rate));
if ((status = oxgrf_set_rx_rf_bandwidth(oxgrf->dev, rfid, (uint32_t)(openair0_cfg->rx_bw))) < 0) {
printf("[oxgrf %d] Failed to set RX bandwidth\n, rfid");
} else
printf("[oxgrf %d] set RX bandwidth to %u\n", rfid,(uint32_t)(openair0_cfg->rx_bw));
if(oxgrf->rx_num_channels > 1) {
if ((status = oxgrf_set_rx2_gain_control_mode(oxgrf->dev, 0, 0)) < 0){
printf("[oxgrf] Failed to set RX2 Gain Control Mode\n");
if ((status = oxgrf_set_rx1_gain_control_mode(oxgrf->dev, rfid, 0)) < 0){
printf("[oxgrf %d] Failed to set RX1 Gain Control Mode\n", rfid);
} else
printf("[oxgrf] set RX2 Gain Control Mode MGC\n");
printf("[oxgrf %d] set RX1 Gain Control Mode MGC\n", rfid);
if ((status = oxgrf_set_rx2_rf_gain(oxgrf->dev, 0, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[oxgrf] Failed to set RX2 gain\n");
if ((status = oxgrf_set_rx1_rf_gain(oxgrf->dev, rfid, (uint32_t)(openair0_cfg->rx_gain[0] > 65?65:openair0_cfg->rx_gain[0]))) < 0) {
printf("[oxgrf %d] Failed to set RX1 gain\n", rfid);
} else
printf("[oxgrf] set RX2 gain to %u\n",(uint32_t)(openair0_cfg->rx_gain[1]));
printf("[oxgrf %d] set RX1 gain to %u\n", rfid,(uint32_t)(openair0_cfg->rx_gain[0]));
if(oxgrf->rx_num_channels > rfid*2+1) {
if ((status = oxgrf_set_rx2_gain_control_mode(oxgrf->dev, rfid, 0)) < 0){
printf("[oxgrf %d] Failed to set RX2 Gain Control Mode\n", rfid);
} else
printf("[oxgrf %d] set RX2 Gain Control Mode MGC\n", rfid);
if ((status = oxgrf_set_rx2_rf_gain(oxgrf->dev, rfid, (uint32_t)(openair0_cfg->rx_gain[1] > 65?65:openair0_cfg->rx_gain[1]))) < 0) {
printf("[oxgrf %d] Failed to set RX2 gain\n", rfid);
} else
printf("[oxgrf %d] set RX2 gain to %u\n", rfid, (uint32_t)(openair0_cfg->rx_gain[1]));
}
}
// TX port Initialize
if ((status = oxgrf_set_tx_lo_freq(oxgrf->dev, 0, (uint64_t)openair0_cfg->tx_freq[0])) < 0) {
printf("[oxgrf] Failed to set TX frequency\n");
} else
printf("[oxgrf] set TX Frequency to %lu\n", (uint64_t)openair0_cfg->tx_freq[0]);
for (int rfid = 0; rfid < tx_rf_num; rfid++)
{
oxgrf_set_tx_fir_en_dis (oxgrf->dev, 0, 0);
if ((status = oxgrf_set_tx_sampling_freq(oxgrf->dev, 0, (uint32_t)openair0_cfg->sample_rate)) < 0) {
printf("[oxgrf] Failed to set TX sample rate\n");
} else
printf("[oxgrf] set TX sampling rate to %u\n", (uint32_t)openair0_cfg->sample_rate);
if ((status = oxgrf_set_tx_lo_freq(oxgrf->dev, rfid, (uint64_t)openair0_cfg->tx_freq[0])) < 0) {
printf("[oxgrf %d] Failed to set TX frequency\n", rfid);
} else
printf("[oxgrf %d] set TX Frequency to %lu\n", rfid, (uint64_t)openair0_cfg->tx_freq[0]);
if ((status = oxgrf_set_tx_rf_bandwidth(oxgrf->dev, 0, (uint32_t)openair0_cfg->tx_bw)) <0) {
printf("[oxgrf] Failed to set TX bandwidth\n");
} else
printf("[oxgrf] set TX bandwidth to %u\n", (uint32_t)openair0_cfg->tx_bw);
if ((status = oxgrf_set_tx_sampling_freq(oxgrf->dev, rfid, (uint32_t)openair0_cfg->sample_rate)) < 0) {
printf("[oxgrf %d] Failed to set TX sample rate\n", rfid, rfid);
} else
printf("[oxgrf %d] set TX sampling rate to %u\n", rfid, (uint32_t)openair0_cfg->sample_rate);
int tx_gain = ((uint32_t)openair0_cfg->tx_gain[0] > 90?90:(uint32_t)openair0_cfg->tx_gain[0]);
if ((status = oxgrf_set_tx1_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX1 gain\n");
} else
printf("[oxgrf] set the TX1 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[0]);
if ((status = oxgrf_set_tx_rf_bandwidth(oxgrf->dev, rfid, (uint32_t)openair0_cfg->tx_bw)) <0) {
printf("[oxgrf %d] Failed to set TX bandwidth\n", rfid);
} else
printf("[oxgrf %d] set TX bandwidth to %u\n", rfid, (uint32_t)openair0_cfg->tx_bw);
if(oxgrf->tx_num_channels > 1) {
tx_gain = ((uint32_t)openair0_cfg->tx_gain[1] > 90?90:(uint32_t)openair0_cfg->tx_gain[1]);
if ((status = oxgrf_set_tx2_attenuation(oxgrf->dev, 0, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf] Failed to set TX2 gain\n");
int tx_gain = ((uint32_t)openair0_cfg->tx_gain[0] > 90?90:(uint32_t)openair0_cfg->tx_gain[0]);
if ((status = oxgrf_set_tx1_attenuation(oxgrf->dev, rfid, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf %d] Failed to set TX1 gain\n", rfid);
} else
printf("[oxgrf] set the TX2 gain to %d\n", (uint32_t)openair0_cfg->tx_gain[1]);
printf("[oxgrf %d] set the TX1 gain to %d\n", rfid, (uint32_t)openair0_cfg->tx_gain[0]);
if(oxgrf->tx_num_channels > rfid*2+1) {
tx_gain = ((uint32_t)openair0_cfg->tx_gain[1] > 90?90:(uint32_t)openair0_cfg->tx_gain[1]);
if ((status = oxgrf_set_tx2_attenuation(oxgrf->dev, rfid, (90 - tx_gain) * 1000)) < 0) {
printf("[oxgrf %d] Failed to set TX2 gain\n", rfid);
} else
printf("[oxgrf %d] set the TX2 gain to %d\n", rfid, (uint32_t)openair0_cfg->tx_gain[1]);
}
}
oxgrf_enable_timestamp(oxgrf->dev, 0, 0);
usleep(5);
oxgrf_enable_timestamp(oxgrf->dev, 0, 1);
......
......@@ -29,7 +29,7 @@ gNBs =
min_rxtxtime = 6;
pdsch_AntennaPorts_XP = 1;
pusch_AntennaPorts = 2;
do_CSIRS = 1;
#do_CSIRS = 1;
do_SRS = 1;
ul_prbblacklist = "135,136,137,138"
......@@ -238,8 +238,8 @@ MACRLCs = (
num_cc = 1;
tr_s_preference = "local_L1";
tr_n_preference = "local_RRC";
pusch_TargetSNRx10 = 150;
pucch_TargetSNRx10 = 200;
pusch_TargetSNRx10 = 250;
pucch_TargetSNRx10 = 300;
pusch_FailureThres = 1000;
ulsch_max_frame_inactivity = 0;
}
......@@ -264,7 +264,7 @@ RUs = (
bands = [78];
num_tp_cores = 8;
max_pdschReferenceSignalPower = -27;
max_rxgain = 45;
max_rxgain = 15;
eNB_instances = [0];
##beamforming 1x2 matrix: 1 layer x 2 antennas
#bf_weights = [0x00007fff, 0x0000];
......
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