Commit 23fd8953 authored by navid's avatar navid

* add device to rrh gateway (only usrp for now)

* update the device common interface for eNB/UE (common_lib.h)


git-svn-id: http://svn.eurecom.fr/openair4G/trunk@7724 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 60e45e47
......@@ -132,7 +132,37 @@ int trx_brf_end(openair0_device *device) {
return 0;
}
//int openair0_dev_init_bladerf(openair0_device *device, openair0_config_t *openair0_cfg) {
int trx_brf_get_stats(openair0_device* device) {
return(0);
}
int trx_brf_reset_stats(openair0_device* device) {
return(0);
}
int trx_brf_stop(openair0_device* device) {
return(0);
}
int trx_brf_set_freq(openair0_device* device) {
return(0);
}
int trx_brf_set_gains(openair0_device* device) {
return(0);
}
int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
int status;
......@@ -141,10 +171,12 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf
brf_state_t *brf = (brf_state_t*)malloc(sizeof(brf_state_t));
memset(brf, 0, sizeof(brf_state_t));
// init required params for BRF
brf->num_buffers = 128;
brf->buffer_size = (unsigned int)openair0_cfg[card].samples_per_packet*sizeof(int32_t); // buffer size = 4096 for sample_len of 1024
brf->num_transfers = 16;
brf->timeout_ms = 0;
//brf->dev_model = ;
brf->num_buffers = 128;
brf->buffer_size = (unsigned int)openair0_cfg[card].samples_per_packet*sizeof(int32_t); // buffer size = 4096 for sample_len of 1024
brf->num_transfers = 16;
brf->timeout_ms = 0;
brf->sample_rate=(unsigned int)openair0_cfg[card].sample_rate;
printf("\n[BRF] sampling_rate %d, num_buffers %d, buffer_size %d, num transfer %d, timeout_ms %d\n",
......@@ -258,6 +290,11 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf
device->trx_end_func = trx_brf_end;
device->trx_read_func = trx_brf_read;
device->trx_write_func = trx_brf_write;
device->trx_get_stats_func = trx_brf_get_stats;
device->trx_reset_stats_func = trx_brf_reset_stats;
device->trx_stop_func = trx_brf_stop;
device->trx_set_freq_func = trx_brf_set_freq;
device->trx_set_gains_func = trx_brf_set_gains;
memcpy((void*)&device->openair0_cfg,(void*)openair0_cfg,sizeof(openair0_config_t));
return 0;
......@@ -269,26 +306,7 @@ int brf_error(int status) {
//return 1; // or status error code
}
int openair0_stop(int card) {
return(0);
}
int openair0_print_stats(openair0_device* device) {
return(0);
}
int openair0_reset_stats(openair0_device* device) {
return(0);
}
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int dummy) {
return 0;
}
int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *openair0_cfg) {
return 0;
}
......
......@@ -40,9 +40,12 @@
#ifndef COMMON_LIB_H
#define COMMON_LIB_H
#include <stdint.h>
#include <sys/types.h>
typedef int64_t openair0_timestamp;
typedef volatile int64_t openair0_vtimestamp;
typedef struct openair0_device_t openair0_device;
/* structrue holds the parameters to configure USRP devices
*/
......@@ -78,7 +81,7 @@ typedef struct {
//! number of samples per RX/TX packet (USRP + Ethernet)
int samples_per_packet;
// delay in sending samples (write) due to hardware access, softmodem processing and fronthaul delay if exist
int tx_delay;
int tx_delay;
//! adjust the position of the samples after delay when sending
unsigned int tx_forward_nsamps;
//! number of RX channels (=RX antennas)
......@@ -144,10 +147,13 @@ typedef enum {
} dev_type_t;
/*!\brief type */
typedef enum {
MIN_FUNC_TYPE = 0,
/*!\brief device functions within a BBU */
BBU_FUNC,
/*!\brief device functions within a RRH */
RRH_FUNC,
MAX_FUNC_TYPE
......@@ -156,13 +162,13 @@ typedef enum {
struct openair0_device_t {
/* Module ID of this device */
int Mod_id;
/* Type of this device */
func_type_t func_type;
/* Type of this device */
dev_type_t type;
/* Type of the device's host (BBU/RRH) */
func_type_t func_type;
/* RF frontend parameters set by application */
openair0_config_t openair0_cfg;
......@@ -174,14 +180,11 @@ struct openair0_device_t {
/* Called to start the transceiver. Return 0 if OK, < 0 if error */
int (*trx_start_func)(openair0_device *device);
/* Called to initiate transceiver threads */
void (*trx_thread_func)(openair0_device *device, unsigned int rt_period, uint8_t RT_flag,uint8_t NRT_flag);
/* Called to request connection from the transceiver/RRH. Return 0 if OK, < 0 if error */
int (*trx_request_func)(openair0_device *device);
/* Called to send a request message between BBU-RRH */
int (*trx_request_func)(openair0_device *device, void *msg, ssize_t msg_len);
/* Called to reply back to connection state to eNB/BBU. Return 0 if OK, < 0 if error */
int (*trx_reply_func)(openair0_device *openair0);
/* Called to send a reply message between BBU-RRH */
int (*trx_reply_func)(openair0_device *openair0, void *msg, ssize_t msg_len);
/* Write 'nsamps' samples on each channel from buffers. buff[0] is the array for
* the first channel. timestamp if the time (in samples) at which the first sample
......@@ -216,6 +219,23 @@ struct openair0_device_t {
/* Terminate operation of the transceiver -- free all associated resources */
void (*trx_end_func)(openair0_device *device);
/* Terminate operation */
int (*trx_stop_func)(int card);
/* Functions API related to UE*/
/*! \brief Set RX feaquencies
* \param
* \returns 0 in success
*/
int (*trx_set_freq_func)(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
/*! \brief Set gains
* \param
* \returns 0 in success
*/
int (*trx_set_gains_func)(openair0_device* device, openair0_config_t *openair0_cfg);
};
......@@ -225,31 +245,19 @@ extern "C"
#endif
/* return 0 if OK */
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg);
openair0_timestamp get_usrp_time(openair0_device *device);
//EXMIMO
//int openair0_dev_init_exmimo(openair0_device *device, openair0_config_t *openair0_cfg);
//USPRP
//int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_cfg);
//BLADERF
//int openair0_dev_init_bladerf(openair0_device* device, openair0_config_t *openair0_cfg);
//int openair0_stop(int card);
//ETHERNET
int openair0_dev_init_eth(openair0_device *device, openair0_config_t *openair0_cfg);
//int openair0_stop_eth(int card);
//int openair0_set_gains_eth(openair0_device* device, openair0_config_t *openair0_cfg);
//int openair0_set_frequencies_eth(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config);
//USPRP
openair0_timestamp get_usrp_time(openair0_device *device);
int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *openair0_cfg);
int openair0_set_gains(openair0_device* device, openair0_config_t *openair0_cfg);
int openair0_print_stats(openair0_device* device);
int openair0_reset_stats(openair0_device* device);
int openair0_stop(int card);
#ifdef __cplusplus
}
......
......@@ -52,12 +52,8 @@
#include "common_lib.h"
#include "ethernet_lib.h"
#define DEFAULT_IF "eth0"
#define BUF_SIZ 8960 /*Jumbo frame size*/
#define MAX_INST 4
//int sockfd[MAX_INST];
int num_devices = 0;
int num_devices_eth = 0;
int dest_addr_len[MAX_INST];
char sendbuf[MAX_INST][BUF_SIZ]; /*TODO*/
......@@ -69,7 +65,7 @@ int ethernet_socket_init(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
// struct sockaddr_in *dest = &dest_addr[Mod_id];
// struct sockaddr_in *dest = &dest_addr[Mod_id];
char str[INET_ADDRSTRLEN];
const char *dest_ip;
int dest_port;
......@@ -156,7 +152,7 @@ void ethernet_socket_opt (openair0_device *device){
}
int trx_eth_request(openair0_device *device) {
int trx_eth_set_dev_conf(openair0_device *device) {
int Mod_id = device->Mod_id;
eth_state_t *eth = (eth_state_t*)device->priv;
......@@ -191,7 +187,7 @@ int trx_eth_request(openair0_device *device) {
int trx_eth_reply(openair0_device *device) {
int trx_eth_get_dev_conf(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
......@@ -218,9 +214,44 @@ int trx_eth_reply(openair0_device *device) {
device->openair0_cfg.remote_port =ntohs(eth->dest_addr[Mod_id].sin_port);
device->openair0_cfg.remote_ip=str;
//ethernet_socket_opt (device);
printf("[RRH] write mod_%d %d to %s:%d\n",Mod_id,eth->sockfd[Mod_id],str,ntohs(eth->dest_addr[Mod_id].sin_port));
// printf("[RRH] write mod_%d %d to %s:%d\n",Mod_id,eth->sockfd[Mod_id],str,ntohs(eth->dest_addr[Mod_id].sin_port));
return 1;
return 0;
}
int trx_eth_request(openair0_device *device, void *msg, ssize_t msg_len) {
int Mod_id = device->Mod_id;
eth_state_t *eth = (eth_state_t*)device->priv;
if (sendto(eth->sockfd[Mod_id],msg,msg_len,0,(struct sockaddr *)&eth->dest_addr[Mod_id],dest_addr_len[Mod_id])==-1){
perror("ETHERNET: ");
exit(0);
}
return 0;
}
int trx_eth_reply(openair0_device *device, void *msg, ssize_t msg_len) {
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
/* receive from client (lte-softmodem) */
if (recvfrom(eth->sockfd[Mod_id],
msg,
msg_len,
0,
(struct sockaddr *)&eth->dest_addr[Mod_id],
(socklen_t *)&dest_addr_len[Mod_id])==-1){
perror("ETHERNET: ");
exit(0);
}
return 0;
}
......@@ -240,17 +271,14 @@ int ethernet_write_data(openair0_device *device, openair0_timestamp timestamp, v
/* we don't want to ovewrite with the header info the previous tx buffer data so we store it*/
int32_t temp0 = *(int32_t *)buff2;
openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + sizeof(int32_t));
//printf("temp0=%d temp=%d\n",temp0,temp1);
//char str[INET_ADDRSTRLEN];
n_written = 0;
*(int16_t *)(buff2 + sizeof(int16_t))=1+(antenna_id<<1);
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = timestamp;
//inet_ntop(AF_INET, &(eth->dest_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN);
//printf("[RRH]write mod_%d %d to %s:%d, len %d, buff %p antenna %d\n",
//Mod_id,eth->sockfd[Mod_id],str,ntohs(eth->dest_addr[Mod_id].sin_port),(nsamps<<2)+header_size, buff2, antenna_id);
/* printf("[RRH]write mod_%d %d , len %d, buff %p antenna %d\n",
Mod_id,eth->sockfd[Mod_id],(nsamps<<2)+header_size, buff2, antenna_id);*/
while(n_written < nsamps) {
/* Send packet */
......@@ -273,7 +301,6 @@ while(n_written < nsamps) {
/* tx buffer values restored */
*(int32_t *)buff2 = temp0;
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1;
//printf("-----------------temp0=%d temp=%d\n",*(int32_t *)buff2,*(openair0_timestamp *)(buff2 + sizeof(int32_t)));
return n_written;
}
......@@ -284,7 +311,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
int bytes_received;
int block_cnt;
int ret;
char str[INET_ADDRSTRLEN];
uint16_t header_size=sizeof(int32_t) + sizeof(openair0_timestamp);
......@@ -299,15 +325,13 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
inet_ntop(AF_INET, &(eth->dest_addr[Mod_id].sin_addr), str, INET_ADDRSTRLEN);
// send command RX for nsamps samples
// printf("requesting %d samples from (%s:%d)\n",nsamps,str,ntohs(eth->dest_addr[Mod_id].sin_port));
bytes_received=0;
block_cnt=0;
/* printf("[RRH] read mod_%d %d,len %d, buff %p antenna %d\n",
Mod_id,eth->sockfd[Mod_id],(nsamps<<2)+header_size, buff2, antenna_id);*/
while(bytes_received < (int)((nsamps<<2))) {
//printf("requesting %d bytes\n",(nsamps<<2));
ret=recvfrom(eth->sockfd[Mod_id],
buff2+bytes_received,
(nsamps<<2)+header_size-bytes_received,
......@@ -315,7 +339,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
(struct sockaddr *)&eth->dest_addr[Mod_id],
(socklen_t *)&dest_addr_len[Mod_id]);
//printf("bytes_received %d (ret %d)\n",bytes_received+ret,ret);
if (ret==-1) {
if (errno == EAGAIN) {
perror("ETHERNET READ: ");
......@@ -349,8 +372,18 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
}
int trx_eth_start(openair0_device *device){
return ethernet_socket_init(device);
if (ethernet_socket_init(device)!=0) {
return -1;
}
if (device->func_type == BBU_FUNC ) {
return trx_eth_set_dev_conf(device);
}
else{
return trx_eth_get_dev_conf(device);
}
return(0);
}
int trx_eth_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int antenna_id, int flags) {
......@@ -364,26 +397,45 @@ int trx_eth_read(openair0_device *device, openair0_timestamp *ptimestamp, void *
}
int openair0_stop(int card) {
int trx_eth_stop(int card) {
return(0);
}
int trx_eth_set_freq(openair0_device* device, openair0_config_t *openair0_cfg,int exmimo_dump_config) {
return(0);
}
int trx_eth_set_gains(openair0_device* device, openair0_config_t *openair0_cfg) {
return(0);
}
int openair0_print_stats(openair0_device* device) {
int trx_eth_get_stats(openair0_device* device) {
return(0);
}
int openair0_reset_stats(openair0_device* device) {
int trx_eth_reset_stats(openair0_device* device) {
return(0);
}
void trx_eth_end(openair0_device *device) {
// close all the sockets
eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id;
/*destroys socket only for the processes that call the eth_end fuction-- shutdown() for beaking the pipe */
if ( close(eth->sockfd[Mod_id]) <0 ) {
perror("ETHERNET: Failed to close socket");
exit(0);
}else {
printf("[RRH] socket for mod_id %d has been successfully closed.",Mod_id);
}
}
......@@ -392,24 +444,24 @@ int openair0_dev_init_eth(openair0_device *device, openair0_config_t *openair0_c
eth_state_t *eth = (eth_state_t*)malloc(sizeof(eth_state_t));
int card = 0;
memset(eth, 0, sizeof(eth_state_t));
eth->buffer_size = (unsigned int)openair0_cfg[card].samples_per_packet*sizeof(int32_t); // buffer size = 4096 for sample_len of 1024
eth->buffer_size = (unsigned int)openair0_cfg[card].samples_per_packet*sizeof(int32_t); // buffer size = 4096 for sample_len of 1024
eth->sample_rate = (unsigned int)openair0_cfg[card].sample_rate;
device->priv = eth;
printf("ETHERNET: Initializing openair0_device for %s ...\n", ((device->func_type == BBU_FUNC) ? "BBU": "RRH"));
device->Mod_id = num_devices++;
device->Mod_id = num_devices_eth++;
device->trx_start_func = trx_eth_start;
device->trx_request_func = trx_eth_request;
device->trx_reply_func = trx_eth_reply;
device->trx_end_func = trx_eth_end;
device->trx_read_func = trx_eth_read;
device->trx_write_func = trx_eth_write;
device->trx_read_func = trx_eth_read;
device->trx_get_stats_func = trx_eth_get_stats;
device->trx_reset_stats_func = trx_eth_reset_stats;
device->trx_end_func = trx_eth_end;
device->trx_stop_func = trx_eth_stop;
device->trx_set_freq_func = trx_eth_set_freq;
device->trx_set_gains_func = trx_eth_set_gains;
memcpy((void*)&device->openair0_cfg,(void*)openair0_cfg,sizeof(openair0_config_t));
/* if (ethernet_socket_init(device)!=0){
return -1;
}*/
return 0;
}
......@@ -47,6 +47,9 @@
#include <net/if.h>
#include <netinet/ether.h>
#define MAX_INST 4
#define DEFAULT_IF "eth0"
#define BUF_SIZ 8960 /*Jumbo frame size*/
typedef struct {
......@@ -54,9 +57,8 @@ typedef struct {
//struct eth_if *dev;
// An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
int sockfd[4];
struct sockaddr_in dest_addr[4];
int sockfd[MAX_INST];
struct sockaddr_in dest_addr[MAX_INST];
unsigned int buffer_size;
unsigned int timeout_ns;
......@@ -102,12 +104,12 @@ struct eth_meta_data{
typedef struct {
/* packet's timestamp */
/* packet's timestamp */
openair0_timestamp timestamp;
/* variable declared for alignment purposes (sample size=32 bit) */
int16_t not_used;
int16_t not_used;
/* antenna port used to resynchronize*/
int16_t antenna_id;
int16_t antenna_id;
} header_t;
......
......@@ -247,7 +247,6 @@ int openair0_stop_without_reset(int card)
#define MY_RF_MODE (RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX)
#define RF_MODE_BASE (LNA1ON + RFBBNORM)
//int openair0_dev_init_exmimo(openair0_device *device, openair0_config_t *openair0_cfg) {
int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// Initialize card
......@@ -483,6 +482,10 @@ int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair
}
int openair0_set_gains(openair0_device* device, openair0_config_t *openair0_cfg){
return(0);
}
unsigned int *openair0_daq_cnt(void) {
return((unsigned int *)openair0_exmimo_pci[0].rxcnt_ptr[0]);
......
......@@ -56,7 +56,7 @@ typedef struct
// --------------------------------
uhd::usrp::multi_usrp::sptr usrp;
//uhd::usrp::multi_usrp::sptr rx_usrp;
//create a send streamer and a receive streamer
uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream;
......@@ -123,6 +123,7 @@ static void trx_usrp_end(openair0_device *device)
s->tx_stream->send("", 0, s->tx_md);
s->tx_md.end_of_burst = false;
}
static int trx_usrp_write(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps, int cc, int flags)
{
usrp_state_t *s = (usrp_state_t*)device->priv;
......@@ -199,7 +200,7 @@ static bool is_equal(double a, double b)
return std::fabs(a-b) < std::numeric_limits<double>::epsilon();
}
int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair0_cfg, int dummy) {
int trx_usrp_set_freq(openair0_device* device, openair0_config_t *openair0_cfg, int dummy) {
usrp_state_t *s = (usrp_state_t*)device->priv;
......@@ -227,7 +228,7 @@ int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *open
}
int openair0_set_gains(openair0_device* device,
int trx_usrp_set_gains(openair0_device* device,
openair0_config_t *openair0_cfg) {
usrp_state_t *s = (usrp_state_t*)device->priv;
......@@ -247,11 +248,11 @@ int openair0_set_gains(openair0_device* device,
return(0);
}
int openair0_stop(int card) {
int trx_usrp_stop(int card) {
return(0);
}
rx_gain_calib_table_t calib_table[] = {
{3500000000.0,46.0},
{2660000000.0,53.0},
......@@ -279,17 +280,18 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) {
}
int openair0_print_stats(openair0_device* device) {
int trx_usrp_get_stats(openair0_device* device) {
return(0);
}
int openair0_reset_stats(openair0_device* device) {
int trx_usrp_reset_stats(openair0_device* device) {
return(0);
}
//int openair0_dev_init_usrp(openair0_device* device, openair0_config_t *openair0_cfg)
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg)
{
......@@ -438,9 +440,14 @@ int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cf
device->priv = s;
device->trx_start_func = trx_usrp_start;
device->trx_end_func = trx_usrp_end;
device->trx_read_func = trx_usrp_read;
device->trx_write_func = trx_usrp_write;
device->trx_read_func = trx_usrp_read;
device->trx_get_stats_func = trx_usrp_get_stats;
device->trx_reset_stats_func = trx_usrp_reset_stats;
device->trx_end_func = trx_usrp_end;
device->trx_stop_func = trx_usrp_stop;
device->trx_set_freq_func = trx_usrp_set_freq;
device->trx_set_gains_func = trx_usrp_set_gains;
s->sample_rate = openair0_cfg[0].sample_rate;
// TODO:
......
......@@ -273,7 +273,7 @@ void *rrh_UE_thread(void *arg) {
while (rrh_exit==0) {
cmd=dev->eth_dev.trx_reply_func(&dev->eth_dev);
cmd=dev->eth_dev.trx_start_func(&dev->eth_dev);
/* allocate memory for TX/RX buffers */
rx_buffer_UE = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*));
......
......@@ -51,8 +51,6 @@
#include "rrh_gw_externs.h"
#include "rt_wrapper.h"
#define RRH_eNB_PORT 50000
#define RRH_eNB_DEST_IP "192.168.12.31"
#define PRINTF_PERIOD 3750
#define HEADER_SIZE ((sizeof(int32_t) + sizeof(openair0_timestamp))>>2)
//#undef LOWLATENCY
......@@ -64,29 +62,30 @@ void *rrh_eNB_tx_thread(void *);
void *rrh_proc_eNB_thread(void *);
void *rrh_eNB_thread(void *);
void set_rt_period( openair0_config_t openair0_cfg);
void print_dev_config(openair0_device device);
void check_dev_config( rrh_module_t *mod_enb);
openair0_timestamp timestamp_eNB_tx[4]= {0,0,0,0},timestamp_eNB_rx[4]= {0,0,0,0};
openair0_timestamp nrt_eNB_counter[4]= {0,0,0,0};
pthread_t main_rrh_eNB_thread;
pthread_attr_t attr, attr_proc;
struct sched_param sched_param_rrh;
pthread_cond_t sync_eNB_cond[4];
pthread_mutex_t sync_eNB_mutex[4];
pthread_cond_t sync_eNB_cond[4];
pthread_mutex_t sync_eNB_mutex[4];
openair0_timestamp nrt_eNB_counter[4]= {0,0,0,0};
int32_t overflow_rx_buffer_eNB[4]= {0,0,0,0};
int32_t nsamps_eNB[4]= {0,0,0,0};
int32_t eNB_tx_started=0,eNB_rx_started=0;
int32_t counter_eNB_rx[4]= {0,0,0,0};
int32_t counter_eNB_tx[4]= {0,0,0,0};
uint8_t RT_flag_eNB,NRT_flag_eNB;
int32_t **tx_buffer_eNB, **rx_buffer_eNB;
void *rrh_eNB_thread_status;
void *rx_eNB[2]; //to be fixed
void *tx_eNB[2]; //to be fixed
int sync_eNB_rx[4]= {-1,-1,-1,-1};
void **rx_eNB; //was fixed to 2 ant
void **tx_eNB; //was fixed to 2 ant
int sync_eNB_rx[4]= {-1,-1,-1,-1};
openair0_timestamp timestamp_eNB_tx[4]= {0,0,0,0},timestamp_eNB_rx[4]= {0,0,0,0};
unsigned int rx_pos=0, next_rx_pos=0;
unsigned int tx_pos=0, prev_tx_pos=0;
......@@ -100,30 +99,117 @@ unsigned int tx_pos=0, prev_tx_pos=0;
* \note
* @ingroup _oai
*/
void create_eNB_trx_threads( rrh_module_t *dev_enb, uint8_t RT_flag, uint8_t NRT_flag){
void create_eNB_trx_threads( rrh_module_t *mod_enb, uint8_t RT_flag, uint8_t NRT_flag){
//int i;
int error_code_eNB;//, error_code_proc_eNB;
int error_code_eNB;
RT_flag_eNB=RT_flag;
NRT_flag_eNB=NRT_flag;
pthread_attr_init(&attr);
sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&attr,&sched_param_rrh);
pthread_attr_setschedpolicy(&attr,SCHED_FIFO);
/*
for (i=0; i<4; i++) {
pthread_mutex_init(&sync_eNB_mutex[i],NULL);
pthread_cond_init(&sync_eNB_cond[i],NULL);
}*/
error_code_eNB = pthread_create(&main_rrh_eNB_thread, &attr, rrh_eNB_thread, (void *)dev_enb);
/*for (i=0; i<4; i++) {
pthread_mutex_init(&sync_eNB_mutex[i],NULL);
pthread_cond_init(&sync_eNB_cond[i],NULL);
}*/
/* handshake with client to exchange parameters */
mod_enb->eth_dev.trx_start_f