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) { ...@@ -132,7 +132,37 @@ int trx_brf_end(openair0_device *device) {
return 0; 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 openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
int status; int status;
...@@ -141,10 +171,12 @@ int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cf ...@@ -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)); brf_state_t *brf = (brf_state_t*)malloc(sizeof(brf_state_t));
memset(brf, 0, sizeof(brf_state_t)); memset(brf, 0, sizeof(brf_state_t));
// init required params for BRF // init required params for BRF
brf->num_buffers = 128; //brf->dev_model = ;
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->num_buffers = 128;
brf->timeout_ms = 0; 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; 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", 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 ...@@ -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_end_func = trx_brf_end;
device->trx_read_func = trx_brf_read; device->trx_read_func = trx_brf_read;
device->trx_write_func = trx_brf_write; 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)); memcpy((void*)&device->openair0_cfg,(void*)openair0_cfg,sizeof(openair0_config_t));
return 0; return 0;
...@@ -269,26 +306,7 @@ int brf_error(int status) { ...@@ -269,26 +306,7 @@ int brf_error(int status) {
//return 1; // or status error code //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) { int openair0_set_rx_frequencies(openair0_device* device, openair0_config_t *openair0_cfg) {
return 0; return 0;
} }
......
...@@ -40,9 +40,12 @@ ...@@ -40,9 +40,12 @@
#ifndef COMMON_LIB_H #ifndef COMMON_LIB_H
#define COMMON_LIB_H #define COMMON_LIB_H
#include <stdint.h> #include <stdint.h>
#include <sys/types.h>
typedef int64_t openair0_timestamp; typedef int64_t openair0_timestamp;
typedef volatile int64_t openair0_vtimestamp; typedef volatile int64_t openair0_vtimestamp;
typedef struct openair0_device_t openair0_device; typedef struct openair0_device_t openair0_device;
/* structrue holds the parameters to configure USRP devices /* structrue holds the parameters to configure USRP devices
*/ */
...@@ -78,7 +81,7 @@ typedef struct { ...@@ -78,7 +81,7 @@ typedef struct {
//! number of samples per RX/TX packet (USRP + Ethernet) //! number of samples per RX/TX packet (USRP + Ethernet)
int samples_per_packet; int samples_per_packet;
// delay in sending samples (write) due to hardware access, softmodem processing and fronthaul delay if exist // 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 //! adjust the position of the samples after delay when sending
unsigned int tx_forward_nsamps; unsigned int tx_forward_nsamps;
//! number of RX channels (=RX antennas) //! number of RX channels (=RX antennas)
...@@ -144,10 +147,13 @@ typedef enum { ...@@ -144,10 +147,13 @@ typedef enum {
} dev_type_t; } dev_type_t;
/*!\brief type */ /*!\brief type */
typedef enum { typedef enum {
MIN_FUNC_TYPE = 0, MIN_FUNC_TYPE = 0,
/*!\brief device functions within a BBU */
BBU_FUNC, BBU_FUNC,
/*!\brief device functions within a RRH */
RRH_FUNC, RRH_FUNC,
MAX_FUNC_TYPE MAX_FUNC_TYPE
...@@ -156,13 +162,13 @@ typedef enum { ...@@ -156,13 +162,13 @@ typedef enum {
struct openair0_device_t { struct openair0_device_t {
/* Module ID of this device */ /* Module ID of this device */
int Mod_id; int Mod_id;
/* Type of this device */
func_type_t func_type;
/* Type of this device */ /* Type of this device */
dev_type_t type; dev_type_t type;
/* Type of the device's host (BBU/RRH) */
func_type_t func_type;
/* RF frontend parameters set by application */ /* RF frontend parameters set by application */
openair0_config_t openair0_cfg; openair0_config_t openair0_cfg;
...@@ -174,14 +180,11 @@ struct openair0_device_t { ...@@ -174,14 +180,11 @@ struct openair0_device_t {
/* Called to start the transceiver. Return 0 if OK, < 0 if error */ /* Called to start the transceiver. Return 0 if OK, < 0 if error */
int (*trx_start_func)(openair0_device *device); int (*trx_start_func)(openair0_device *device);
/* Called to initiate transceiver threads */ /* Called to send a request message between BBU-RRH */
void (*trx_thread_func)(openair0_device *device, unsigned int rt_period, uint8_t RT_flag,uint8_t NRT_flag); int (*trx_request_func)(openair0_device *device, void *msg, ssize_t msg_len);
/* Called to request connection from the transceiver/RRH. Return 0 if OK, < 0 if error */
int (*trx_request_func)(openair0_device *device);
/* Called to reply back to connection state to eNB/BBU. Return 0 if OK, < 0 if error */ /* Called to send a reply message between BBU-RRH */
int (*trx_reply_func)(openair0_device *openair0); 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 /* 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 * the first channel. timestamp if the time (in samples) at which the first sample
...@@ -216,6 +219,23 @@ struct openair0_device_t { ...@@ -216,6 +219,23 @@ struct openair0_device_t {
/* Terminate operation of the transceiver -- free all associated resources */ /* Terminate operation of the transceiver -- free all associated resources */
void (*trx_end_func)(openair0_device *device); 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" ...@@ -225,31 +245,19 @@ extern "C"
#endif #endif
/* return 0 if OK */ /* return 0 if OK */
int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg); int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cfg);
openair0_timestamp get_usrp_time(openair0_device *device); //int openair0_stop(int card);
//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);
//ETHERNET //ETHERNET
int openair0_dev_init_eth(openair0_device *device, openair0_config_t *openair0_cfg); 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_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 #ifdef __cplusplus
} }
......
...@@ -52,12 +52,8 @@ ...@@ -52,12 +52,8 @@
#include "common_lib.h" #include "common_lib.h"
#include "ethernet_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_eth = 0;
int num_devices = 0;
int dest_addr_len[MAX_INST]; int dest_addr_len[MAX_INST];
char sendbuf[MAX_INST][BUF_SIZ]; /*TODO*/ char sendbuf[MAX_INST][BUF_SIZ]; /*TODO*/
...@@ -69,7 +65,7 @@ int ethernet_socket_init(openair0_device *device) { ...@@ -69,7 +65,7 @@ int ethernet_socket_init(openair0_device *device) {
eth_state_t *eth = (eth_state_t*)device->priv; eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id; 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]; char str[INET_ADDRSTRLEN];
const char *dest_ip; const char *dest_ip;
int dest_port; int dest_port;
...@@ -156,7 +152,7 @@ void ethernet_socket_opt (openair0_device *device){ ...@@ -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; int Mod_id = device->Mod_id;
eth_state_t *eth = (eth_state_t*)device->priv; eth_state_t *eth = (eth_state_t*)device->priv;
...@@ -191,7 +187,7 @@ int trx_eth_request(openair0_device *device) { ...@@ -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; eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id; int Mod_id = device->Mod_id;
...@@ -218,9 +214,44 @@ int trx_eth_reply(openair0_device *device) { ...@@ -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_port =ntohs(eth->dest_addr[Mod_id].sin_port);
device->openair0_cfg.remote_ip=str; device->openair0_cfg.remote_ip=str;
//ethernet_socket_opt (device); //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 ...@@ -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*/ /* 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; int32_t temp0 = *(int32_t *)buff2;
openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + sizeof(int32_t)); openair0_timestamp temp1 = *(openair0_timestamp *)(buff2 + sizeof(int32_t));
//printf("temp0=%d temp=%d\n",temp0,temp1);
//char str[INET_ADDRSTRLEN];
n_written = 0; n_written = 0;
*(int16_t *)(buff2 + sizeof(int16_t))=1+(antenna_id<<1); *(int16_t *)(buff2 + sizeof(int16_t))=1+(antenna_id<<1);
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = timestamp; *(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 , len %d, buff %p antenna %d\n",
//printf("[RRH]write mod_%d %d to %s:%d, len %d, buff %p antenna %d\n", Mod_id,eth->sockfd[Mod_id],(nsamps<<2)+header_size, buff2, antenna_id);*/
//Mod_id,eth->sockfd[Mod_id],str,ntohs(eth->dest_addr[Mod_id].sin_port),(nsamps<<2)+header_size, buff2, antenna_id);
while(n_written < nsamps) { while(n_written < nsamps) {
/* Send packet */ /* Send packet */
...@@ -273,7 +301,6 @@ while(n_written < nsamps) { ...@@ -273,7 +301,6 @@ while(n_written < nsamps) {
/* tx buffer values restored */ /* tx buffer values restored */
*(int32_t *)buff2 = temp0; *(int32_t *)buff2 = temp0;
*(openair0_timestamp *)(buff2 + sizeof(int32_t)) = temp1; *(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; return n_written;
} }
...@@ -284,7 +311,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi ...@@ -284,7 +311,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
int bytes_received; int bytes_received;
int block_cnt; int block_cnt;
int ret; int ret;
char str[INET_ADDRSTRLEN];
uint16_t header_size=sizeof(int32_t) + sizeof(openair0_timestamp); 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 ...@@ -299,15 +325,13 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
eth_state_t *eth = (eth_state_t*)device->priv; eth_state_t *eth = (eth_state_t*)device->priv;
int Mod_id = device->Mod_id; 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; bytes_received=0;
block_cnt=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))) { while(bytes_received < (int)((nsamps<<2))) {
//printf("requesting %d bytes\n",(nsamps<<2));
ret=recvfrom(eth->sockfd[Mod_id], ret=recvfrom(eth->sockfd[Mod_id],
buff2+bytes_received, buff2+bytes_received,
(nsamps<<2)+header_size-bytes_received, (nsamps<<2)+header_size-bytes_received,
...@@ -315,7 +339,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi ...@@ -315,7 +339,6 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
(struct sockaddr *)&eth->dest_addr[Mod_id], (struct sockaddr *)&eth->dest_addr[Mod_id],
(socklen_t *)&dest_addr_len[Mod_id]); (socklen_t *)&dest_addr_len[Mod_id]);
//printf("bytes_received %d (ret %d)\n",bytes_received+ret,ret);
if (ret==-1) { if (ret==-1) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
perror("ETHERNET READ: "); perror("ETHERNET READ: ");
...@@ -349,8 +372,18 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi ...@@ -349,8 +372,18 @@ int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,voi
} }
int trx_eth_start(openair0_device *device){ 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) { 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 * ...@@ -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); 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); return(0);
} }
int openair0_reset_stats(openair0_device* device) {
int trx_eth_reset_stats(openair0_device* device) {
return(0); return(0);
} }
void trx_eth_end(openair0_device *device) { 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 ...@@ -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)); eth_state_t *eth = (eth_state_t*)malloc(sizeof(eth_state_t));
int card = 0; int card = 0;
memset(eth, 0, sizeof(eth_state_t)); 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; eth->sample_rate = (unsigned int)openair0_cfg[card].sample_rate;
device->priv = eth; device->priv = eth;
printf("ETHERNET: Initializing openair0_device for %s ...\n", ((device->func_type == BBU_FUNC) ? "BBU": "RRH")); 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_start_func = trx_eth_start;
device->trx_request_func = trx_eth_request; device->trx_request_func = trx_eth_request;
device->trx_reply_func = trx_eth_reply; 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_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)); memcpy((void*)&device->openair0_cfg,(void*)openair0_cfg,sizeof(openair0_config_t));
/* if (ethernet_socket_init(device)!=0){
return -1;
}*/
return 0; return 0;
} }
...@@ -47,6 +47,9 @@ ...@@ -47,6 +47,9 @@
#include <net/if.h> #include <net/if.h>
#include <netinet/ether.h> #include <netinet/ether.h>
#define MAX_INST 4
#define DEFAULT_IF "eth0"
#define BUF_SIZ 8960 /*Jumbo frame size*/
typedef struct { typedef struct {
...@@ -54,9 +57,8 @@ typedef struct { ...@@ -54,9 +57,8 @@ typedef struct {
//struct eth_if *dev; //struct eth_if *dev;
// An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend) // An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
int sockfd[4]; int sockfd[MAX_INST];
struct sockaddr_in dest_addr[4]; struct sockaddr_in dest_addr[MAX_INST];
unsigned int buffer_size; unsigned int buffer_size;
unsigned int timeout_ns; unsigned int timeout_ns;
...@@ -102,12 +104,12 @@ struct eth_meta_data{ ...@@ -102,12 +104,12 @@ struct eth_meta_data{
typedef struct { typedef struct {
/* packet's timestamp */ /* packet's timestamp */
openair0_timestamp timestamp; openair0_timestamp timestamp;
/* variable declared for alignment purposes (sample size=32 bit) */ /* variable declared for alignment purposes (sample size=32 bit) */
int16_t not_used; int16_t not_used;
/* antenna port used to resynchronize*/ /* antenna port used to resynchronize*/
int16_t antenna_id; int16_t antenna_id;
} header_t; } header_t;
......
...@@ -247,7 +247,6 @@ int openair0_stop_without_reset(int card) ...@@ -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 MY_RF_MODE (RXEN + TXEN + TXLPFNORM + TXLPFEN + TXLPF25 + RXLPFNORM + RXLPFEN + RXLPF25 + LNA1ON +LNAMax + RFBBNORM + DMAMODE_RX + DMAMODE_TX)
#define RF_MODE_BASE (LNA1ON + RFBBNORM) #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) { int openair0_device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// Initialize card // Initialize card
...@@ -483,6 +482,10 @@ int openair0_set_frequencies(openair0_device* device, openair0_config_t *openair ...@@ -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) { unsigned int *openair0_daq_cnt(void) {
return((unsigned int *)openair0_exmimo_pci[0].rxcnt_ptr[0]); return((unsigned int *)openair0_exmimo_pci[0].rxcnt_ptr[0]);
......
...@@ -56,7 +56,7 @@ typedef struct ...@@ -56,7 +56,7 @@ typedef struct
// -------------------------------- // --------------------------------
uhd::usrp::multi_usrp::sptr usrp; uhd::usrp::multi_usrp::sptr usrp;
//uhd::usrp::multi_usrp::sptr rx_usrp; //uhd::usrp::multi_usrp::sptr rx_usrp;
//create a send streamer and a receive streamer //create a send streamer and a receive streamer
uhd::tx_streamer::sptr tx_stream; uhd::tx_streamer::sptr tx_stream;
uhd::rx_streamer::sptr rx_stream; uhd::rx_streamer::sptr rx_stream;
...@@ -123,6 +123,7 @@ static void trx_usrp_end(openair0_device *device) ...@@ -123,6 +123,7 @@ static void trx_usrp_end(openair0_device *device)
s->tx_stream->send("", 0, s->tx_md); s->tx_stream->send("", 0, s->tx_md);
s->tx_md.end_of_burst = false; 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) 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; usrp_state_t *s = (usrp_state_t*)device->priv;
...@@ -199,7 +200,7 @@ static bool is_equal(double a, double b) ...@@ -199,7 +200,7 @@ static bool is_equal(double a, double b)
return std::fabs(a-b) < std::numeric_limits<double>::epsilon(); 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; 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 ...@@ -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) { openair0_config_t *openair0_cfg) {
usrp_state_t *s = (usrp_state_t*)device->priv; usrp_state_t *s = (usrp_state_t*)device->priv;
...@@ -247,11 +248,11 @@ int openair0_set_gains(openair0_device* device, ...@@ -247,11 +248,11 @@ int openair0_set_gains(openair0_device* device,
return(0); return(0);
} }
int openair0_stop(int card) { int trx_usrp_stop(int card) {
return(0); return(0);
} }
rx_gain_calib_table_t calib_table[] = { rx_gain_calib_table_t calib_table[] = {
{3500000000.0,46.0}, {3500000000.0,46.0},
{2660000000.0,53.0}, {2660000000.0,53.0},
...@@ -279,17 +280,18 @@ void set_rx_gain_offset(openair0_config_t *openair0_cfg, int chain_index) { ...@@ -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); return(0);
} }
int openair0_reset_stats(openair0_device* device) { int trx_usrp_reset_stats(openair0_device* device) {
return(0); 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) 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 ...@@ -438,9 +440,14 @@ int openair0_device_init(openair0_device* device, openair0_config_t *openair0_cf
device->priv = s; device->priv = s;
device->trx_start_func = trx_usrp_start; 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_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; s->sample_rate = openair0_cfg[0].sample_rate;
// TODO: // TODO:
......
...@@ -273,7 +273,7 @@ void *rrh_UE_thread(void *arg) { ...@@ -273,7 +273,7 @@ void *rrh_UE_thread(void *arg) {
while (rrh_exit==0) { 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 */ /* allocate memory for TX/RX buffers */
rx_buffer_UE = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*)); rx_buffer_UE = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*));
......
...@@ -51,8 +51,6 @@ ...@@ -51,8 +51,6 @@
#include "rrh_gw_externs.h" #include "rrh_gw_externs.h"
#include "rt_wrapper.h" #include "rt_wrapper.h"
#define RRH_eNB_PORT 50000
#define RRH_eNB_DEST_IP "192.168.12.31"
#define PRINTF_PERIOD 3750 #define PRINTF_PERIOD 3750
#define HEADER_SIZE ((sizeof(int32_t) + sizeof(openair0_timestamp))>>2) #define HEADER_SIZE ((sizeof(int32_t) + sizeof(openair0_timestamp))>>2)
//#undef LOWLATENCY //#undef LOWLATENCY
...@@ -64,29 +62,30 @@ void *rrh_eNB_tx_thread(void *); ...@@ -64,29 +62,30 @@ void *rrh_eNB_tx_thread(void *);
void *rrh_proc_eNB_thread(void *); void *rrh_proc_eNB_thread(void *);
void *rrh_eNB_thread(void *); void *rrh_eNB_thread(void *);
void set_rt_period( openair0_config_t openair0_cfg); 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_t main_rrh_eNB_thread;
pthread_attr_t attr, attr_proc; pthread_attr_t attr, attr_proc;
struct sched_param sched_param_rrh; 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 overflow_rx_buffer_eNB[4]= {0,0,0,0};
int32_t nsamps_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 eNB_tx_started=0,eNB_rx_started=0;
int32_t counter_eNB_rx[4]= {0,0,0,0}; int32_t counter_eNB_rx[4]= {0,0,0,0};
int32_t counter_eNB_tx[4]= {0,0,0,0}; int32_t counter_eNB_tx[4]= {0,0,0,0};
uint8_t RT_flag_eNB,NRT_flag_eNB; uint8_t RT_flag_eNB,NRT_flag_eNB;
int32_t **tx_buffer_eNB, **rx_buffer_eNB; int32_t **tx_buffer_eNB, **rx_buffer_eNB;
void *rrh_eNB_thread_status; void *rrh_eNB_thread_status;
void *rx_eNB[2]; //to be fixed void **rx_eNB; //was fixed to 2 ant
void *tx_eNB[2]; //to be fixed void **tx_eNB; //was fixed to 2 ant
int sync_eNB_rx[4]= {-1,-1,-1,-1};
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 rx_pos=0, next_rx_pos=0;
unsigned int tx_pos=0, prev_tx_pos=0; unsigned int tx_pos=0, prev_tx_pos=0;
...@@ -100,30 +99,117 @@ unsigned int tx_pos=0, prev_tx_pos=0; ...@@ -100,30 +99,117 @@ unsigned int tx_pos=0, prev_tx_pos=0;
* \note * \note
* @ingroup _oai * @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 i;
int error_code_eNB;//, error_code_proc_eNB; int error_code_eNB;
RT_flag_eNB=RT_flag; RT_flag_eNB=RT_flag;
NRT_flag_eNB=NRT_flag; NRT_flag_eNB=NRT_flag;
pthread_attr_init(&attr); pthread_attr_init(&attr);
sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO); sched_param_rrh.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&attr,&sched_param_rrh); pthread_attr_setschedparam(&attr,&sched_param_rrh);
pthread_attr_setschedpolicy(&attr,SCHED_FIFO); pthread_attr_setschedpolicy(&attr,SCHED_FIFO);
/* /*for (i=0; i<4; i++) {
for (i=0; i<4; i++) { pthread_mutex_init(&sync_eNB_mutex[i],NULL);
pthread_mutex_init(&sync_eNB_mutex[i],NULL); pthread_cond_init(&sync_eNB_cond[i],NULL);
pthread_cond_init(&sync_eNB_cond[i],NULL); }*/
}*/
/* handshake with client to exchange parameters */
error_code_eNB = pthread_create(&main_rrh_eNB_thread, &attr, rrh_eNB_thread, (void *)dev_enb); mod_enb->eth_dev.trx_start_func(&mod_enb->eth_dev);//change port make it plus_id
memcpy((void*)&mod_enb->devs->openair0_cfg,(void *)&mod_enb->eth_dev.openair0_cfg,sizeof(openair0_config_t));
/* update certain parameters */
if ( mod_enb->devs->type == EXMIMO_IF ) {
if ( mod_enb->devs->openair0_cfg.num_rb_dl == 100 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 175;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 50 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 95;
mod_enb->devs->openair0_cfg.tx_delay = 5;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 25 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 1024;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 70;
mod_enb->devs->openair0_cfg.tx_delay = 6;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 6 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 256;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 40;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
}
else if (mod_enb->devs->type == USRP_IF) {
if ( mod_enb->devs->openair0_cfg.num_rb_dl == 100 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 175;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 50 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 95;
mod_enb->devs->openair0_cfg.tx_delay = 5;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 25 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 1024;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 70;
mod_enb->devs->openair0_cfg.tx_delay = 6;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 6 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 256;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 40;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
}
else if (mod_enb->devs->type == BLADERF_IF) {
if ( mod_enb->devs->openair0_cfg.num_rb_dl == 100 ) {
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 175;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 50 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 2048;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 95;
mod_enb->devs->openair0_cfg.tx_delay = 5;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 25 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 1024;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 70;
mod_enb->devs->openair0_cfg.tx_delay = 6;
}
else if( mod_enb->devs->openair0_cfg.num_rb_dl == 6 ){
mod_enb->devs->openair0_cfg.samples_per_packet = 256;
mod_enb->devs->openair0_cfg.tx_forward_nsamps = 40;
mod_enb->devs->openair0_cfg.tx_delay = 8;
}
}
/* check sanity of received configuration parameters and print */
check_dev_config(mod_enb);
#ifndef ETHERNET
/* initialize and apply configuration to associated RF device */
if (openair0_device_init(mod_enb->devs, &mod_enb->devs->openair0_cfg)<0){
LOG_E(RRH,"Exiting, cannot initialize RF device.\n");
exit(-1);
}
else {
LOG_I(RRH,"RF device has been successfully initialized.\n");
}
#endif
error_code_eNB = pthread_create(&main_rrh_eNB_thread, &attr, rrh_eNB_thread, (void *)mod_enb);
if (error_code_eNB) { if (error_code_eNB) {
printf("Error while creating eNB thread\n"); LOG_E(RRH,"Error while creating eNB thread\n");
exit(-1); exit(-1);
} }
} }
/*! \fn void *rrh_eNB_thread(void *arg) /*! \fn void *rrh_eNB_thread(void *arg)
...@@ -139,62 +225,69 @@ void *rrh_eNB_thread(void *arg) ...@@ -139,62 +225,69 @@ void *rrh_eNB_thread(void *arg)
rrh_module_t *dev=(rrh_module_t *)arg; rrh_module_t *dev=(rrh_module_t *)arg;
pthread_t eNB_rx_thread, eNB_tx_thread; pthread_t eNB_rx_thread, eNB_tx_thread;
int error_code_eNB_rx, error_code_eNB_tx; int error_code_eNB_rx, error_code_eNB_tx;
int16_t i,j; int32_t i,j;
void *tmp; void *tmp;
unsigned int samples_per_frame=0; unsigned int samples_per_frame=0;
while (rrh_exit==0) { while (rrh_exit==0) {
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TRX, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TRX, 1 );
/* handshake with client to exchange parameters */
dev->eth_dev.trx_reply_func(&dev->eth_dev);//change port make it plus_id if (dev->devs->type != NONE_IF) {
/* prints received configuration parameters */ set_rt_period(dev->eth_dev.openair0_cfg);
print_dev_config(dev->eth_dev); }
set_rt_period(dev->eth_dev.openair0_cfg); samples_per_frame = dev->eth_dev.openair0_cfg.samples_per_frame;
samples_per_frame = dev->eth_dev.openair0_cfg.samples_per_frame;
/* allocate memory for TX/RX buffers /* allocate memory for TX/RX buffers
each antenna port has a TX and a RX buffer each antenna port has a TX and a RX buffer
each TX and RX buffer is of (samples_per_frame + HEADER_SIZE) samples(int32_t) */ each TX and RX buffer is of (samples_per_frame + HEADER_SIZE) samples (size of samples is 4 bytes) */
rx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*)); rx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*));
tx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.tx_num_channels*sizeof(int32_t*)); tx_buffer_eNB = (int32_t**)malloc16(dev->eth_dev.openair0_cfg.tx_num_channels*sizeof(int32_t*));
LOG_D(RRH,"rx ch %d %p and tx ch %d %p\n", LOG_I(RRH,"rx ch %d %p and tx ch %d %p\n",
dev->eth_dev.openair0_cfg.rx_num_channels, dev->eth_dev.openair0_cfg.rx_num_channels,
rx_buffer_eNB, rx_buffer_eNB,
dev->eth_dev.openair0_cfg.tx_num_channels, dev->eth_dev.openair0_cfg.tx_num_channels,
tx_buffer_eNB); tx_buffer_eNB);
/* rx_buffer_eNB points to the beginning of data */ /* rx_buffer_eNB points to the beginning of data */
for (i=0; i<dev->eth_dev.openair0_cfg.rx_num_channels; i++) { for (i=0; i<dev->eth_dev.openair0_cfg.rx_num_channels; i++) {
tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame + HEADER_SIZE)); tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame + HEADER_SIZE));
memset(tmp,0,sizeof(int32_t)*(samples_per_frame + HEADER_SIZE)); memset(tmp,0,sizeof(int32_t)*(samples_per_frame + HEADER_SIZE));
rx_buffer_eNB[i]=( tmp + (HEADER_SIZE*sizeof(int32_t)) ); rx_buffer_eNB[i]=( tmp + (HEADER_SIZE*sizeof(int32_t)) );
LOG_D(RRH," rx ch %d %p |%p header=%d size=%d sample=%d spf=%d\n", LOG_I(RRH," rx ch %d %p |%p\n",i,rx_buffer_eNB[i],tmp);
i,
rx_buffer_eNB[i],tmp,HEADER_SIZE,(sizeof(int32_t)*(samples_per_frame + HEADER_SIZE)),sizeof(int32_t),samples_per_frame);
} }
/* tx_buffer_eNB points to the beginning of data */ /* tx_buffer_eNB points to the beginning of data */
for (i=0; i<dev->eth_dev.openair0_cfg.tx_num_channels; i++) { for (i=0; i<dev->eth_dev.openair0_cfg.tx_num_channels; i++) {
tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame + HEADER_SIZE)); tmp=(void *)malloc(sizeof(int32_t)*(samples_per_frame + HEADER_SIZE));
memset(tmp,0,sizeof(int32_t)*(samples_per_frame + HEADER_SIZE)); memset(tmp,0,sizeof(int32_t)*(samples_per_frame + HEADER_SIZE));
tx_buffer_eNB[i]=( tmp + (HEADER_SIZE*sizeof(int32_t)) ); tx_buffer_eNB[i]=( tmp + (HEADER_SIZE*sizeof(int32_t)) );
LOG_D(RRH," tx ch %d %p| %p \n", i,tx_buffer_eNB[i],tmp); LOG_I(RRH," tx ch %d %p| %p \n", i,tx_buffer_eNB[i],tmp);
} }
/* dummy initialization for TX/RX buffers */ /* dummy initialization for TX/RX buffers */
for (i=0; i<dev->eth_dev.openair0_cfg.tx_num_channels; i++) { for (i=0; i<dev->eth_dev.openair0_cfg.rx_num_channels; i++) {
for (j=0; j<samples_per_frame; j++) { for (j=0; j<samples_per_frame; j++) {
rx_buffer_eNB[i][j]=32+i; rx_buffer_eNB[i][j]=32+i;
tx_buffer_eNB[i][j]=13+i;
} }
} }
/* dummy initialization for TX/RX buffers */
for (i=0; i<dev->eth_dev.openair0_cfg.tx_num_channels; i++) {
for (j=0; j<samples_per_frame; j++) {
tx_buffer_eNB[i][j]=12+i;
}
}
/* allocate TX/RX buffers pointers used in write/read operations */
rx_eNB = (void**)malloc16(dev->eth_dev.openair0_cfg.rx_num_channels*sizeof(int32_t*));
tx_eNB = (void**)malloc16(dev->eth_dev.openair0_cfg.tx_num_channels*sizeof(int32_t*));
#ifdef LOWLATENCY #ifdef LOWLATENCY
error_code_eNB_rx = pthread_create(&eNB_rx_thread, NULL, rrh_eNB_rx_thread, (void *)dev); error_code_eNB_rx = pthread_create(&eNB_rx_thread, NULL, rrh_eNB_rx_thread, (void *)dev);
error_code_eNB_tx = pthread_create(&eNB_tx_thread, NULL, rrh_eNB_tx_thread, (void *)dev); error_code_eNB_tx = pthread_create(&eNB_tx_thread, NULL, rrh_eNB_tx_thread, (void *)dev);
LOG_D(RRH,"[eNB][SCHED] deadline scheduling applied to TX/RX threads\n"); LOG_I(RRH,"[eNB][SCHED] deadline scheduling applied to eNB TX/RX threads\n");
#else #else
pthread_attr_t attr_eNB_rx, attr_eNB_tx; pthread_attr_t attr_eNB_rx, attr_eNB_tx;
struct sched_param sched_param_eNB_rx, sched_param_eNB_tx; struct sched_param sched_param_eNB_rx, sched_param_eNB_tx;
...@@ -209,7 +302,7 @@ void *rrh_eNB_thread(void *arg) ...@@ -209,7 +302,7 @@ void *rrh_eNB_thread(void *arg)
error_code_eNB_rx = pthread_create(&eNB_rx_thread, &attr_eNB_rx, rrh_eNB_rx_thread, (void *)dev); error_code_eNB_rx = pthread_create(&eNB_rx_thread, &attr_eNB_rx, rrh_eNB_rx_thread, (void *)dev);
error_code_eNB_tx = pthread_create(&eNB_tx_thread, &attr_eNB_tx, rrh_eNB_tx_thread, (void *)dev); error_code_eNB_tx = pthread_create(&eNB_tx_thread, &attr_eNB_tx, rrh_eNB_tx_thread, (void *)dev);
LOG_D(RRH,"[eNB][SCHED] FIFO scheduling applied to TX/RX threads\n"); LOG_I(RRH,"[eNB][SCHED] FIFO scheduling applied to eNB TX/RX threads\n");
#endif #endif
if (error_code_eNB_rx) { if (error_code_eNB_rx) {
...@@ -253,7 +346,7 @@ void *rrh_eNB_rx_thread(void *arg){ ...@@ -253,7 +346,7 @@ void *rrh_eNB_rx_thread(void *arg){
rrh_module_t *dev = (rrh_module_t *)arg; rrh_module_t *dev = (rrh_module_t *)arg;
ssize_t bytes_sent; ssize_t bytes_sent;
int i, spp ,pck_rx=0; int i, spp ,pck_rx=0;
openair0_vtimestamp last_hw_counter=0; //volatile int64_t last_hw_counter=0;---> read openair0_vtimestamp last_hw_counter=0; //volatile int64_t
unsigned int samples_per_frame=0; unsigned int samples_per_frame=0;
uint8_t loopback=0,measurements=0; uint8_t loopback=0,measurements=0;
...@@ -266,7 +359,6 @@ void *rrh_eNB_rx_thread(void *arg){ ...@@ -266,7 +359,6 @@ void *rrh_eNB_rx_thread(void *arg){
measurements = dev->measurements; measurements = dev->measurements;
next_rx_pos = spp; next_rx_pos = spp;
LOG_I(RRH,"rt period is set to %d\n",rt_period);
#ifdef LOWLATENCY #ifdef LOWLATENCY
struct sched_attr attr; struct sched_attr attr;
unsigned int flags = 0; unsigned int flags = 0;
...@@ -352,7 +444,7 @@ void *rrh_eNB_rx_thread(void *arg){ ...@@ -352,7 +444,7 @@ void *rrh_eNB_rx_thread(void *arg){
VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_TS, timestamp_eNB_rx[i]&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_RX_TS, timestamp_eNB_rx[i]&0xffffffff );
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
//LOG_D(RRH,"rx_buffer_eNB[i][rx_pos]=%p ,rx_pos=%d, i=%d ts=%d\n",&rx_buffer_eNB[i][rx_pos],rx_pos,i,timestamp_eNB_rx[i]); //LOG_D(RRH," rx_eNB[i]=%p rx_buffer_eNB[i][rx_pos]=%p ,rx_pos=%d, i=%d ts=%d\n",rx_eNB[i],&rx_buffer_eNB[i][rx_pos],rx_pos,i,timestamp_eNB_rx[i]);
if ((bytes_sent = dev->eth_dev.trx_write_func (&dev->eth_dev, if ((bytes_sent = dev->eth_dev.trx_write_func (&dev->eth_dev,
timestamp_eNB_rx[i], timestamp_eNB_rx[i],
rx_eNB, rx_eNB,
...@@ -382,7 +474,7 @@ void *rrh_eNB_rx_thread(void *arg){ ...@@ -382,7 +474,7 @@ void *rrh_eNB_rx_thread(void *arg){
min_rx_time = total_rx_time; min_rx_time = total_rx_time;
if (total_rx_time > max_rx_time){ if (total_rx_time > max_rx_time){
max_rx_time = total_rx_time; max_rx_time = total_rx_time;
LOG_D(RRH,"Max value %d update at rx_position %d \n",timestamp_eNB_rx[i], rx_pos); LOG_I(RRH,"Max value %d update at rx_position %d \n",total_rx_time,timestamp_eNB_rx[i]);
} }
average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1); average_rx_time = (long long unsigned int)((average_rx_time*trial)+total_rx_time)/(trial+1);
} }
...@@ -542,47 +634,74 @@ void *rrh_eNB_tx_thread(void *arg){ ...@@ -542,47 +634,74 @@ void *rrh_eNB_tx_thread(void *arg){
//needs to be fixed //needs to be fixed
void set_rt_period( openair0_config_t openair0_cfg){ void set_rt_period( openair0_config_t openair0_cfg){
AssertFatal(openair0_cfg.samples_per_frame > 0, "invalide samples per frame !%u\n",openair0_cfg.samples_per_frame);
AssertFatal(openair0_cfg.samples_per_packet > 0, "invalide samples per packets !%u\n",openair0_cfg.samples_per_packet);
rt_period= (double)(openair0_cfg.samples_per_packet/(openair0_cfg.samples_per_frame/10.0)*1000000); rt_period= (double)(openair0_cfg.samples_per_packet/(openair0_cfg.samples_per_frame/10.0)*1000000);
AssertFatal(rt_period > 0, "invalide rt period !%u\n", rt_period); AssertFatal(rt_period > 0, "Invalid rt period !%u\n", rt_period);
LOG_I(RRH,"Real time period is set to %d ns.\n",rt_period); //only in case of NRT with emulated UE
// set the calibration parameters for ETH later: check with RK //create_timer_thread();
openair0_cfg.tx_delay=0;
openair0_cfg.tx_forward_nsamps=0;
//only in case of NRT with emulated UE
create_timer_thread();
// usleep(rt_period*1000);
} }
void print_dev_config(openair0_device device){ void check_dev_config( rrh_module_t *mod_enb) {
printf("\tMod_id=%d\n \tlog level=%d\n \tDL_RB=%d\n \tspf=%d\n \tsr=%f\n \tspp=%d\n \ttx_delay=%d\n \ttx_forwd_samps=%d\n \trx_ch=%d\n \ttx_ch=%d\n \trx_freq=%f\n \ttx_freq=%f\n \trxg_mode=%d\n \trx_gain=%f\n \ttx_gain=%f\n \trx_bw=%f\n \ttx_bw=%f\n \tautocal=%d\n \trem_addr %s:%d\n \tmy_addr %s:%d\n",
device.openair0_cfg.Mod_id, AssertFatal( (mod_enb->devs->openair0_cfg.num_rb_dl==100 || mod_enb->devs->openair0_cfg.num_rb_dl==50 || mod_enb->devs->openair0_cfg.num_rb_dl==25 || mod_enb->devs->openair0_cfg.num_rb_dl==6) , "Invalid number of resource blocks! %d\n", mod_enb->devs->openair0_cfg.num_rb_dl);
device.openair0_cfg.log_level, AssertFatal( mod_enb->devs->openair0_cfg.samples_per_frame > 0 , "Invalid number of samples per frame! %d\n",mod_enb->devs->openair0_cfg.samples_per_frame);
device.openair0_cfg.num_rb_dl, AssertFatal( mod_enb->devs->openair0_cfg.sample_rate > 0.0, "Invalid sample rate! %f\n", mod_enb->devs->openair0_cfg.sample_rate);
device.openair0_cfg.samples_per_frame, AssertFatal( mod_enb->devs->openair0_cfg.samples_per_packet > 0 , "Invalid number of samples per packet! %d\n",mod_enb->devs->openair0_cfg.samples_per_packet);
device.openair0_cfg.sample_rate, AssertFatal( mod_enb->devs->openair0_cfg.rx_num_channels > 0 , "Invalid number of RX antennas! %d\n", mod_enb->devs->openair0_cfg.rx_num_channels);
device.openair0_cfg.samples_per_packet, AssertFatal( mod_enb->devs->openair0_cfg.tx_num_channels > 0 , "Invalid number of TX antennas! %d\n", mod_enb->devs->openair0_cfg.tx_num_channels);
device.openair0_cfg.tx_delay, AssertFatal( mod_enb->devs->openair0_cfg.rx_freq[0] > 0.0 ,"Invalid RX frequency! %f\n", mod_enb->devs->openair0_cfg.rx_freq[0]);
device.openair0_cfg.tx_forward_nsamps, AssertFatal( mod_enb->devs->openair0_cfg.tx_freq[0] > 0.0 ,"Invalid TX frequency! %f\n", mod_enb->devs->openair0_cfg.tx_freq[0]);
device.openair0_cfg.rx_num_channels, AssertFatal( mod_enb->devs->openair0_cfg.rx_gain[0] > 0.0 ,"Invalid RX gain! %f\n", mod_enb->devs->openair0_cfg.rx_gain[0]);
device.openair0_cfg.tx_num_channels, AssertFatal( mod_enb->devs->openair0_cfg.tx_gain[0] > 0.0 ,"Invalid TX gain! %f\n", mod_enb->devs->openair0_cfg.tx_gain[0]);
device.openair0_cfg.rx_freq[0], AssertFatal( mod_enb->devs->openair0_cfg.rx_bw > 0.0 ,"Invalid RX bw! %f\n", mod_enb->devs->openair0_cfg.rx_bw);
device.openair0_cfg.tx_freq[0], AssertFatal( mod_enb->devs->openair0_cfg.tx_bw > 0.0 ,"Invalid RX bw! %f\n", mod_enb->devs->openair0_cfg.tx_bw);
device.openair0_cfg.rxg_mode[0], // AssertFatal( mod_enb->devs->openair0_cfg.autocal[0] > 0 , "Invalid auto calibration choice! %d\n", mod_enb->devs->openair0_cfg.autocal[0]);
device.openair0_cfg.rx_gain[0],
device.openair0_cfg.tx_gain[0], printf("\n---------------------RF device configuration parameters---------------------\n");
device.openair0_cfg.rx_bw,
device.openair0_cfg.tx_bw, printf("\tMod_id=%d\n \tlog level=%d\n \tDL_RB=%d\n \tsamples_per_frame=%d\n \tsample_rate=%f\n \tsamples_per_packet=%d\n \ttx_delay=%d\n \ttx_forward_nsamps=%d\n \trx_num_channels=%d\n \ttx_num_channels=%d\n \trx_freq_0=%f\n \ttx_freq_0=%f\n \trx_freq_1=%f\n \ttx_freq_1=%f\n \trx_freq_2=%f\n \ttx_freq_2=%f\n \trx_freq_3=%f\n \ttx_freq_3=%f\n \trxg_mode=%d\n \trx_gain_0=%f\n \ttx_gain_0=%f\n \trx_gain_1=%f\n \ttx_gain_1=%f\n \trx_gain_2=%f\n \ttx_gain_2=%f\n \trx_gain_3=%f\n \ttx_gain_3=%f\n \trx_gain_offset_2=%f\n \ttx_gain_offset_3=%f\n \trx_bw=%f\n \ttx_bw=%f\n \tautocal=%d\n \trem_addr %s:%d\n \tmy_addr %s:%d\n",
device.openair0_cfg.autocal[0], mod_enb->devs->openair0_cfg.Mod_id,
device.openair0_cfg.remote_ip, mod_enb->devs->openair0_cfg.log_level,
device.openair0_cfg.remote_port, mod_enb->devs->openair0_cfg.num_rb_dl,
device.openair0_cfg.my_ip, mod_enb->devs->openair0_cfg.samples_per_frame,
device.openair0_cfg.my_port mod_enb->devs->openair0_cfg.sample_rate,
); mod_enb->devs->openair0_cfg.samples_per_packet,
mod_enb->devs->openair0_cfg.tx_delay,
mod_enb->devs->openair0_cfg.tx_forward_nsamps,
mod_enb->devs->openair0_cfg.rx_num_channels,
mod_enb->devs->openair0_cfg.tx_num_channels,
mod_enb->devs->openair0_cfg.rx_freq[0],
mod_enb->devs->openair0_cfg.tx_freq[0],
mod_enb->devs->openair0_cfg.rx_freq[1],
mod_enb->devs->openair0_cfg.tx_freq[1],
mod_enb->devs->openair0_cfg.rx_freq[2],
mod_enb->devs->openair0_cfg.tx_freq[2],
mod_enb->devs->openair0_cfg.rx_freq[3],
mod_enb->devs->openair0_cfg.tx_freq[3],
mod_enb->devs->openair0_cfg.rxg_mode[0],
mod_enb->devs->openair0_cfg.rx_gain[0],
mod_enb->devs->openair0_cfg.tx_gain[0],
mod_enb->devs->openair0_cfg.rx_gain[1],
mod_enb->devs->openair0_cfg.tx_gain[1],
mod_enb->devs->openair0_cfg.rx_gain[2],
mod_enb->devs->openair0_cfg.tx_gain[2],
mod_enb->devs->openair0_cfg.rx_gain[3],
mod_enb->devs->openair0_cfg.tx_gain[3],
//mod_enb->devs->openair0_cfg.rx_gain_offset[0],
//mod_enb->devs->openair0_cfg.rx_gain_offset[1],
mod_enb->devs->openair0_cfg.rx_gain_offset[2],
mod_enb->devs->openair0_cfg.rx_gain_offset[3],
mod_enb->devs->openair0_cfg.rx_bw,
mod_enb->devs->openair0_cfg.tx_bw,
mod_enb->devs->openair0_cfg.autocal[0],
mod_enb->devs->openair0_cfg.remote_ip,
mod_enb->devs->openair0_cfg.remote_port,
mod_enb->devs->openair0_cfg.my_ip,
mod_enb->devs->openair0_cfg.my_port
);
printf("----------------------------------------------------------------------------\n");
} }
...@@ -2966,6 +2966,7 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; ...@@ -2966,6 +2966,7 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
#ifdef ETHERNET #ifdef ETHERNET
openair0.type=ETH_IF; // not used for the moment openair0.type=ETH_IF; // not used for the moment
openair0.func_type = BBU_FUNC;
openair0_dev_init_eth(&openair0, &openair0_cfg[0]); openair0_dev_init_eth(&openair0, &openair0_cfg[0]);
#else #else
#ifdef EXMIMO #ifdef EXMIMO
...@@ -2984,8 +2985,7 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; ...@@ -2984,8 +2985,7 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
printf("Exiting, cannot initialize device\n"); printf("Exiting, cannot initialize device\n");
exit(-1); exit(-1);
} }
else if (mode==loop_through_memory) { else if (mode==loop_through_memory) {
} }
#endif #endif
...@@ -3304,12 +3304,14 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL; ...@@ -3304,12 +3304,14 @@ openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
#endif #endif
#ifndef EXMIMO #ifndef EXMIMO
#ifndef USRP_DEBUG #ifndef USRP_DEBUG
if (mode!=loop_through_memory) if (mode!=loop_through_memory)
if (openair0.trx_start_func(&openair0) != 0 ) if (openair0.trx_start_func(&openair0) != 0 )
LOG_E(HW,"Could not start the device\n"); LOG_E(HW,"Could not start the device\n");
#endif #endif
#endif #endif
......
...@@ -443,11 +443,16 @@ static void *UE_thread_synch(void *arg) ...@@ -443,11 +443,16 @@ static void *UE_thread_synch(void *arg)
openair0_cfg[0].rx_gain[0] -= 0; openair0_cfg[0].rx_gain[0] -= 0;
break; break;
} }
#ifndef EXMIMO
openair0.trx_set_freq_func(&openair0,&openair0_cfg[0],0);
openair0.trx_set_gains_func(&openair0,&openair0_cfg[0]);
openair0.trx_stop_func(0);
#else
openair0_set_frequencies(&openair0,&openair0_cfg[0],0); openair0_set_frequencies(&openair0,&openair0_cfg[0],0);
openair0_set_gains(&openair0,&openair0_cfg[0]); openair0_set_gains(&openair0,&openair0_cfg[0]);
openair0_stop(0); openair0_stop(0);
#endif
sleep(1); sleep(1);
init_frame_parms(&UE->lte_frame_parms,1); init_frame_parms(&UE->lte_frame_parms,1);
} }
else { else {
...@@ -516,10 +521,15 @@ static void *UE_thread_synch(void *arg) ...@@ -516,10 +521,15 @@ static void *UE_thread_synch(void *arg)
openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+freq_offset; openair0_cfg[card].tx_freq[i] = downlink_frequency[card][i]+uplink_frequency_offset[card][i]+freq_offset;
#ifdef OAI_USRP #ifdef OAI_USRP
openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET; openair0_cfg[card].rx_gain[i] = UE->rx_total_gain_dB;//-USRP_GAIN_OFFSET;
#ifndef EXMIMO
openair0.trx_set_freq_func(&openair0,&openair0_cfg[0],0);
#else
openair0_set_frequencies(&openair0,&openair0_cfg[0],0); openair0_set_frequencies(&openair0,&openair0_cfg[0],0);
#endif
switch(UE->lte_frame_parms.N_RB_DL) { switch(UE->lte_frame_parms.N_RB_DL) {
case 6: case 6:
openair0_cfg[card].rx_gain[i] -= 12; openair0_cfg[card].rx_gain[i] -= 12;
......
...@@ -1030,9 +1030,10 @@ void *rrh_eNB_thread(void *arg) ...@@ -1030,9 +1030,10 @@ void *rrh_eNB_thread(void *arg)
rrh_eNB_desc.clientaddr = clientaddr; rrh_eNB_desc.clientaddr = clientaddr;
rrh_eNB_desc.clientaddrlen = clientaddrlen; rrh_eNB_desc.clientaddrlen = clientaddrlen;
cmd = cmd&1; //cmd = cmd&1;
cmd = cmd|1;//in order to make cmd evalution dummy (the first message from lte to rrh has changed, see: @ethernet_lib.c trx_start_func has been substituted by trx_request_func )
inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN); inet_ntop(AF_INET, &(((struct sockaddr_in*)&clientaddr)->sin_addr), str, INET_ADDRSTRLEN);
if (cmd==START_CMD) { if (cmd==START_CMD) {
pthread_attr_init(&attr_eNB_rx); pthread_attr_init(&attr_eNB_rx);
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
[*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI
[*] Thu Jul 9 09:53:25 2015 [*] Thu Jul 9 09:53:25 2015
[*] [*]
[dumpfile] "/tmp/openair_dump_eNB.vcd" [dumpfile] "/tmp/openair_dump_rrh.vcd"
[dumpfile_mtime] "Thu Jul 9 09:52:29 2015" [dumpfile_mtime] "Thu Jul 9 09:52:29 2015"
[dumpfile_size] 170586112 [dumpfile_size] 170586112
[savefile] "/home/sud/openair4G/targets/RT/USER/eNB2.gtkw" [savefile] "/home/sud/openair4G/targets/RT/USER/eNB2.gtkw"
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "common_lib.h" #include "common_lib.h"
#include "rrh_gw.h" // change to rrh_new.h, put externs in rrh_extern.h #include "rrh_gw.h" // change to rrh_new.h, put externs in rrh_extern.h
#include "rt_wrapper.h" #include "rt_wrapper.h"
#include "rrh_gw_externs.h" // change to rrh_new.h, put externs in rrh_extern.h
#include "log_if.h" #include "log_if.h"
...@@ -68,10 +69,10 @@ static void debug_init(void); ...@@ -68,10 +69,10 @@ static void debug_init(void);
static void get_options(int argc, char *argv[]); static void get_options(int argc, char *argv[]);
static void print_help(void); static void print_help(void);
static void get_RFinterfaces(void); static void get_RFinterfaces(void);
static rrh_module_t new_module(unsigned int id, dev_type_t type); static rrh_module_t new_module(unsigned int id);
int get_ip_address(char* if_name);
char rrh_ip[20] = "192.168.12.242"; // there is code to detect the my ip address
char rrh_ip[20] = "192.168.12.31"; // there is code to detect the my ip address
int rrh_port = 50000; // has to be an option int rrh_port = 50000; // has to be an option
/* log */ /* log */
...@@ -86,34 +87,33 @@ int16_t ue_log_verbosity = LOG_MED; ...@@ -86,34 +87,33 @@ int16_t ue_log_verbosity = LOG_MED;
/* flags definitions */ /* flags definitions */
uint8_t eNB_flag=0; uint8_t eNB_flag=0;
uint8_t UE_flag=0; uint8_t UE_flag=0;
uint8_t EXMIMO_flag=0; uint8_t EXMIMO_flag=0;
uint8_t USRP_flag=0; uint8_t USRP_flag=0;
uint8_t RT_flag=0, NRT_flag=1; uint8_t RT_flag=0, NRT_flag=1;
uint8_t rrh_exit=0; uint8_t rrh_exit=0;
uint8_t loopback_flag=0;
uint8_t measurements_flag=0;
/* Default operation as RRH: /* Default operation as RRH:
- there are no eNB nor UE modules - there are neither eNB nor UE modules
- no RF device is asscociated with RRH */ - no RF device is asscociated with RRH */
uint8_t num_eNB_mod=0; uint8_t num_eNB_mod=0;
uint8_t num_UE_mod=0; uint8_t num_UE_mod=0;
uint8_t num_EXMIMO_mod=0; uint8_t num_EXMIMO_mod=0;
uint8_t num_USRP_mod=0; uint8_t num_USRP_mod=0;
uint8_t loopback_flag=0;
uint8_t measurements_flag=0;
uint8_t hardware_target=NONE_IF; uint8_t hardware_target=NONE_IF;
unsigned int RT_period=0; rrh_module_t *enb_array;
rrh_module_t *enb_array,*ue_array; rrh_module_t *ue_array;
pthread_mutex_t timer_mutex; pthread_mutex_t timer_mutex;
openair0_vtimestamp hw_counter=0; openair0_vtimestamp hw_counter=0;
unsigned int rt_period=0;
struct itimerspec timerspec;
unsigned int rt_period; char* if_name="lo";
struct itimerspec timerspec;
char* if_name="eth0";
int main(int argc, char **argv) { int main(int argc, char **argv) {
...@@ -123,40 +123,72 @@ int main(int argc, char **argv) { ...@@ -123,40 +123,72 @@ int main(int argc, char **argv) {
get_options(argc, argv); get_options(argc, argv);
/* initialize logger and signal analyzer */ /* initialize logger and signal analyzer */
debug_init(); debug_init();
/* */
set_latency_target(); set_latency_target();
/*make a graceful exit when ctrl-c is pressed */ /*make a graceful exit when ctrl-c is pressed */
signal(SIGSEGV, signal_handler); signal(SIGSEGV, signal_handler);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
//probe RF front end devices interfaced to RRH /*probe RF front end devices interfaced to RRH */
//get_RFinterfaces(); // get_RFinterfaces();
#ifdef ETHERNET
int error_code_timer;
pthread_t main_timer_proc_thread;
LOG_I(RRH,"Creating timer thread with rt period %d ns.\n",rt_period);
/* setup the timer to generate an interrupt:
-for the first time in (sample_per_packet/sample_rate) ns
-and then every (sample_per_packet/sample_rate) ns */
timerspec.it_value.tv_sec = rt_period/1000000000;
timerspec.it_value.tv_nsec = rt_period%1000000000;
timerspec.it_interval.tv_sec = rt_period/1000000000;
timerspec.it_interval.tv_nsec = rt_period%1000000000;
//#ifndef LOWLATENCY
pthread_attr_t attr_timer;
struct sched_param sched_param_timer;
pthread_attr_init(&attr_timer);
sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO);
pthread_attr_setschedparam(&attr_timer,&sched_param_timer);
pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO);
pthread_mutex_init(&timer_mutex,NULL);
error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timerspec);
LOG_I(RRH,"[SCHED] FIFO scheduling applied to timer thread \n");
/*#else
error_code_timer = pthread_create(&main_timer_proc_thread, NULL, timer_proc, (void *)&timerspec);
LOG_I(RRH,"[SCHED] deadline scheduling applied to timer thread \n");
#endif*/
if (error_code_timer) {
LOG_E(RRH,"Error while creating timer proc thread\n");
exit(-1);
}
#endif
/* create modules based on input arguments */ /* create modules based on input arguments */
if (eNB_flag==1){ if (eNB_flag==1){
enb_array=(rrh_module_t*)malloc(num_eNB_mod*sizeof(rrh_module_t)); enb_array=(rrh_module_t*)malloc(num_eNB_mod*sizeof(rrh_module_t));
// create num of modules for(i=0;i<num_eNB_mod;i++){
for(i=0;i<num_eNB_mod;i++){ enb_array[i]=new_module(i);//enb_array[i]=new_module(i, get_RF_interfaces(&hardware_target));
/*
enb_array[i]=new_module(i, get_RF_interfaces(&hardware_target));
*/
enb_array[i]=new_module(i, NONE_IF);
create_eNB_trx_threads(&enb_array[i],RT_flag,NRT_flag); create_eNB_trx_threads(&enb_array[i],RT_flag,NRT_flag);
LOG_I(RRH,"[eNB %d] module(s) created (%u) \n",i,num_eNB_mod); LOG_I(RRH,"[eNB %d] module(s) created (out of %u) \n",i,num_eNB_mod);
} }
} }
if (UE_flag==1){ if (UE_flag==1){
ue_array=(rrh_module_t*)malloc(num_UE_mod*sizeof(rrh_module_t)); ue_array=(rrh_module_t*)malloc(num_UE_mod*sizeof(rrh_module_t));
// create num of modules
for(i=0;i<num_UE_mod;i++){ for(i=0;i<num_UE_mod;i++){
ue_array[i]=new_module(i, NONE_IF); ue_array[i]=new_module(i);
create_UE_trx_threads(&ue_array[i],RT_flag,NRT_flag); create_UE_trx_threads(&ue_array[i],RT_flag,NRT_flag);
LOG_I(RRH,"[UE %d] module(s) created (%u)\n",i, num_UE_mod); LOG_I(RRH,"[UE %d] module(s) created (out of %u)\n",i, num_UE_mod);
} }
} }
printf("TYPE <CTRL-C> TO TERMINATE\n"); printf("TYPE <CTRL-C> TO TERMINATE\n");
while (rrh_exit==0) while (rrh_exit==0)
...@@ -178,137 +210,55 @@ int main(int argc, char **argv) { ...@@ -178,137 +210,55 @@ int main(int argc, char **argv) {
* \note * \note
* @ingroup _oai * @ingroup _oai
*/ */
static rrh_module_t new_module (unsigned int id, dev_type_t type) { static rrh_module_t new_module (unsigned int id) {
rrh_module_t rrh_mod; rrh_module_t rrh_mod;
openair0_config_t openair0_cfg; openair0_config_t openair0_cfg;
rrh_mod.id=id; rrh_mod.id=id;
rrh_mod.loopback=loopback_flag; rrh_mod.loopback=loopback_flag;
rrh_mod.measurements=measurements_flag; rrh_mod.measurements=measurements_flag;
rrh_mod.eth_dev.func_type=RRH_FUNC;
/* each module is associated with an ethernet device */ /* each module is associated with an ethernet device */
rrh_mod.eth_dev.type=ETH_IF; rrh_mod.eth_dev.type=ETH_IF;
get_ip_addreess(if_name); rrh_mod.eth_dev.func_type=RRH_FUNC;
get_ip_address(if_name);
openair0_cfg.my_ip=&rrh_ip[0]; openair0_cfg.my_ip=&rrh_ip[0];
openair0_cfg.my_port=rrh_port; openair0_cfg.my_port=rrh_port;
//printf("rrh ip %s\n", rrh_mod.eth_dev.openair0_cfg.my_ip); /* ethernet device initialization */
/* ethernet device initialization*/
if (openair0_dev_init_eth(&rrh_mod.eth_dev, &openair0_cfg)<0){ if (openair0_dev_init_eth(&rrh_mod.eth_dev, &openair0_cfg)<0){
LOG_E(RRH,"Exiting, cannot initialize ethernet interface.\n"); LOG_E(RRH,"Exiting, cannot initialize ethernet interface.\n");
exit(-1); exit(-1);
} }
/* specify associated RF device */
openair0_device *oai_dv = (openair0_device *)malloc(sizeof(openair0_device));
memset(oai_dv,0, sizeof(openair0_device));
#ifdef EXMIMO
rrh_mod.devs=oai_dv;
rrh_mod.devs->type=EXMIMO_IF;
LOG_I(RRH,"Setting RF device to EXMIMO\n");
#elif OAI_USRP
rrh_mod.devs=oai_dv;
rrh_mod.devs->type=USRP_IF;
LOG_I(RRH,"Setting RF device to USRP\n");
#elif OAI_BLADERF
rrh_mod.devs=oai_dv;
rrh_mod.devs->type=BLADERF_IF;
LOG_I(RRH,"Setting RF device to BLADERF\n");
#else
rrh_mod.devs=oai_dv;
rrh_mod.devs->type=NONE_IF;
LOG_I(RRH,"Setting RF interface to NONE_IF... \n");
#endif
/* initialize another HW device */
switch(type){
case ETH_IF:
LOG_E(RRH,"Error: one module is associated with one ETHERNET iterface!\n");
break;
case EXMIMO_IF:
rrh_mod.devs=malloc(sizeof(openair0_device));
rrh_mod.devs->type=EXMIMO_IF;
LOG_I(RRH,"Setting RF interface to EXMIMO_IF and initializing device ...\n");
/*if (openair0_device_init(rrh_mod.devs, &openair0_cfg)<0){
printf("Exiting, cannot initialize device.\n");
exit(-1);
}*/
break;
case USRP_IF:
rrh_mod.devs=malloc(sizeof(openair0_device));
rrh_mod.devs->type=USRP_IF;
LOG_I(RRH,"Setting RF interface to USRP_IF and initializing device ...\n");
/*if (openair0_device_init(rrh_mod.devs, &openair0_cfg)<0){
printf("Exiting, cannot initialize device.\n");
exit(-1);
} */
break;
case BLADERF_IF:
rrh_mod.devs=malloc(sizeof(openair0_device));
rrh_mod.devs->type=BLADERF_IF;
LOG_I(RRH,"Setting RF interface to BLADERF_IF and initializing device ...\n");
/* if (openair0_device_init(rrh_mod.devs, &openair0_cfg)<0){
printf("Exiting, cannot initialize device.\n");
exit(-1);
} */
break;
case NONE_IF:
rrh_mod.devs=NULL;
LOG_I(RRH,"Setting RF interface to NONE_IF... \n");
break;
default:
break;
}
return rrh_mod; return rrh_mod;
} }
/*! \fn static void get_RFinterfaces(void)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
static void get_RFinterfaces(void) {
//tbd
EXMIMO_flag=1;
USRP_flag=1;
num_EXMIMO_mod=1;
num_USRP_mod=1;
}
/*!\fn void create_timer_thread(void)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
void create_timer_thread() {
int error_code_timer;
pthread_t main_timer_proc_thread;
LOG_I(RRH,"Creating timer thread with rt period %d ns.\n",rt_period);
/* setup the timer to generate an interrupt:
-for the first time in (sample_per_packet/sample_rate) ns
-and then every (sample_per_packet/sample_rate) ns */
timerspec.it_value.tv_sec = rt_period/1000000000;
timerspec.it_value.tv_nsec = rt_period%1000000000;
timerspec.it_interval.tv_sec = rt_period/1000000000;
timerspec.it_interval.tv_nsec = rt_period%1000000000;
pthread_mutex_init(&timer_mutex,NULL);
#ifndef LOWLATENCY
pthread_attr_t attr_timer;
struct sched_param sched_param_timer;
pthread_attr_init(&attr_timer);
sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO-1);
pthread_attr_setschedparam(&attr_timer,&sched_param_timer);
pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO-1);
error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timerspec);
LOG_D(RRH,"[SCHED] FIFO scheduling \n");
#else
error_code_timer = pthread_create(&main_timer_proc_thread, NULL, timer_proc, (void *)&timerspec);
LOG_D(RRH,"[SCHED] LOWLATENCY scheduling \n");
#endif
if (error_code_timer) {
LOG_E(RRH,"Error while creating timer proc thread\n");
exit(-1);
}
}
/*! \fn void *timer_proc(void *arg) /*! \fn void *timer_proc(void *arg)
* \brief this function * \brief this function
...@@ -320,13 +270,11 @@ void create_timer_thread() { ...@@ -320,13 +270,11 @@ void create_timer_thread() {
*/ */
void *timer_proc(void *arg) { void *timer_proc(void *arg) {
timer_t timerid; // timer ID for timer timer_t timerid;
struct itimerspec *timer = (struct itimerspec*)arg; // the timer data structure struct itimerspec *timer= (struct itimerspec *)arg ; // the timer data structure
struct itimerspec *old_value; struct itimerspec *old_value;
LOG_I(RRH,"timer thread created\n"); /*
#ifdef LOWLATENCY #ifdef LOWLATENCY
struct sched_attr attr; struct sched_attr attr;
unsigned int flags = 0; unsigned int flags = 0;
...@@ -338,30 +286,27 @@ void *timer_proc(void *arg) { ...@@ -338,30 +286,27 @@ void *timer_proc(void *arg) {
attr.sched_policy = SCHED_DEADLINE; attr.sched_policy = SCHED_DEADLINE;
attr.sched_runtime = (0.1 * 100) * 10000; // attr.sched_runtime = (0.1 * 100) * 10000; //
attr.sched_deadline = rt_period;//(0.1 * 100) * 10000; // attr.sched_deadline = rt_period-30000;//(0.1 * 100) * 10000; //
attr.sched_period = rt_period;//(0.1 * 100) * 10000; // each TX/RX thread has, as a function of RT PERIOD ?? attr.sched_period = rt_period;//(0.1 * 100) * 10000; // each TX/RX thread has, as a function of RT PERIOD ??
if (sched_setattr(0, &attr, flags) < 0 ) { if (sched_setattr(0, &attr, flags) < 0 ) {
perror("[SCHED] timer thread: sched_setattr failed\n"); perror("[SCHED] timer thread: sched_setattr failed\n");
exit(-1); exit(-1);
} }
#endif #endif
//printf("Starting the timer\n"); */
if (timer_create (CLOCK_REALTIME, NULL, &timerid) == -1) { if (timer_create (CLOCK_REALTIME, NULL, &timerid) == -1) {
fprintf (stderr, "couldn't create a timer\n"); fprintf (stderr, "couldn't create a timer\n");
perror (NULL); perror (NULL);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
signal(SIGALRM, timer_signal_handler); signal(SIGALRM, timer_signal_handler);
// and start it! LOG_I(RRH,"Timer has started!\n");
timer_settime (timerid, 0, timer, old_value); timer_settime (timerid, 0, timer, old_value);
//timer_settime (timerid, TIMER_ABSTIME, timer, old_value);
while (!rrh_exit) { while (!rrh_exit) {
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TM, 1 );
sleep(1); sleep(1);
//VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_TM, 0 );
} }
timer_delete(timerid); timer_delete(timerid);
...@@ -437,16 +382,10 @@ static void debug_init(void) { ...@@ -437,16 +382,10 @@ static void debug_init(void) {
// vcd initialization // vcd initialization
if (ouput_vcd) { if (ouput_vcd) {
vcd_signal_dumper_init("/tmp/openair_dump_rrh.vcd");
if (eNB_flag==1)
vcd_signal_dumper_init("/tmp/openair_dump_eNB.vcd");
if (UE_flag==1)
vcd_signal_dumper_init("/tmp/openair_dump_UE.vcd");
}
} }
}
/*!\fn void get_options(int argc, char *argv[]) /*!\fn void get_options(int argc, char *argv[])
* \brief this function * \brief this function
...@@ -504,21 +443,29 @@ static void get_options(int argc, char *argv[]) { ...@@ -504,21 +443,29 @@ static void get_options(int argc, char *argv[]) {
measurements_flag=1; measurements_flag=1;
break; break;
case 'w': case 'w':
/* force to use this target*/ /* force to use this target*/
//hardware_target= hardware_target=1;
break; break;
case 'h': case 'h':
print_help(); print_help();
exit(-1); exit(-1);
default: /* '?' */ default: /* '?' */
//fprintf(stderr, "Usage: \n", argv[0]); //fprintf(stderr, "Usage: \n", argv[0]);
exit(-1); exit(-1);
}
} }
} }
int get_ip_addreess(char* if_name){ }
/*!\fn void print_help(void)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
int get_ip_address(char* if_name) {
int fd; int fd;
struct ifreq ifr; struct ifreq ifr;
...@@ -569,3 +516,84 @@ static void print_help(void) { ...@@ -569,3 +516,84 @@ static void print_help(void) {
} }
/*! \fn void exit_fun(const char* s)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
void exit_fun(const char* s)
{
if (s != NULL) {
printf("%s %s() Exiting RRH: %s\n",__FILE__, __FUNCTION__, s);
}
rrh_exit = 1;
exit (-1);
}
/*! \fn static void get_RFinterfaces(void)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
static void get_RFinterfaces(void) {
EXMIMO_flag=1;
USRP_flag=1;
num_EXMIMO_mod=1;
num_USRP_mod=1;
}
/*!\fn void create_timer_thread(void)
* \brief this function
* \param[in]
* \param[out]
* \return
* \note
* @ingroup _oai
*/
void create_timer_thread() {
int error_code_timer;
pthread_t main_timer_proc_thread;
LOG_I(RRH,"Creating timer thread with rt period %d ns.\n",rt_period);
/* setup the timer to generate an interrupt:
-for the first time in (sample_per_packet/sample_rate) ns
-and then every (sample_per_packet/sample_rate) ns */
timerspec.it_value.tv_sec = rt_period/1000000000;
timerspec.it_value.tv_nsec = rt_period%1000000000;
timerspec.it_interval.tv_sec = rt_period/1000000000;
timerspec.it_interval.tv_nsec = rt_period%1000000000;
pthread_mutex_init(&timer_mutex,NULL);
#ifndef LOWLATENCY
pthread_attr_t attr_timer;
struct sched_param sched_param_timer;
pthread_attr_init(&attr_timer);
sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO-1);
pthread_attr_setschedparam(&attr_timer,&sched_param_timer);
pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO-1);
error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timerspec);
LOG_I(RRH,"[SCHED] FIFO scheduling applied to timer thread \n");
#else
error_code_timer = pthread_create(&main_timer_proc_thread, NULL, timer_proc, (void *)&timerspec);
LOG_I(RRH,"[SCHED] deadline scheduling applied to timer thread \n");
#endif
if (error_code_timer) {
LOG_E(RRH,"Error while creating timer proc thread\n");
exit(-1);
}
}
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
/*! \brief RRH supports two types of modules: eNB and UE /*! \brief RRH supports two types of modules: eNB and UE
each module is associated a device of type ETH_IF each module is associated a device of type ETH_IF
and optionally with another device (USRP/BLADERF/EXMIMO) */ and optionally with an RF device (USRP/BLADERF/EXMIMO) */
typedef struct { typedef struct {
//! module id //! module id
uint8_t id; uint8_t id;
...@@ -80,6 +80,6 @@ void create_timer_thread(void); ...@@ -80,6 +80,6 @@ void create_timer_thread(void);
** FUNCTION PROTOTYPES ** ** FUNCTION PROTOTYPES **
******************************************************************************/ ******************************************************************************/
void create_UE_trx_threads( rrh_module_t *dev_ue, uint8_t RT_flag, uint8_t NRT_flag); void create_UE_trx_threads( rrh_module_t *dev_ue, uint8_t RT_flag, uint8_t NRT_flag);
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);
#endif #endif
...@@ -47,7 +47,8 @@ extern int32_t nsamps_UE[4],nsamps_eNB[4]; ...@@ -47,7 +47,8 @@ extern int32_t nsamps_UE[4],nsamps_eNB[4];
extern int32_t overflow_rx_buffer_eNB[4],overflow_rx_buffer_UE[4]; extern int32_t overflow_rx_buffer_eNB[4],overflow_rx_buffer_UE[4];
extern uint8_t rrh_exit; extern uint8_t rrh_exit;
extern int32_t **rx_buffer_eNB, **rx_buffer_UE; extern int32_t **rx_buffer_eNB, **rx_buffer_UE;
extern unsigned int rt_period;
extern pthread_mutex_t timer_mutex;
extern unsigned int rt_period;
#endif #endif
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