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*));
......
This diff is collapsed.
...@@ -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"
......
This diff is collapsed.
...@@ -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