mirror of
https://gitlab.eurecom.fr/oai/openairinterface5g.git
synced 2026-07-13 04:30:28 +00:00
Compare commits
2 Commits
load-radio
...
dcoffset2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd2396abc4 | ||
|
|
198f742085 |
@@ -607,6 +607,8 @@ void *emulatedRF_thread(void *param) {
|
||||
void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
RU_proc_t *proc = &ru->proc;
|
||||
NR_DL_FRAME_PARMS *fp = ru->nr_frame_parms;
|
||||
nfapi_nr_config_request_scf_t *cfg = &ru->config;
|
||||
int slot_type = nr_slot_select(cfg,*frame,*slot%fp->slots_per_frame);
|
||||
void *rxp[ru->nb_rx];
|
||||
unsigned int rxs;
|
||||
int i;
|
||||
@@ -615,6 +617,26 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
openair0_timestamp ts,old_ts;
|
||||
AssertFatal(*slot<fp->slots_per_frame && *slot>=0, "slot %d is illegal (%d)\n",*slot,fp->slots_per_frame);
|
||||
|
||||
int txsymb;
|
||||
int rxoff = 0;
|
||||
|
||||
if (cfg->cell_config.frame_duplex_type.value == TDD) {
|
||||
if(slot_type == NR_MIXED_SLOT) {
|
||||
txsymb = 0;
|
||||
|
||||
for(int symbol_count = 0; symbol_count<NR_NUMBER_OF_SYMBOLS_PER_SLOT; symbol_count++) {
|
||||
if (cfg->tdd_table.max_tdd_periodicity_list[*slot].max_num_of_symbol_per_slot_list[symbol_count].slot_config.value == 0)
|
||||
txsymb++;
|
||||
}
|
||||
|
||||
AssertFatal(txsymb>0,"illegal txsymb %d\n",txsymb);
|
||||
|
||||
if(*slot%(fp->slots_per_subframe/2))
|
||||
rxoff = txsymb * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
||||
else
|
||||
rxoff = (fp->ofdm_symbol_size + fp->nb_prefix_samples0) + (txsymb - 1) * (fp->ofdm_symbol_size + fp->nb_prefix_samples);
|
||||
}
|
||||
}
|
||||
start_meas(&ru->rx_fhaul);
|
||||
for (i=0; i<ru->nb_rx; i++)
|
||||
rxp[i] = (void *)&ru->common.rxdata[i][fp->get_samples_slot_timestamp(*slot,fp,0)];
|
||||
@@ -629,10 +651,12 @@ void rx_rf(RU_t *ru,int *frame,int *slot) {
|
||||
rxs = samples_per_slot;
|
||||
ts = old_ts + rxs;
|
||||
} else {
|
||||
LOG_I(PHY,"%d.%d => doing trx_read rxoff %d\n",*frame,*slot,rxoff);
|
||||
rxs = ru->rfdevice.trx_read_func(&ru->rfdevice,
|
||||
&ts,
|
||||
rxp,
|
||||
samples_per_slot,
|
||||
rxoff,
|
||||
ru->nb_rx);
|
||||
}
|
||||
|
||||
@@ -1390,7 +1414,7 @@ void *ru_thread( void *param ) {
|
||||
if (ru->feprx) {
|
||||
ru->feprx(ru,proc->tti_rx);
|
||||
//LOG_M("rxdata.m","rxs",ru->common.rxdata[0],1228800,1,1);
|
||||
if (initial_wait == 0 && proc->frame_rx == 127 ) {LOG_M("rxdata.m","rxs",ru->common.rxdata[0],fp->samples_per_frame,1,1); LOG_M("rxdataF.m","rxsF",RC.gNB[0]->common_vars.rxdataF[0],fp->symbols_per_slot*fp->ofdm_symbol_size,1,1); exit(-1);}
|
||||
if (initial_wait == 0 && proc->frame_rx == 127 && proc->tti_rx==19) {LOG_M("rxdata.m","rxs",ru->common.rxdata[0],fp->samples_per_frame,1,1); LOG_M("rxdataF.m","rxsF",RC.gNB[0]->common_vars.rxdataF[0],fp->symbols_per_slot*fp->ofdm_symbol_size,1,1); exit(-1);}
|
||||
LOG_D(PHY,"RU proc: frame_rx = %d, tti_rx = %d\n", proc->frame_rx, proc->tti_rx);
|
||||
/*
|
||||
LOG_D(PHY,"Copying rxdataF from RU to gNB\n");
|
||||
|
||||
@@ -307,7 +307,7 @@ void recv_IF4p5(RU_t *ru,
|
||||
while (ru->ifdevice.trx_read_func(&ru->ifdevice,
|
||||
(int64_t *) packet_type,
|
||||
&rx_buffer,
|
||||
db_fulllength,
|
||||
db_fulllength,0,
|
||||
0) < 0) {
|
||||
perror("ETHERNET read");
|
||||
read_cnt++;
|
||||
|
||||
@@ -1274,7 +1274,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int tti, uint16_t pa
|
||||
ru->ifdevice.trx_read_func(&ru->ifdevice,
|
||||
×tamp[packet_id],
|
||||
(void**)txp,
|
||||
spp_eth,
|
||||
spp_eth,0,
|
||||
fp->nb_antennas_tx);
|
||||
clock_gettime( CLOCK_MONOTONIC, &end_decomp);
|
||||
LOG_D(HW,"[SF %d] IF_Read_Time: %"PRId64"\n",subframe,clock_difftime_ns(start_decomp, end_decomp));
|
||||
|
||||
@@ -399,7 +399,7 @@ struct openair0_device_t {
|
||||
* \returns the number of sample read
|
||||
*/
|
||||
|
||||
int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps,int num_antennas);
|
||||
int (*trx_read_func)(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps,int rxoff,int num_antennas);
|
||||
|
||||
/*! \brief Receive samples from hardware, this version provides a single antenna at a time and returns.
|
||||
* Read \ref nsamps samples from each channel to buffers. buff[0] is the array for
|
||||
|
||||
@@ -619,16 +619,18 @@ int trx_usrp_write_init(openair0_device *device){
|
||||
* \param antenna_id Index of antenna for which to receive samples
|
||||
* \returns the number of sample read
|
||||
*/
|
||||
static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int cc) {
|
||||
static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp, void **buff, int nsamps, int dcoff,int cc) {
|
||||
usrp_state_t *s = (usrp_state_t *)device->priv;
|
||||
int samples_received=0;
|
||||
int nsamps2; // aligned to upper 32 or 16 byte boundary
|
||||
int nsamps2,dcoff2; // aligned to upper 32 or 16 byte boundary
|
||||
#if defined(__x86_64) || defined(__i386__)
|
||||
#ifdef __AVX2__
|
||||
nsamps2 = (nsamps+7)>>3;
|
||||
dcoff2 = (dcoff+7)>>3;
|
||||
__m256i buff_tmp[cc<2 ? 2 : cc][nsamps2];
|
||||
#else
|
||||
nsamps2 = (nsamps+3)>>2;
|
||||
dcoff2 = (dcoff+3)>>2;
|
||||
__m128i buff_tmp[cc<2 ? 2 : cc][nsamps2];
|
||||
#endif
|
||||
#elif defined(__arm__)
|
||||
@@ -682,11 +684,12 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
|
||||
__m256i mean=_mm256_setzero_si256();
|
||||
int16_t mean16[2];
|
||||
|
||||
for (int j=0; j<nsamps2<<1; j++) {
|
||||
for (int j=dcoff2<<1; j<nsamps2<<1; j++) {
|
||||
mean=_mm256_add_epi32(mean,_mm256_cvtepi16_epi32(((__m128i*)buff_tmp[i])[j]));
|
||||
}
|
||||
mean16[0] =(int16_t)((_mm256_extract_epi32(mean,0) + _mm256_extract_epi32(mean,2) + _mm256_extract_epi32(mean,4) + _mm256_extract_epi32(mean,6))/nsamps);
|
||||
mean16[1] =(int16_t)((_mm256_extract_epi32(mean,1) + _mm256_extract_epi32(mean,3) + _mm256_extract_epi32(mean,5) + _mm256_extract_epi32(mean,7))/nsamps);
|
||||
mean16[0] =(int16_t)((_mm256_extract_epi32(mean,0) + _mm256_extract_epi32(mean,2) + _mm256_extract_epi32(mean,4) + _mm256_extract_epi32(mean,6))/(nsamps-dcoff));
|
||||
mean16[1] =(int16_t)((_mm256_extract_epi32(mean,1) + _mm256_extract_epi32(mean,3) + _mm256_extract_epi32(mean,5) + _mm256_extract_epi32(mean,7))/(nsamps-dcoff));
|
||||
LOG_I(PHY,"%d,%d\n",mean16[0],mean16[1]);
|
||||
/*
|
||||
LOG_I(PHY,"mean16[0] %d mean16[1] %d (%d,%d,%d,%d,%d,%d,%d,%d)\n",mean16[0],mean16[1],
|
||||
_mm256_extract_epi32(mean,0),
|
||||
@@ -698,23 +701,23 @@ static int trx_usrp_read(openair0_device *device, openair0_timestamp *ptimestamp
|
||||
_mm256_extract_epi32(mean,6),
|
||||
_mm256_extract_epi32(mean,7)); */
|
||||
if ((((uintptr_t) buff[i])&0x1F)==0) {
|
||||
mean = _mm256_set1_epi32(*(uint32_t*)mean16);// FK: in some cases the buffer might not be 32 byte aligned, so we cannot use avx2
|
||||
mean = _mm256_set1_epi32(0/**(uint32_t*)mean16*/);// FK: in some cases the buffer might not be 32 byte aligned, so we cannot use avx2
|
||||
|
||||
for (int j=0; j<nsamps2; j++)
|
||||
((__m256i *)buff[i])[j] = _mm256_srai_epi16(_mm256_subs_epi16(buff_tmp[i][j],mean),rxshift);
|
||||
} else {
|
||||
__m128i mean128 = _mm_set1_epi32(*(uint32_t*)mean16);
|
||||
for (int j=0; j<(nsamps2<<1); j++)
|
||||
for (int j=dcoff2<<1; j<(nsamps2<<1); j++)
|
||||
((__m128i *)buff[i])[j] = _mm_srai_epi16(_mm_subs_epi16(((__m128i *)buff_tmp[i])[j],mean128),rxshift);
|
||||
}
|
||||
#else
|
||||
__m128i mean=mm_setzero_si128();
|
||||
for (int j=0; j<nsamps2<<1; j++) {
|
||||
for (int j=dcoff<<1; j<nsamps2<<1; j++) {
|
||||
mean=_mm_adds_epi32(mean,_mm_cvtepi16_epi32(((__m64*)buff_tmp[i])[j]));
|
||||
}
|
||||
mean16[0] =(int16_t)(( _mm_extract_epi32(mean,0) + _mm_extract_epi32(mean,2))/nsamps);
|
||||
mean16[1] =(int16_t)(( _mm_extract_epi32(mean,1) + _mm_extract_epi32(mean,3))/nsamps);
|
||||
mean = _mm_set1_epi32(*(uint32_t*)mean16);
|
||||
mean16[0] =(int16_t)(( _mm_extract_epi32(mean,0) + _mm_extract_epi32(mean,2))/(nsamps-dcoff));
|
||||
mean16[1] =(int16_t)(( _mm_extract_epi32(mean,1) + _mm_extract_epi32(mean,3))/(nsamps-dcoff));
|
||||
mean = _mm_set1_epi32(0/**(uint32_t*)mean16*/);
|
||||
for (int j=0; j<nsamps2; j++)
|
||||
((__m128i *)buff[i])[j] = _mm_srai_epi16(_mm_subs_epi16(buff_tmp[i][j],mean),rxshift);
|
||||
#endif
|
||||
@@ -1123,10 +1126,11 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
s->usrp->set_rx_dc_offset(true);
|
||||
if (device->type==USRP_X300_DEV) {
|
||||
openair0_cfg[0].rx_gain_calib_table = calib_table_x310;
|
||||
std::cerr << "-- Using calibration table: calib_table_x310" << std::endl;
|
||||
// s->usrp->set_rx_dc_offset(true);
|
||||
|
||||
}
|
||||
|
||||
if (device->type==USRP_N300_DEV) {
|
||||
|
||||
Reference in New Issue
Block a user