Commit e6f3c9b8 authored by Cedric Roux's avatar Cedric Roux

Merge branch 'enhancement-10-harmony' into develop_integration_w03

Conflicts:
	targets/RT/USER/lte-enb.c
	targets/RT/USER/lte-softmodem.c
parents da0cbaf8 56241235
......@@ -29,7 +29,7 @@
#include "LAYER2/MAC/extern.h"
#include "MBSFN-SubframeConfigList.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
//#define DEBUG_PHY
#define DEBUG_PHY
#include "assertions.h"
#include <math.h>
......@@ -1304,25 +1304,26 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
common_vars->txdataF[eNB_id] = (int32_t **)malloc16(NB_ANTENNA_PORTS_ENB*sizeof(int32_t*));
common_vars->txdataF_BF[eNB_id] = (int32_t **)malloc16(fp->nb_antennas_tx*sizeof(int32_t*));
for (i=0; i<14; i++) {
common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
if (eNB->node_function != NGFI_RRU_IF5) {
for (i=0; i<((eNB->do_precoding==0)?fp->nb_antennas_tx:14); i++) {
common_vars->txdataF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t) );
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][INIT] lte_common_vars->txdataF[%d][%d] = %p (%d bytes)\n",
eNB_id,i,common_vars->txdataF[eNB_id][i],
fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t));
printf("[openair][LTE_PHY][INIT] common_vars->txdataF[%d][%d] = %p (%lu bytes)\n",
eNB_id,i,common_vars->txdataF[eNB_id][i],
fp->ofdm_symbol_size*fp->symbols_per_tti*10*sizeof(int32_t));
#endif
}
}
for (i=0; i<fp->nb_antennas_tx; i++) {
common_vars->txdataF_BF[eNB_id][i] = (int32_t*)malloc16_clear(fp->ofdm_symbol_size*sizeof(int32_t) );
if (eNB->node_function != NGFI_RCC_IF4p5)
common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear(fp->samples_per_tti*10*sizeof(int32_t) );
// Allocate 10 subframes of I/Q TX signal data (time) if not
common_vars->txdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][INIT] lte_common_vars->txdataF_BF[%d][%d] = %p (%d bytes)\n",
eNB_id,i,common_vars->txdataF_BF[eNB_id][i],
fp->ofdm_symbol_size*sizeof(int32_t));
msg("[openair][LTE_PHY][INIT] lte_common_vars->txdata[%d][%d] = %p\n",eNB_id,i,common_vars->txdata[eNB_id][i]);
printf("[openair][LTE_PHY][INIT] common_vars->txdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->txdata[eNB_id][i],
fp->samples_per_tti*10*sizeof(int32_t));
#endif
}
......@@ -1358,17 +1359,25 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
for (i=0; i<fp->nb_antennas_rx; i++) {
if (eNB->node_function != NGFI_RCC_IF4p5) {
// allocate 2 subframes of I/Q signal data (time) if not an RCC (no time-domain signals)
common_vars->rxdata[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*10*sizeof(int32_t) );
common_vars->rxdata_7_5kHz[eNB_id][i] = (int32_t*)malloc16_clear( fp->samples_per_tti*sizeof(int32_t) );
if (eNB->node_function != NGFI_RRU_IF5)
// allocate 2 subframes of I/Q signal data (time, 7.5 kHz offset)
common_vars->rxdata_7_5kHz[eNB_id][i] = (int32_t*)malloc16_clear( 2*fp->samples_per_tti*2*sizeof(int32_t) );
}
if (eNB->node_function != NGFI_RRU_IF5)
// allocate 2 subframes of I/Q signal data (frequency)
common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(2*fp->ofdm_symbol_size*fp->symbols_per_tti) );
#ifdef DEBUG_PHY
printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p\n",eNB_id,i,common_vars->rxdata[eNB_id][i]);
printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i]);
printf("[openair][LTE_PHY][INIT] common_vars->rxdata[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata[eNB_id][i],fp->samples_per_tti*10*sizeof(int32_t));
if (eNB->node_function != NGFI_RRU_IF5)
printf("[openair][LTE_PHY][INIT] common_vars->rxdata_7_5kHz[%d][%d] = %p (%lu bytes)\n",eNB_id,i,common_vars->rxdata_7_5kHz[eNB_id][i],fp->samples_per_tti*2*sizeof(int32_t));
#endif
}
common_vars->rxdataF[eNB_id][i] = (int32_t*)malloc16_clear(sizeof(int32_t)*(fp->ofdm_symbol_size*fp->symbols_per_tti) );
}
if (eNB->node_function != NGFI_RRU_IF4p5) {
if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
// Channel estimates for SRS
for (UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
......@@ -1383,7 +1392,8 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
common_vars->sync_corr[eNB_id] = (uint32_t*)malloc16_clear( LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*sizeof(uint32_t)*fp->samples_per_tti );
}
} else { //UPLINK abstraction = 1
} // abstraction_flag = 0
else { //UPLINK abstraction = 1
eNB->sinr_dB = (double*) malloc16_clear( fp->N_RB_DL*12*sizeof(double) );
}
} //eNB_id
......@@ -1391,7 +1401,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
if (abstraction_flag==0) {
if (eNB->node_function != NGFI_RRU_IF4p5) {
if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
generate_ul_ref_sigs_rx();
// SRS
......@@ -1405,7 +1415,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
// ULSCH VARS, skip if NFGI_RRU_IF4
if (eNB->node_function!=NGFI_RRU_IF4p5)
if ((eNB->node_function!=NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5))
prach_vars->prachF = (int16_t*)malloc16_clear( 1024*2*sizeof(int16_t) );
/* number of elements of an array X is computed as sizeof(X) / sizeof(X[0]) */
......@@ -1418,7 +1428,7 @@ int phy_init_lte_eNB(PHY_VARS_eNB *eNB,
#endif
}
if (eNB->node_function != NGFI_RRU_IF4p5) {
if ((eNB->node_function != NGFI_RRU_IF4p5)&&(eNB->node_function != NGFI_RRU_IF5)) {
AssertFatal(fp->nb_antennas_rx <= sizeof(prach_vars->prach_ifft) / sizeof(prach_vars->prach_ifft[0]),
"nb_antennas_rx too large");
for (i=0; i<fp->nb_antennas_rx; i++) {
......
......@@ -22,6 +22,23 @@
#include "defs.h"
#include "log.h"
uint16_t dl_S_table_normal[10]={3,9,10,11,12,3,9,10,11,6};
uint16_t dl_S_table_extended[10]={3,8,9,10,3,8,9,5,0,0};
void set_S_config(LTE_DL_FRAME_PARMS *fp) {
int X = fp->srsX;
fp->ul_symbols_in_S_subframe=(1+X);
if ((fp->Ncp==EXTENDED) && (fp->tdd_config_S>7))
AssertFatal(1==0,"Illegal S subframe configuration for Extended Prefix mode\n");
fp->dl_symbols_in_S_subframe = (fp->Ncp==NORMAL)?dl_S_table_normal[fp->tdd_config_S] : dl_S_table_extended[fp->tdd_config_S];
}
int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
{
......@@ -29,7 +46,7 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
LOG_I(PHY,"Initializing frame parms for N_RB_DL %d, Ncp %d, osf %d\n",frame_parms->N_RB_DL,frame_parms->Ncp,osf);
if (frame_parms->Ncp==1) {
if (frame_parms->Ncp==EXTENDED) {
frame_parms->nb_prefix_samples0=512;
frame_parms->nb_prefix_samples = 512;
frame_parms->symbols_per_tti = 12;
......@@ -37,8 +54,10 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
frame_parms->nb_prefix_samples0 = 160;
frame_parms->nb_prefix_samples = 144;
frame_parms->symbols_per_tti = 14;
}
switch(osf) {
case 1:
log2_osf = 0;
......@@ -167,6 +186,8 @@ int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf)
printf("lte_parms.c: Setting N_RB_DL to %d, ofdm_symbol_size %d\n",frame_parms->N_RB_DL, frame_parms->ofdm_symbol_size);
if (frame_parms->frame_type == TDD) set_S_config(frame_parms);
// frame_parms->tdd_config=3;
return(0);
}
......
......@@ -510,14 +510,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
// perform a time domain correlation using the oversampled sync sequence
unsigned int n, ar, peak_val, peak_pos, mean_val;
unsigned int n, ar, peak_val, peak_pos;
uint64_t mean_val;
int result;
short *primary_synch_time;
int eNB_id = frame_parms->Nid_cell%3;
// msg("[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length);
if (sync_corr_eNB == NULL) {
msg("[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n");
LOG_E(PHY,"[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n");
return(-1);
}
......@@ -535,7 +536,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
break;
default:
msg("[SYNC TIME] Illegal eNB_id!\n");
LOG_E(PHY,"[SYNC TIME] Illegal eNB_id!\n");
return (-1);
}
......@@ -567,7 +568,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
peak_val);
}
*/
mean_val += (sync_corr_eNB[n]>>10);
mean_val += sync_corr_eNB[n];
if (sync_corr_eNB[n]>peak_val) {
peak_val = sync_corr_eNB[n];
......@@ -575,17 +576,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
}
}
mean_val/=length;
*peak_val_out = peak_val;
if (peak_val <= (40*mean_val)) {
#ifdef DEBUG_PHY
msg("[SYNC TIME] No peak found (%u,%u,%u,%u)\n",peak_pos,peak_val,mean_val,40*mean_val);
#endif
if (peak_val <= (40*(uint32_t)mean_val)) {
LOG_D(PHY,"[SYNC TIME] No peak found (%u,%u,%u,%u)\n",peak_pos,peak_val,mean_val,40*mean_val);
return(-1);
} else {
#ifdef DEBUG_PHY
msg("[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %u\n",peak_pos,peak_val,mean_val);
#endif
LOG_D(PHY,"[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %u\n",peak_pos,peak_val,mean_val);
return(peak_pos);
}
......
......@@ -32,16 +32,20 @@
#include "PHY/defs.h"
#include "PHY/TOOLS/alaw_lut.h"
#include "PHY/extern.h"
#include "SCHED/defs.h"
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
//#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type, int k) {
LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
int32_t **txdataF = eNB->common_vars.txdataF[0];
int32_t **rxdataF = eNB->common_vars.rxdataF[0];
int16_t **rxsigF = eNB->prach_vars.rxsigF;
void *tx_buffer = eNB->ifbuffer.tx;
int32_t **txdataF = (eNB->CC_id==0) ? eNB->common_vars.txdataF[0] : PHY_vars_eNB_g[0][0]->common_vars.txdataF[0];
int32_t **rxdataF = eNB->common_vars.rxdataF[0];
int16_t **rxsigF = eNB->prach_vars.rxsigF;
void *tx_buffer = eNB->ifbuffer.tx[subframe&1];
void *tx_buffer_prach = eNB->ifbuffer.tx_prach;
uint16_t symbol_id=0, element_id=0;
uint16_t db_fulllength, db_halflength;
......@@ -49,31 +53,44 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
uint16_t *data_block=NULL, *i=NULL;
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
IF4p5_header_t *packet_header=NULL;
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
int nsym = fp->symbols_per_tti;
if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
if (packet_type == IF4p5_PDLFFT) {
if (subframe_select(fp,subframe)==SF_S)
nsym=fp->dl_symbols_in_S_subframe;
db_fulllength = 12*fp->N_RB_DL;
db_halflength = (db_fulllength)>>1;
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
IF4p5_header_t *dl_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
gen_IF4p5_dl_header(dl_header, frame, subframe);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer);
data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
}
gen_IF4p5_dl_header(packet_header, frame, subframe);
for (symbol_id=0; symbol_id<fp->symbols_per_tti; symbol_id++) {
for (symbol_id=0; symbol_id<nsym; symbol_id++) {
if (eNB->CC_id==1) LOG_I(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,frame,subframe,symbol_id);
for (element_id=0; element_id<db_halflength; element_id++) {
i = (uint16_t*) &txdataF[0][blockoffsetF+element_id];
i = (uint16_t*) &txdataF[eNB->CC_id][blockoffsetF+element_id];
data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
i = (uint16_t*) &txdataF[0][slotoffsetF+element_id];
i = (uint16_t*) &txdataF[eNB->CC_id][slotoffsetF+element_id];
data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
}
dl_header->frame_status &= ~(0x000f<<26);
dl_header->frame_status |= (symbol_id&0x000f)<<26;
packet_header->frame_status &= ~(0x000f<<26);
packet_header->frame_status |= (symbol_id&0x000f)<<26;
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
......@@ -87,58 +104,92 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
slotoffsetF += fp->ofdm_symbol_size;
blockoffsetF += fp->ofdm_symbol_size;
}
} else if (packet_type == IF4p5_PULFFT) {
} else if ((packet_type == IF4p5_PULFFT)||
(packet_type == IF4p5_PULTICK)){
db_fulllength = 12*fp->N_RB_UL;
db_halflength = (db_fulllength)>>1;
slotoffsetF = 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
IF4p5_header_t *ul_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
gen_IF4p5_ul_header(ul_header, frame, subframe);
for (symbol_id=0; symbol_id<fp->symbols_per_tti; symbol_id++) {
for (element_id=0; element_id<db_halflength; element_id++) {
i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id];
data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
if (subframe_select(fp,subframe)==SF_S) {
nsym=fp->ul_symbols_in_S_subframe;
slotoffsetF += (fp->ofdm_symbol_size*(fp->symbols_per_tti-nsym));
blockoffsetF += (fp->ofdm_symbol_size*(fp->symbols_per_tti-nsym));
}
i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id];
data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
}
ul_header->frame_status &= ~(0x000f<<26);
ul_header->frame_status |= (symbol_id&0x000f)<<26;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer);
data_block = (uint16_t*)(tx_buffer + sizeof_IF4p5_header_t);
}
gen_IF4p5_ul_header(packet_header, packet_type, frame, subframe);
if (packet_type == IF4p5_PULFFT) {
for (symbol_id=fp->symbols_per_tti-nsym; symbol_id<fp->symbols_per_tti; symbol_id++) {
LOG_D(PHY,"IF4p5_PULFFT: frame %d, subframe %d, symbol %d\n",frame,subframe,symbol_id);
for (element_id=0; element_id<db_halflength; element_id++) {
i = (uint16_t*) &rxdataF[0][blockoffsetF+element_id];
data_block[element_id] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
i = (uint16_t*) &rxdataF[0][slotoffsetF+element_id];
data_block[element_id+db_halflength] = ((uint16_t) lin2alaw[*i]) | (lin2alaw[*(i+1)]<<8);
}
packet_header->frame_status &= ~(0x000f<<26);
packet_header->frame_status |= (symbol_id&0x000f)<<26;
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
&tx_buffer,
db_fulllength,
1,
IF4p5_PULFFT)) < 0) {
perror("ETHERNET write for IF4p5_PULFFT\n");
}
slotoffsetF += fp->ofdm_symbol_size;
blockoffsetF += fp->ofdm_symbol_size;
}
}
else {
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
&tx_buffer,
db_fulllength,
1,
IF4p5_PULFFT)) < 0) {
perror("ETHERNET write for IF4p5_PULFFT\n");
0,
&tx_buffer,
0,
1,
IF4p5_PULTICK)) < 0) {
perror("ETHERNET write for IF4p5_PULFFT\n");
}
slotoffsetF += fp->ofdm_symbol_size;
blockoffsetF += fp->ofdm_symbol_size;
}
}
} else if (packet_type == IF4p5_PRACH) {
// FIX: hard coded prach samples length
db_fulllength = 840*2;
IF4p5_header_t *prach_header = (IF4p5_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
LOG_D(PHY,"IF4p5_PRACH: frame %d, subframe %d\n",frame,subframe);
db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t *)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t *)(tx_buffer_prach);
data_block = (uint16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t);
}
gen_IF4p5_prach_header(packet_header, frame, subframe);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((int16_t*)(tx_buffer_prach + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
(&rxsigF[0][k]),
PRACH_BLOCK_SIZE_BYTES);
} else {
memcpy((int16_t*)(tx_buffer_prach + sizeof_IF4p5_header_t),
(&rxsigF[0][k]),
PRACH_BLOCK_SIZE_BYTES);
}
gen_IF4p5_prach_header(prach_header, frame, subframe);
memcpy((int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4p5_header_t),
(&rxsigF[0][k]),
db_fulllength*sizeof(int16_t));
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
&tx_buffer,
&tx_buffer_prach,
db_fulllength,
1,
IF4p5_PRACH)) < 0) {
......@@ -148,7 +199,7 @@ void send_IF4p5(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type
AssertFatal(1==0, "send_IF4p5 - Unknown packet_type %x", packet_type);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );
if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );
return;
}
......@@ -163,8 +214,9 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
uint16_t element_id;
uint16_t db_fulllength, db_halflength;
int slotoffsetF=0, blockoffsetF=0;
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );
if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );
if (eNB->node_function == NGFI_RRU_IF4p5) {
db_fulllength = (12*fp->N_RB_DL);
......@@ -183,17 +235,28 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
0) < 0) {
perror("ETHERNET read");
}
packet_header = (IF4p5_header_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t);
if (eth->flags == ETH_RAW_IF4p5_MODE) {
packet_header = (IF4p5_header_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t);
} else {
packet_header = (IF4p5_header_t*) (rx_buffer);
data_block = (uint16_t*) (rx_buffer+sizeof_IF4p5_header_t);
}
*frame = ((packet_header->frame_status)>>6)&0xffff;
*subframe = ((packet_header->frame_status)>>22)&0x000f;
*subframe = ((packet_header->frame_status)>>22)&0x000f;
*packet_type = packet_header->sub_type;
if (*packet_type == IF4p5_PDLFFT) {
*symbol_number = ((packet_header->frame_status)>>26)&0x000f;
LOG_D(PHY,"DL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number);
slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + (*subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
......@@ -210,6 +273,8 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
} else if (*packet_type == IF4p5_PULFFT) {
*symbol_number = ((packet_header->frame_status)>>26)&0x000f;
if (eNB->CC_id==1) LOG_I(PHY,"UL_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe,*symbol_number);
slotoffsetF = (*symbol_number)*(fp->ofdm_symbol_size) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength - 1;
......@@ -224,18 +289,27 @@ void recv_IF4p5(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_t
}
} else if (*packet_type == IF4p5_PRACH) {
if (eNB->CC_id==1) LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d, symbol %d\n",eNB->CC_id,*frame,*subframe);
// FIX: hard coded prach samples length
db_fulllength = 840*2;
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t),
db_fulllength*sizeof(int16_t));
db_fulllength = PRACH_HARD_CODED_NUM_SAMPLES;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4p5_header_t),
PRACH_BLOCK_SIZE_BYTES);
} else {
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+sizeof_IF4p5_header_t),
PRACH_BLOCK_SIZE_BYTES);
}
} else if (*packet_type == IF4p5_PULTICK) {
} else {
AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type);
}
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 );
if (eNB->CC_id==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 );
return;
}
......@@ -253,10 +327,10 @@ void gen_IF4p5_dl_header(IF4p5_header_t *dl_packet, int frame, int subframe) {
}
void gen_IF4p5_ul_header(IF4p5_header_t *ul_packet, int frame, int subframe) {
void gen_IF4p5_ul_header(IF4p5_header_t *ul_packet, uint16_t packet_subtype, int frame, int subframe) {
ul_packet->type = IF4p5_PACKET_TYPE;
ul_packet->sub_type = IF4p5_PULFFT;
ul_packet->sub_type = packet_subtype;
ul_packet->rsvd = 0;
......@@ -282,6 +356,18 @@ void gen_IF4p5_prach_header(IF4p5_header_t *prach_packet, int frame, int subfram
void malloc_IF4p5_buffer(PHY_VARS_eNB *eNB) {
// Keep the size large enough
eNB->ifbuffer.tx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
eth_state_t *eth = (eth_state_t*) (eNB->ifdevice.priv);
int i;
if (eth->flags == ETH_RAW_IF4p5_MODE) {
for (i=0;i<10;i++)
eNB->ifbuffer.tx[i] = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.tx_prach = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(RAW_IF4p5_PRACH_SIZE_BYTES);
} else {
for (i=0;i<10;i++)
eNB->ifbuffer.tx[i] = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.tx_prach = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(UDP_IF4p5_PRACH_SIZE_BYTES);
}
}
......@@ -37,6 +37,7 @@
#define IF4p5_PULFFT 0x0019
#define IF4p5_PDLFFT 0x0020
#define IF4p5_PRACH 0x0021
#define IF4p5_PULTICK 0x0022
struct IF4p5_header {
/// Type
......@@ -55,7 +56,7 @@ typedef struct IF4p5_header IF4p5_header_t;
void gen_IF4p5_dl_header(IF4p5_header_t*, int, int);
void gen_IF4p5_ul_header(IF4p5_header_t*, int, int);
void gen_IF4p5_ul_header(IF4p5_header_t*, uint16_t, int, int);
void gen_IF4p5_prach_header(IF4p5_header_t*, int, int);
......
......@@ -21,11 +21,11 @@
/*! \file PHY/LTE_TRANSPORT/if5_tools.c
* \brief
* \author S. Sandeep Kumar, Raymond Knopp
* \author S. Sandeep Kumar, Raymond Knopp, Tien-Thinh Nguyen
* \date 2016
* \version 0.1
* \company Eurecom
* \email: ee13b1025@iith.ac.in, knopp@eurecom.fr
* \email: ee13b1025@iith.ac.in, knopp@eurecom.fr, tien-thinh.nguyen@eurecom.fr
* \note
* \warning
*/
......@@ -34,13 +34,21 @@
#include "targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
//#define DEBUG_DL_MOBIPASS
//#define DEBUG_UL_MOBIPASS
#define SUBFRAME_SKIP_NUM_MOBIPASS 8
int dummy_cnt = 0;
int subframe_skip_extra = 0;
int start_flag = 1;
int offset_cnt = 1;
void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe, uint8_t *seqno, uint16_t packet_type) {
LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
int32_t *txp[fp->nb_antennas_tx], *rxp[fp->nb_antennas_rx];
int32_t *tx_buffer=NULL;
int8_t dummy_buffer[fp->samples_per_tti*2];
uint16_t packet_id=0, i=0;
uint32_t spp_eth = (uint32_t) eNB->ifdevice.openair0_cfg->samples_per_packet;
......@@ -89,17 +97,18 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
}
} else if (packet_type == IF5_MOBIPASS) {
uint16_t db_fulllength=640;
uint16_t db_fulllength = PAYLOAD_MOBIPASS_NUM_SAMPLES;
__m128i *data_block=NULL, *data_block_head=NULL;
__m128i *txp128;
__m128i t0, t1;
tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t));
// tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t));
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t));
IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 4);
data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t);
header->flags = 0;
header->fifo_status = 0;
header->seqno = *seqno;
......@@ -110,14 +119,14 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
txp128 = (__m128i *) txp[0];
for (packet_id=0; packet_id<fp->samples_per_tti/db_fulllength; packet_id++) {
header->time_stamp = (uint32_t)(proc_timestamp + packet_id*db_fulllength);
header->time_stamp = htonl((uint32_t)(proc_timestamp + packet_id*db_fulllength));
data_block = data_block_head;
for (i=0; i<db_fulllength>>2; i+=2) {
t0 = _mm_srai_epi16(*txp128++, 4);
t1 = _mm_srai_epi16(*txp128++, 4);
*data_block++ = _mm_packs_epi16(t0, t1);
// *data_block++ = _mm_packs_epi16(t0, t1);
_mm_storeu_si128(data_block++, _mm_packs_epi16(t0, t1));
}
// Write the packet to the fronthaul
......@@ -129,18 +138,38 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
IF5_MOBIPASS)) < 0) {
perror("ETHERNET write for IF5_MOBIPASS\n");
}
#ifdef DEBUG_DL_MOBIPASS
if ((subframe==0)&&(dummy_cnt == 100)) {
memcpy((void*)&dummy_buffer[packet_id*db_fulllength*2],(void*)data_block_head,db_fulllength*2);
}
#endif
header->seqno += 1;
}
*seqno = header->seqno;
#ifdef DEBUG_DL_MOBIPASS
uint8_t txe;
txe = dB_fixed(signal_energy(txp[0],fp->samples_per_tti));
if (txe > 0){
LOG_D(PHY,"[Mobipass] frame:%d, subframe:%d, energy %d\n", (proc_timestamp/(10*fp->samples_per_tti))&1023,subframe, txe);