Commit 0789ee95 authored by Sandeep Kumar's avatar Sandeep Kumar

ifdevice tx/rx buffer per cc

parent a3c41ed7
......@@ -49,12 +49,12 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type,
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;
uint16_t symbol_id=0, element_id=0;
uint16_t db_fulllength, db_halflength;
int slotoffsetF=0, blockoffsetF=0;
void *tx_buffer=NULL;
uint16_t *data_block=NULL, *i=NULL;
if (packet_type == IF4_PDLFFT) {
......@@ -63,7 +63,6 @@ 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 - 1;
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + db_fulllength*sizeof(uint16_t));
IF4_header_t *dl_header = (IF4_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t);
......@@ -100,7 +99,6 @@ 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 - 1;
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + db_fulllength*sizeof(uint16_t));
IF4_header_t *ul_header = (IF4_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t);
......@@ -135,21 +133,15 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type,
// FIX: hard coded prach samples length
db_fulllength = 839*2;
tx_buffer = malloc(MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + db_fulllength*sizeof(int16_t));
IF4_header_t *prach_header = (IF4_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
data_block = (uint16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t);
gen_IF4_prach_header(prach_header, frame, subframe);
// 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;
//}
memcpy((int16_t*)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t),
(&rxsigF[0][0]+k),
db_fulllength*sizeof(int16_t));
if ((eNB->ifdevice.trx_write_func(&eNB->ifdevice,
symbol_id,
&tx_buffer,
......@@ -162,7 +154,6 @@ void send_IF4(PHY_VARS_eNB *eNB, int frame, int subframe, uint16_t packet_type,
AssertFatal(1==0, "send_IF4 - Unknown packet_type %x", packet_type);
}
free(tx_buffer);
return;
}
......@@ -172,6 +163,7 @@ void recv_IF4(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_typ
int32_t **txdataF = eNB->common_vars.txdataF[0];
int32_t **rxdataF = eNB->common_vars.rxdataF[0];
int16_t **rxsigF = eNB->prach_vars.rxsigF;
void *rx_buffer = eNB->ifbuffer.rx;
uint16_t element_id;
uint16_t db_fulllength, db_halflength;
......@@ -184,7 +176,6 @@ void recv_IF4(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_typ
}
db_halflength = db_fulllength>>1;
void *rx_buffer=NULL;
IF4_header_t *packet_header=NULL;
uint16_t *data_block=NULL, *i=NULL;
......@@ -238,14 +229,14 @@ void recv_IF4(PHY_VARS_eNB *eNB, int *frame, int *subframe, uint16_t *packet_typ
// 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));
memcpy((&rxsigF[0][0]),
(int16_t*) (rx_buffer+MAC_HEADER_SIZE_BYTES+sizeof_IF4_header_t),
db_fulllength*sizeof(int16_t));
} else {
AssertFatal(1==0, "recv_IF4 - Unknown packet_type %x", *packet_type);
}
free(rx_buffer);
return;
}
......@@ -260,7 +251,6 @@ void gen_IF4_dl_header(IF4_header_t *dl_packet, int frame, int subframe) {
dl_packet->frame_status = 0;
dl_packet->frame_status |= (frame&0xffff)<<6;
dl_packet->frame_status |= (subframe&0x000f)<<22;
}
......@@ -274,7 +264,6 @@ void gen_IF4_ul_header(IF4_header_t *ul_packet, int frame, int subframe) {
ul_packet->frame_status = 0;
ul_packet->frame_status |= (frame&0xffff)<<6;
ul_packet->frame_status |= (subframe&0x000f)<<22;
}
......@@ -288,5 +277,11 @@ void gen_IF4_prach_header(IF4_header_t *prach_packet, int frame, int subframe) {
prach_packet->frame_status = 0;
prach_packet->frame_status |= (frame&0xffff)<<6;
prach_packet->frame_status |= (subframe&0x000f)<<22;
}
void malloc_IF4_buffer(PHY_VARS_eNB *eNB) {
// Keep the size large enough
eNB->ifbuffer.tx = malloc(RAW_IF4_PRACH_SIZE_BYTES);
eNB->ifbuffer.rx = malloc(RAW_IF4_PRACH_SIZE_BYTES);
}
......@@ -70,3 +70,5 @@ void gen_IF4_prach_header(IF4_header_t*, int, int);
void send_IF4(PHY_VARS_eNB*, int, int, uint16_t, int);
void recv_IF4(PHY_VARS_eNB*, int*, int*, uint16_t*, uint32_t*);
void malloc_IF4_buffer(PHY_VARS_eNB*);
......@@ -514,7 +514,8 @@ typedef struct PHY_VARS_eNB_s {
/// RF and Interface devices per CC
openair0_device rfdevice;
openair0_device ifdevice;
// *** Handle spatially distributed MIMO antenna ports
/// Pointer for ifdevice buffer struct
if_buffer_t ifbuffer;
} PHY_VARS_eNB;
......
......@@ -2527,10 +2527,6 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl
uint16_t packet_type;
uint32_t symbol_number=0;
uint32_t symbol_mask, symbol_mask_full;
struct timespec time_req, time_rem;
time_req.tv_sec = 0;
time_req.tv_nsec = 900000;
if (subframe==9) {
subframe=0;
......@@ -2594,9 +2590,6 @@ void phy_procedures_eNB_common_RX(PHY_VARS_eNB *eNB,const uint8_t abstraction_fl
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 1 );
recv_IF5(eNB, &proc->timestamp_rx, proc->subframe_rx, IF5_RRH_GW_UL);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5, 0 );
//nanosleep(&time_req, &time_rem);
//proc->timestamp_rx += fp->samples_per_tti;
proc->frame_rx = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
......
......@@ -236,6 +236,14 @@ typedef struct {
} eth_params_t;
typedef struct {
//! Tx buffer for if device
void *tx;
//! Rx buffer for if device
void *rx;
} if_buffer_t;
/*!\brief structure holds the parameters to configure USRP devices */
struct openair0_device_t {
/*!brief Module ID of this device */
......
......@@ -312,13 +312,11 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
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_header_t;
void *test_buffer = (void*)malloc(packet_size);
IF4_header_t *test_header = (IF4_header_t*)(test_buffer + MAC_HEADER_SIZE_BYTES);
ssize_t packet_size = MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t;
IF4_header_t *test_header = (IF4_header_t*)(buff[0] + MAC_HEADER_SIZE_BYTES);
bytes_received = recv(eth->sockfd[Mod_id],
test_buffer,
buff[0],
packet_size,
MSG_PEEK);
if (bytes_received ==-1) {
......@@ -336,11 +334,7 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
} else {
packet_size = RAW_IF4_PRACH_SIZE_BYTES;
}
buff[0] = (void*)malloc(packet_size);
bytes_received = 0;
while(bytes_received < packet_size) {
bytes_received = recv(eth->sockfd[Mod_id],
buff[0],
......@@ -357,7 +351,6 @@ int trx_eth_read_raw_IF4(openair0_device *device, openair0_timestamp *timestamp,
}
eth->rx_nsamps = nsamps;
free(test_buffer);
return(bytes_received);
}
......@@ -394,7 +387,8 @@ int eth_set_dev_conf_raw(openair0_device *device) {
int eth_set_dev_conf_raw_IF4(openair0_device *device) {
int eth_set_dev_conf_raw_IF4(openair0_device *device) {
// use for cc_id info
int Mod_id = device->Mod_id;
eth_state_t *eth = (eth_state_t*)device->priv;
......@@ -455,6 +449,7 @@ int eth_get_dev_conf_raw(openair0_device *device) {
int eth_get_dev_conf_raw_IF4(openair0_device *device) {
// use for cc_id info
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
......
......@@ -768,6 +768,18 @@ static void* eNB_thread_rx_common( void* param ) {
wait_system_ready ("Waiting for eNB application to be ready %s\r", &start_eNB);
#endif
// Create buffer for IF device and free when stopping
if (eNB->node_function == NGFI_RCC_IF4 || eNB->node_function == NGFI_RRU_IF4) {
malloc_IF4_buffer(eNB);
} else if (eNB->node_function == NGFI_RRU_IF5 || eNB->node_function == eNodeB_3GPP_BBU) {
//malloc_IF5_buffer(eNB);
} else {
eNB->ifbuffer.tx = NULL;
eNB->ifbuffer.rx = NULL;
}
// Start IF device for this CC
if (eNB->node_function != eNodeB_3GPP) {
if (eNB->ifdevice.trx_start_func(&eNB->ifdevice) != 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