Commit f0e8581f authored by aikaterini.trilyraki's avatar aikaterini.trilyraki

1. update ethernet library-raw/udp modes supported 2. rrh_gw UE/eNB_trasport...

1. update ethernet library-raw/udp modes supported 2. rrh_gw UE/eNB_trasport files updated accordingly
parent fd39e80e
This diff is collapsed.
This diff is collapsed.
......@@ -36,6 +36,8 @@
* \note
* \warning
*/
#ifndef ETHERNET_LIB_H
#define ETHERNET_LIB_H
#include <arpa/inet.h>
#include <linux/if_packet.h>
......@@ -47,61 +49,95 @@
#include <net/if.h>
#include <netinet/ether.h>
#define MAX_INST 4
#define DEFAULT_IF "lo"
#define BUF_SIZ 8960 /*Jumbo frame size*/
#define MAX_INST 4
#define DEFAULT_IF "lo"
#define ETH_RAW_MODE 1
#define ETH_UDP_MODE (1<<1)
#define ETH_LOOP_MODE (1<<2)
#define TX_FLAG 1
#define RX_FLAG 0
#define MAC_HEADER_SIZE_BYTES (sizeof(struct ether_header))
#define APP_HEADER_SIZE_BYTES (sizeof(int32_t) + sizeof(openair0_timestamp))
#define PAYLOAD_SIZE_BYTES(nsamps) (nsamps<<2)
#define UDP_PACKET_SIZE_BYTES(nsamps) (APP_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES(nsamps))
#define RAW_PACKET_SIZE_BYTES(nsamps) (APP_HEADER_SIZE_BYTES + MAC_HEADER_SIZE_BYTES + PAYLOAD_SIZE_BYTES(nsamps))
/*
#define RRH_DEST_MAC0 0x74
#define RRH_DEST_MAC1 0xd4
#define RRH_DEST_MAC2 0x35
#define RRH_DEST_MAC3 0xcc
#define RRH_DEST_MAC4 0x88
#define RRH_DEST_MAC5 0x45
#define BBU_DEST_MAC0 0xd4
#define BBU_DEST_MAC1 0xbe
#define BBU_DEST_MAC2 0xd9
#define BBU_DEST_MAC3 0x22
#define BBU_DEST_MAC4 0x0a
#define BBU_DEST_MAC5 0xac
*/
/*!\brief opaque ethernet data structure */
typedef struct {
// opaque eth data struct
//struct eth_if *dev;
// An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
/*!\brief socket file desc */
int sockfd[MAX_INST];
struct sockaddr_in dest_addr[MAX_INST];
/*!\brief interface name */
char *if_name[MAX_INST];
/*!\brief buffer size */
unsigned int buffer_size;
unsigned int timeout_ns;
//struct eth_metadata meta_rx;
//struct eth_metadata meta_tx;
unsigned int sample_rate;
// time offset between transmiter timestamp and receiver timestamp;
/*!\brief timeout ms */
unsigned int rx_timeout_ms;
/*!\brief timeout ms */
unsigned int tx_timeout_ms;
/*!\brief runtime flags */
uint32_t flags;
/*!\ time offset between transmiter timestamp and receiver timestamp */
double tdiff;
// use brf_time_offset to get this value
int tx_forward_nsamps; //166 for 20Mhz
/*!\ calibration */
int tx_forward_nsamps;
// --------------------------------
// Debug and output control
// --------------------------------
/*!\brief number of I/Q samples to be printed */
int iqdumpcnt;
/*!\brief number of underflows in interface */
int num_underflows;
/*!\brief number of overflows in interface */
int num_overflows;
/*!\brief number of concesutive errors in interface */
int num_seq_errors;
/*!\brief number of errors in interface's receiver */
int num_rx_errors;
/*!\brief umber of errors in interface's transmitter */
int num_tx_errors;
uint64_t tx_actual_nsamps; // actual number of samples transmitted
/*!\brief current TX timestamp */
openair0_timestamp tx_current_ts;
/*!\brief socket file desc */
openair0_timestamp rx_current_ts;
/*!\brief actual number of samples transmitted */
uint64_t tx_actual_nsamps;
/*!\brief actual number of samples received */
uint64_t rx_actual_nsamps;
uint64_t tx_nsamps; // number of planned samples
/*!\brief number of samples to be transmitted */
uint64_t tx_nsamps;
/*!\brief number of samples to be received */
uint64_t rx_nsamps;
uint64_t tx_count; // number pf packets
/*!\brief number of packets transmitted */
uint64_t tx_count;
/*!\brief number of packets received */
uint64_t rx_count;
//openair0_timestamp rx_timestamp;
} eth_state_t;
#define ETH_META_STATUS_OVERRUN (1 << 0)
#define ETH_META_STATUS_UNDERRUN (1 << 1)
struct eth_meta_data{
uint64_t timestamp;
uint32_t flags;
uint32_t status;
unsigned int actual_count;
};
/*!\brief packet header */
......@@ -138,9 +174,37 @@ typedef enum {
MAX_OPT
} eth_opt_t;
/*
#define SND_BUF_SIZE 1
#define RCV_BUF_SIZE 1<<1
#define SND_TIMEOUT 1<<2
#define RCV_TIMEOUT 1<<3
#define MTU_SIZE 1<<4
#define TX_Q_LEN 1<<5
#define RING_PAR 1<<5
#define COALESCE_PAR 1<<6
#define PAUSE_PAR 1<<7
*/
/*!\brief I/Q samples */
typedef struct {
/*!\brief phase */
short i;
/*!\brief quadrature */
short q;
} iqoai_t ;
void dump_packet(char *title, unsigned char* pkt, int bytes, unsigned int tx_rx_flag);
unsigned short calc_csum (unsigned short *buf, int nwords);
void dump_dev(openair0_device *device);
void inline dump_buff(openair0_device *device, char *buff,unsigned int tx_rx_flag,int nsamps);
void inline dump_rxcounters(openair0_device *device);
void inline dump_txcounters(openair0_device *device);
void dump_iqs(char * buff, int iq_cnt);
/*! \fn int ethernet_tune (openair0_device *device, eth_opt_t option)
/*! \fn int ethernet_tune (openair0_device *device, unsigned int option, int value);
* \brief this function allows you to configure certain ethernet parameters in socket or device level
* \param[in] openair0 device which bears the socket
* \param[in] name of parameter to configure
......@@ -148,6 +212,37 @@ typedef enum {
* \note
* @ingroup _oai
*/
int ethernet_tune (openair0_device *device, eth_opt_t option);
int ethernet_write_data(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc) ;
int ethernet_read_data(openair0_device *device,openair0_timestamp *timestamp,void **buff, int nsamps,int cc);
int ethernet_tune(openair0_device *device, unsigned int option, int value);
/*! \fn int eth_socket_init_udp(openair0_device *device)
* \brief initialization of UDP Socket to communicate with one destination
* \param[in] *device openair device for which the socket will be created
* \param[out]
* \return 0 on success, otherwise -1
* \note
* @ingroup _oai
*/
int eth_socket_init_udp(openair0_device *device);
int trx_eth_write_udp(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
int trx_eth_read_udp(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int eth_get_dev_conf_udp(openair0_device *device);
/*! \fn static int eth_set_dev_conf_udp(openair0_device *device)
* \brief
* \param[in] *device openair device
* \param[out]
* \return 0 on success, otherwise -1
* \note
* @ingroup _oai
*/
int eth_set_dev_conf_udp(openair0_device *device);
int eth_socket_init_raw(openair0_device *device);
int trx_eth_write_raw(openair0_device *device, openair0_timestamp timestamp, void **buff, int nsamps,int cc, int flags);
int trx_eth_read_raw(openair0_device *device, openair0_timestamp *timestamp, void **buff, int nsamps, int cc);
int eth_get_dev_conf_raw(openair0_device *device);
int eth_set_dev_conf_raw(openair0_device *device);
#endif
......@@ -284,7 +284,7 @@ void *rrh_UE_thread(void *arg) {
tx_buffer_UE[i]=(tmp+4*sizeof(int32_t));
}
printf("Client %s:%d is connected (DL_RB=%d) rt=%d|%d. \n" , dev->eth_dev.openair0_cfg.remote_ip,
printf("Client %s:%d is connected (DL_RB=%d) rt=%d|%d. \n" , dev->eth_dev.openair0_cfg.remote_addr,
dev->eth_dev.openair0_cfg.remote_port,
dev->eth_dev.openair0_cfg.num_rb_dl,
dev->eth_dev.openair0_cfg.rx_num_channels,
......
This diff is collapsed.
......@@ -51,9 +51,9 @@
#include <time.h>
#include "common_lib.h"
#include "rrh_gw.h" // change to rrh_new.h, put externs in rrh_extern.h
#include "rrh_gw.h"
#include "rt_wrapper.h"
#include "rrh_gw_externs.h" // change to rrh_new.h, put externs in rrh_extern.h
#include "rrh_gw_externs.h"
#include "log_if.h"
......@@ -72,7 +72,8 @@
char rrh_ip[20] = "192.168.12.242"; // there is code to detect the my ip address
char rrh_ip[20] = "0.0.0.0"; // there is code to detect my ip address
unsigned char rrh_mac[6] = "0:0:0:0:0:0";
int rrh_port = 50000; // has to be an option
/* log */
......@@ -86,7 +87,7 @@ int16_t ue_log_level = LOG_INFO;
int16_t ue_log_verbosity = LOG_MED;
/* flags definitions */
/* flag definitions */
uint8_t eNB_flag=0;
uint8_t UE_flag=0;
uint8_t EXMIMO_flag=0;
......@@ -102,10 +103,8 @@ uint8_t measurements_flag=0;
- default ethernet interface is local */
uint8_t num_eNB_mod=0;
uint8_t num_UE_mod=0;
uint8_t num_EXMIMO_mod=0;
uint8_t num_USRP_mod=0;
uint8_t hardware_target=NONE_IF;
char* if_name="lo";
uint8_t eth_mode=ETH_UDP_MODE;
rrh_module_t *enb_array;
rrh_module_t *ue_array;
......@@ -128,14 +127,14 @@ static void print_help(void);
*/
static rrh_module_t new_module(unsigned int id);
/*!\fn static int get_ip_address(char* if_name)
/*!\fn static int get_address(char* if_name, uint8_t flag);
* \brief retrieves IP address from the specified network interface
* \param[in] name of network interface
* \return 0
* \note
* @ingroup _oai
*/
static int get_ip_address(char* if_name);
static int get_address(char* if_name, uint8_t flag);
......@@ -192,48 +191,45 @@ static rrh_module_t new_module (unsigned int id) {
rrh_mod.measurements=measurements_flag;
/* each module is associated with an ethernet device */
rrh_mod.eth_dev.type=ETH_IF;
rrh_mod.eth_dev.type=NONE_DEV;
rrh_mod.eth_dev.transp_type=NONE_TP;
/* ethernet device is functioning within RRH */
rrh_mod.eth_dev.func_type=RRH_FUNC;
/* specify IP address */
get_ip_address(if_name);
openair0_cfg.my_ip=&rrh_ip[0];
openair0_cfg.my_port=rrh_port;
rrh_mod.eth_dev.host_type=RRH_HOST;
/* get IP and MAC address */
get_address(if_name,eth_mode);
if(eth_mode==ETH_UDP_MODE) {
openair0_cfg.my_addr = &rrh_ip[0];
openair0_cfg.my_port = rrh_port;
LOG_I(RRH,"UDP mode selected for ethernet.\n");
} else if (eth_mode==ETH_RAW_MODE) {
openair0_cfg.my_addr = &rrh_mac[0];
openair0_cfg.my_port = rrh_port;
LOG_I(RRH,"RAW mode selected for ethernet.\n");
}
/* if use setrunnig parameters we should keep in device->priv keep if_name and raw/udp flag*/
/* ethernet device initialization */
if (openair0_dev_init_eth(&rrh_mod.eth_dev, &openair0_cfg)<0){
if (openair0_transport_load(&rrh_mod.eth_dev, &openair0_cfg)<0,NULL) {
LOG_E(RRH,"Exiting, cannot initialize ethernet interface.\n");
exit(-1);
}
/* allocate space and specify associated RF device */
openair0_device *oai_dv = (openair0_device *)malloc(sizeof(openair0_device));
memset(oai_dv,0, sizeof(openair0_device));
#ifdef EXMIMO
memset(oai_dv,0,sizeof(openair0_device));
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
rrh_mod.devs->type=NONE_DEV;
rrh_mod.devs->transp_type=NONE_TP;
rrh_mod.devs->host_type=RRH_HOST;
return rrh_mod;
}
static void debug_init(void) {
// log initialization
/* log initialization */
logInit();
set_glog(glog_level, glog_verbosity);
......@@ -241,7 +237,7 @@ static void debug_init(void) {
//set_comp_log(ENB_LOG, enb_log_level, enb_log_verbosity, 1);
//set_comp_log(UE_LOG, ue_log_level, ue_log_verbosity, 1);
// vcd initialization
/* vcd initialization */
if (ouput_vcd) {
vcd_signal_dumper_init("/tmp/openair_dump_rrh.vcd");
......@@ -253,7 +249,7 @@ static void get_options(int argc, char *argv[]) {
int opt;
while ((opt = getopt(argc, argv, "xvhlte:n:u:g:r:w:i:")) != -1) {
while ((opt = getopt(argc, argv, "xvhlte:n:u:g:r:m:i:")) != -1) {
switch (opt) {
case 'n':
......@@ -273,6 +269,9 @@ static void get_options(int argc, char *argv[]) {
printf("RRH interface name is set to %s\n", if_name);
}
break;
case 'm':
eth_mode=atoi(optarg);
break;
case 'r':
//rrh_log_level=atoi(optarg);
break;
......@@ -293,49 +292,48 @@ static void get_options(int argc, char *argv[]) {
loopback_flag=1;
break;
case 't':
/*When measurements are enabled statistics related to TX/RX time are printed*/
/* When measurements are enabled statistics related to TX/RX time are printed */
measurements_flag=1;
break;
case 'w':
/* force to use this target*/
hardware_target=1;
break;
case 'h':
print_help();
exit(-1);
break;
case 'h':
print_help();
exit(-1);
default: /* '?' */
//fprintf(stderr, "Usage: \n", argv[0]);
exit(-1);
}
}
}
}
static int get_ip_address(char* if_name) {
static int get_address(char* if_name, uint8_t flag) {
int fd;
struct ifreq ifr;
fd = socket(AF_INET, SOCK_DGRAM, 0);
fd = socket(AF_INET, SOCK_DGRAM, 0);
/* I want to get an IPv4 IP address */
ifr.ifr_addr.sa_family = AF_INET;
ifr.ifr_addr.sa_family = AF_INET;
/* I want IP address attached to "if_name" */
strncpy(ifr.ifr_name, if_name, IFNAMSIZ-1);
if ( ioctl(fd, SIOCGIFADDR, &ifr)<0 ) {
perror("IOCTL:");
exit(-1);
}
if (flag==ETH_UDP_MODE) {
if ( ioctl(fd, SIOCGIFADDR, &ifr)<0 ) {
perror("IOCTL:");
exit(-1);
}
snprintf(&rrh_ip[0],20,"%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
LOG_I(RRH,"%s: IP address: %s\n",if_name,rrh_ip);
} else if (flag==ETH_RAW_MODE) {
if ( ioctl(fd, SIOCGIFHWADDR, &ifr)<0 ) {
perror("IOCTL:");
exit(-1);
}
ether_ntoa_r ((unsigned char *)ifr.ifr_hwaddr.sa_data, rrh_mac);
LOG_I(RRH,"%s: MAC address: %s\n",if_name,rrh_mac);
}
close(fd);
/* display result */
snprintf(&rrh_ip[0],20,"%s", inet_ntoa(((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr));
LOG_I(RRH,"Got IP address %s from interface %s\n", rrh_ip,if_name);
return 0;
}
......@@ -343,19 +341,19 @@ static int get_ip_address(char* if_name) {
static void print_help(void) {
puts("Usage: \n");
puts(" sudo -E chrt 99 ./rrh -n1 -g6 -v -t");
puts(" sudo -E chrt 99 ./rrh -n1 -g6 -v -t -i lo -m1");
puts("Options:\n");
puts("\t -n create eNB module\n");
puts("\t -u create UE module\n");
puts("\t -g define global log level\n");
puts("\t -i set the RRH interface (default lo)\n");
puts("\t -m set ethernet mode to be used by RRH, valid options: (1:raw, 2:udp) \n");
puts("\t -r define rrh log level\n");
puts("\t -e define eNB log level\n");
puts("\t -x enable real time bahaviour\n");
puts("\t -v enable vcd dump\n");
puts("\t -l enable loopback mode\n");
puts("\t -t enable measurements\n");
puts("\t -w force to use specified HW\n");
puts("\t -h display info\n");
}
......
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