Commit 9f0a76e8 authored by Raymond Knopp's avatar Raymond Knopp

Merge branch 'enhancement-10-harmony' of...

Merge branch 'enhancement-10-harmony' of https://gitlab.eurecom.fr/oai/openairinterface5g into enhancement-10-harmony
parents 08d89933 8390977e
......@@ -48,15 +48,15 @@
// --- Careful to handle buffer memory --- RAW/UDP modes --- PRACH variables and data
void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type) {
void send_IF4(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 *prachF = eNB->prach_vars.prachF;
int16_t **rxsigF = eNB->prach_vars.rxsigF;
uint16_t symbol_id, element_id;
uint16_t symbol_id=0, element_id=0;
uint16_t db_fulllength, db_halflength;
int slotoffsetF, blockoffsetF;
int slotoffsetF=0, blockoffsetF=0;
void *tx_buffer=NULL;
int16_t *data_block=NULL;
......@@ -84,7 +84,8 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type)
}
// Update information in generated packet
dl_header->frame_status.sym_num = symbol_id;
dl_header->frame_status &= ~(0x000f<<26);
dl_header->frame_status |= (symbol_id&0x000f)<<26;
// Write the packet to the fronthaul
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
......@@ -105,7 +106,7 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type)
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength;
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_dl_header_t + db_fulllength*sizeof(int16_t));
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_ul_header_t + db_fulllength*sizeof(int16_t));
IF4_ul_header_t *ul_header = (IF4_ul_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4_ul_header_t);
......@@ -122,11 +123,12 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type)
}
// Update information in generated packet
ul_header->frame_status.sym_num = symbol_id;
ul_header->frame_status &= ~(0x000f<<26);
ul_header->frame_status |= (symbol_id&0x000f)<<26;
// Write the packet(s) to the fronthaul
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
(int64_t) symbol_id,
symbol_id,
&tx_buffer,
db_fulllength,
1,
......@@ -139,8 +141,7 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type)
}
} else if (packet_type == IF4_PRACH) {
// FIX: hard coded prach samples length
db_fulllength = 839;
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
db_fulllength = 839*2;
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_prach_header_t + db_fulllength*sizeof(int16_t));
IF4_prach_header_t *prach_header = (IF4_prach_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
......@@ -148,15 +149,18 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type)
gen_IF4_prach_header(prach_header, frame, subframe);
// Do compression and generate data blocks
for (element_id=0; element_id<db_fulllength; element_id++) {
data_block[element_id] = lin2alaw[ (prachF[blockoffsetF+element_id] & 0xffff) + 32768 ];
data_block[element_id] |= lin2alaw[ (prachF[blockoffsetF+element_id]>>16) + 32768 ]<<8;
}
// Generate uncompressed data blocks
memcpy(data_block, (rxsigF[0]+k), db_fulllength*sizeof(int16_t));
//for (element_id=0; element_id<db_fulllength; element_id++) {
// data_block[element_id] = rxsigF[0][prachoffsetF];
// data_block[element_id] |= rxsigF[0][prachoffsetF+1]<<16;
// prachoffsetF += 2;
//}
// Write the packet to the fronthaul
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
(int64_t) symbol_id,
symbol_id,
&tx_buffer,
db_fulllength,
1,
......@@ -176,36 +180,38 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
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 *prachF = eNB->prach_vars.prachF;
int16_t **rxsigF = eNB->prach_vars.rxsigF;
uint16_t element_id;
uint16_t db_fulllength, db_halflength;
int slotoffsetF, blockoffsetF;
*packet_type = 0;
int slotoffsetF=0, blockoffsetF=0;
if (eNB->node_function == NGFI_RRU_IF4) {
db_fulllength = (12*fp->N_RB_DL);
} else {
db_fulllength = (12*fp->N_RB_UL);
}
db_halflength = db_fulllength>>1;
int64_t *ret_type=(int64_t*)malloc(sizeof(int64_t));
void *rx_buffer=NULL;
void **buff=NULL;
int16_t *data_block=NULL;
// Read packet(s) from the fronthaul
if (eNB->ifdevice.trx_read_func(&eNB->ifdevice,
ret_type,
buff,
0,
&rx_buffer,
db_fulllength,
0) < 0) {
perror("ETHERNET read");
}
*packet_type = *ret_type;
rx_buffer = buff[0];
*packet_type = (uint16_t) *ret_type;
if (*packet_type == IF4_PDLFFT) {
data_block = (int16_t*) (rx_buffer+sizeof_IF4_dl_header_t);
db_halflength = (12*fp->N_RB_DL)>>1;
// Calculate from received packet
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength;
......@@ -220,13 +226,11 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
}
// Find and return symbol_number
*symbol_number = ((IF4_dl_header_t*)(rx_buffer))->frame_status.sym_num;
*symbol_number = ((((IF4_dl_header_t*)(rx_buffer))->frame_status)>>26)&0x000f;
} else if (*packet_type == IF4_PULFFT) {
data_block = (int16_t*) (rx_buffer+sizeof_IF4_ul_header_t);
db_halflength = (12*fp->N_RB_UL)>>1;
// Calculate from received packet
slotoffsetF = (subframe)*(fp->ofdm_symbol_size)*((fp->Ncp==1) ? 12 : 14) + 1;
blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength;
......@@ -241,12 +245,16 @@ void recv_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t *packet_type,
}
// Find and return symbol_number
*symbol_number = ((IF4_ul_header_t*)(rx_buffer))->frame_status.sym_num;
*symbol_number = ((((IF4_ul_header_t*)(rx_buffer))->frame_status)>>26)&0x000f;
} else if (*packet_type == IF4_PRACH) {
data_block = (int16_t*) (rx_buffer+sizeof_IF4_prach_header_t);
db_fulllength = 839; // hard coded
// FIX: hard coded prach samples length
db_fulllength = 839*2;
// Generate uncompressed data blocks
memcpy((rxsigF[0]+slotoffsetF), data_block, db_fulllength*sizeof(int16_t));
} else {
AssertFatal(1==0, "recv_IF4 - Unknown packet_type %x", *packet_type);
......@@ -262,18 +270,13 @@ void gen_IF4_dl_header(IF4_dl_header_t *dl_packet, int frame, int subframe) {
dl_packet->type = IF4_PACKET_TYPE;
dl_packet->sub_type = IF4_PDLFFT;
// Leave reserved as it is
// Reset frame status
dl_packet->rsvd = 0;
// Set frame status
dl_packet->frame_status.ant_num = 0;
dl_packet->frame_status.ant_start = 0;
dl_packet->frame_status.rf_num = frame;
dl_packet->frame_status.sf_num = subframe;
dl_packet->frame_status.sym_num = 0;
dl_packet->frame_status.rsvd = 0;
// Set frame check sequence
dl_packet->frame_status = 0;
dl_packet->frame_status |= (frame&0xffff)<<6;
dl_packet->frame_status |= (subframe&0x000f)<<22;
}
......@@ -287,19 +290,20 @@ void gen_IF4_ul_header(IF4_ul_header_t *ul_packet, int frame, int subframe) {
ul_packet->rsvd = 0;
// Set frame status
ul_packet->frame_status.ant_num = 0;
ul_packet->frame_status.ant_start = 0;
ul_packet->frame_status.rf_num = frame;
ul_packet->frame_status.sf_num = subframe;
ul_packet->frame_status.sym_num = 0;
ul_packet->frame_status.rsvd = 0;
ul_packet->frame_status = 0;
ul_packet->frame_status |= (frame&0xffff)<<6;
ul_packet->frame_status |= (subframe&0x000f)<<22;
// Set antenna specific gain *** set other antenna gain ***
ul_packet->gain0.exponent = 0;
ul_packet->gain0.rsvd = 0;
// Set frame check sequence
ul_packet->gain0 = 0;
ul_packet->gain1 = 0;
ul_packet->gain2 = 0;
ul_packet->gain3 = 0;
ul_packet->gain4 = 0;
ul_packet->gain5 = 0;
ul_packet->gain6 = 0;
ul_packet->gain7 = 0;
}
......@@ -312,12 +316,8 @@ void gen_IF4_prach_header(IF4_prach_header_t *prach_packet, int frame, int subfr
prach_packet->rsvd = 0;
// Set LTE Prach configuration
prach_packet->prach_conf.rsvd = 0;
prach_packet->prach_conf.ant = 0;
prach_packet->prach_conf.rf_num = frame;
prach_packet->prach_conf.sf_num = subframe;
prach_packet->prach_conf.exponent = 0;
prach_packet->prach_conf = 0;
prach_packet->prach_conf |= (frame&0xffff)<<6;
prach_packet->prach_conf |= (subframe&0x000f)<<22;
// Set frame check sequence
}
......@@ -47,6 +47,10 @@
#define IF4_PDLFFT 0x0020
#define IF4_PRACH 0x0021
/*
Bit-field reference
/// IF4 Frame Status (32 bits)
struct IF4_frame_status {
/// Antenna Numbers
......@@ -63,9 +67,6 @@ struct IF4_frame_status {
uint32_t rsvd:2;
};
typedef struct IF4_frame_status IF4_frame_status_t;
#define sizeof_IF4_frame_status_t 4
/// IF4 Antenna Gain (16 bits)
struct IF4_gain {
/// Reserved
......@@ -74,9 +75,6 @@ struct IF4_gain {
uint16_t exponent:6;
};
typedef struct IF4_gain IF4_gain_t;
#define sizeof_IF_gain_t 2
/// IF4 LTE PRACH Configuration (32 bits)
struct IF4_lte_prach_conf {
/// Reserved
......@@ -91,8 +89,7 @@ struct IF4_lte_prach_conf {
uint32_t exponent:6;
};
typedef struct IF4_lte_prach_conf IF4_lte_prach_conf_t;
#define sizeof_IF4_lte_prach_conf_t 4
*/
struct IF4_dl_header {
/// Destination Address
......@@ -106,7 +103,7 @@ struct IF4_dl_header {
/// Reserved
uint32_t rsvd;
/// Frame Status
IF4_frame_status_t frame_status;
uint32_t frame_status;
/// Data Blocks
/// Frame Check Sequence
......@@ -128,23 +125,23 @@ struct IF4_ul_header {
/// Reserved
uint32_t rsvd;
/// Frame Status
IF4_frame_status_t frame_status;
uint32_t frame_status;
/// Gain 0
IF4_gain_t gain0;
uint16_t gain0;
/// Gain 1
IF4_gain_t gain1;
uint16_t gain1;
/// Gain 2
IF4_gain_t gain2;
uint16_t gain2;
/// Gain 3
IF4_gain_t gain3;
uint16_t gain3;
/// Gain 4
IF4_gain_t gain4;
uint16_t gain4;
/// Gain 5
IF4_gain_t gain5;
uint16_t gain5;
/// Gain 6
IF4_gain_t gain6;
uint16_t gain6;
/// Gain 7
IF4_gain_t gain7;
uint16_t gain7;
/// Data Blocks
/// Frame Check Sequence
......@@ -166,7 +163,7 @@ struct IF4_prach_header {
/// Reserved
uint32_t rsvd;
/// LTE Prach Configuration
IF4_lte_prach_conf_t prach_conf;
uint32_t prach_conf;
/// Prach Data Block (one antenna)
/// Frame Check Sequence
......@@ -182,6 +179,6 @@ void gen_IF4_ul_header(IF4_ul_header_t*, int, int);
void gen_IF4_prach_header(IF4_prach_header_t*, int, int);
void send_IF4(PHY_VARS_eNB*, int, int, uint16_t);
void send_IF4(PHY_VARS_eNB*, int, int, uint16_t, int);
void recv_IF4(PHY_VARS_eNB*, int, int, uint16_t*, uint32_t*);
......@@ -41,6 +41,7 @@
#include "PHY/defs.h"
#include "PHY/extern.h"
//#include "prach.h"
#include "PHY/LTE_TRANSPORT/if4_tools.h"
#include "SCHED/defs.h"
#include "SCHED/extern.h"
#include "UTIL/LOG/vcd_signal_dumper.h"
......@@ -1269,18 +1270,25 @@ void rx_prach(PHY_VARS_eNB *eNB,
}
if (eNB->node_function == NGFI_RRU_IF4) {
/// **** send_IF4 of prachF to RCC **** ///
k = (12*n_ra_prb) - 6*eNB->frame_parms.N_RB_UL;
if (k<0) {
k+=(eNB->frame_parms.ofdm_symbol_size);
}
k*=12;
k+=13;
k*=2;
/// **** send_IF4 of rxsigF to RCC **** ///
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
//send_IF4(eNB, frame, subframe, IF4_PRACH);
send_IF4(eNB, eNB->proc.frame_rx, eNB->proc.subframe_rx, IF4_PRACH, k);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );
return;
}
// in case of RCC and prach received rx_thread wakes up prach
//else if (eNB->node_function == NGFI_RCC_IF4) {
// wait for prachF from RRU and continue with PRACH processing
//}
// here onwards is for eNodeB_3GPP or NGFI_RCC_IF4
......
......@@ -2610,9 +2610,8 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl
if (eNB->node_function == NGFI_RRU_IF4 && is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)<=0) {
/// **** send_IF4 of rxdataF to RCC (no prach now) **** ///
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
//send_IF4(eNB, frame, subframe, IF4_PULFFT);
send_IF4(eNB, frame, subframe, IF4_PULFFT, 0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );
}
......
......@@ -303,14 +303,15 @@ int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, voi
int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc) {
// Read nblocks info from packet itself
int nblocks = nsamps;
int bytes_received=0;
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4_dl_header_t;
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4_dl_header_t;
void *test_buffer = (void*)malloc(packet_size);
void *rx_buffer=NULL;
IF4_dl_header_t *test_header = (IF4_dl_header_t*)(test_buffer + MAC_HEADER_SIZE_BYTES);
......@@ -339,7 +340,7 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
packet_size = RAW_IF4_PRACH_SIZE_BYTES - packet_size;
}
memcpy(buff[0], test_header, sizeof_IF4_dl_header_t);
memcpy(buff[0], test_header, sizeof_IF4_dl_header_t);
rx_buffer = (void*)(buff[0]+sizeof_IF4_dl_header_t);
bytes_received = 0;
......
......@@ -56,7 +56,7 @@
// Packet sizes for IF4 interface format
#define DATA_BLOCK_SIZE_BYTES(scaled_nblocks) (sizeof(int16_t)*scaled_nblocks)
#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*839) // FIX hard coded prach size
#define PRACH_BLOCK_SIZE_BYTES (sizeof(int16_t)*839*2) // FIX hard coded prach size (uncompressed)
#define RAW_IF4_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_dl_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
#define RAW_IF4_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_ul_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))
......
......@@ -654,8 +654,8 @@ extern "C" {
}
/* device specific */
openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
//openair0_cfg[0].txlaunch_wait = 1;//manage when TX processing is triggered
//openair0_cfg[0].txlaunch_wait_slotcount = 1; //manage when TX processing is triggered
openair0_cfg[0].iq_txshift = 4;//shift
openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
......
......@@ -487,10 +487,9 @@ static void* eNB_thread_rxtx( void* param ) {
}
} else {
/// **** recv_IF4 of txdataF from RCC **** ///
/// **** recv_IF4 of txdataF from RCC **** ///
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 1 );
//recv_IF4(eNB, frame, subframe, packet_type, symbol_number);
//recv_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc->frame_tx, proc->subframe_tx, packet_type, symbol_number);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4, 0 );
}
......@@ -537,10 +536,9 @@ static void* eNB_thread_rxtx( void* param ) {
} else {
/// **** send_IF4 of txdataF to RRU **** ///
/// **** send_IF4 of txdataF to RRU **** ///
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 );
send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc->frame_tx, proc->subframe_tx, IF4_PDLFFT);
send_IF4(PHY_vars_eNB_g[0][proc->CC_id], proc->frame_tx, proc->subframe_tx, IF4_PDLFFT, 0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 0 );
}
......
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