Commit be0e4095 authored by Eino Virtanen's avatar Eino Virtanen Committed by Florian Kaltenberger

USRP addressess and clock sources can be configured in the configuration file...

USRP addressess and clock sources can be configured in the configuration file with the RU section with comma separated IP addresses in 'sdr_addrs' and with strings "internal"/"external"/"gpsdo" in 'clock_src'.

TODO: Currently the driver picks the two first RX and TX channels when nb_tx and nb_rx are both set to 2. If a developers wants to force usage of two devices, 'set_rx_subdev_spec' and 'set_tx_subdev_spec' can be used to indicate to the driver so that antennas from separate devices will be used. To rephrase: until 4 antennas are supported by OAI, testing with two devices, so that antennas from both devices are used, requires manual configuration of which subdevices' antennas are used.

Conflicts:
	targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp
parent bd5b3b1e
...@@ -102,6 +102,8 @@ typedef enum { ...@@ -102,6 +102,8 @@ typedef enum {
#define CONFIG_STRING_RU_MAX_RXGAIN "max_rxgain" #define CONFIG_STRING_RU_MAX_RXGAIN "max_rxgain"
#define CONFIG_STRING_RU_IF_COMPRESSION "if_compression" #define CONFIG_STRING_RU_IF_COMPRESSION "if_compression"
#define CONFIG_STRING_RU_NBIOTRRC_LIST "NbIoT_RRC_instances" #define CONFIG_STRING_RU_NBIOTRRC_LIST "NbIoT_RRC_instances"
#define CONFIG_STRING_RU_SDR_ADDRS "sdr_addrs"
#define CONFIG_STRING_RU_SDR_CLK_SRC "clock_src"
#define RU_LOCAL_IF_NAME_IDX 0 #define RU_LOCAL_IF_NAME_IDX 0
#define RU_LOCAL_ADDRESS_IDX 1 #define RU_LOCAL_ADDRESS_IDX 1
...@@ -121,6 +123,8 @@ typedef enum { ...@@ -121,6 +123,8 @@ typedef enum {
#define RU_ATT_TX_IDX 15 #define RU_ATT_TX_IDX 15
#define RU_ATT_RX_IDX 16 #define RU_ATT_RX_IDX 16
#define RU_NBIOTRRC_LIST_IDX 17 #define RU_NBIOTRRC_LIST_IDX 17
#define RU_SDR_ADDRS 18
#define RU_SDR_CLK_SRC 19
...@@ -147,6 +151,8 @@ typedef enum { ...@@ -147,6 +151,8 @@ typedef enum {
{CONFIG_STRING_RU_ATT_TX, NULL, 0, uptr:NULL, defintval:0, TYPE_UINT, 0}, \ {CONFIG_STRING_RU_ATT_TX, NULL, 0, uptr:NULL, defintval:0, TYPE_UINT, 0}, \
{CONFIG_STRING_RU_ATT_RX, NULL, 0, uptr:NULL, defintval:0, TYPE_UINT, 0}, \ {CONFIG_STRING_RU_ATT_RX, NULL, 0, uptr:NULL, defintval:0, TYPE_UINT, 0}, \
{CONFIG_STRING_RU_NBIOTRRC_LIST, NULL, 0, uptr:NULL, defintarrayval:DEFENBS, TYPE_INTARRAY, 1}, \ {CONFIG_STRING_RU_NBIOTRRC_LIST, NULL, 0, uptr:NULL, defintarrayval:DEFENBS, TYPE_INTARRAY, 1}, \
{CONFIG_STRING_RU_SDR_ADDRS, NULL, 0, strptr:NULL, defstrval:"0.0.0.0", TYPE_STRING, 0}, \
{CONFIG_STRING_RU_SDR_CLK_SRC, NULL, 0, strptr:NULL, defstrval:"internal", TYPE_STRING, 0}, \
} }
/*---------------------------------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------------------------------*/
......
...@@ -199,6 +199,8 @@ typedef struct { ...@@ -199,6 +199,8 @@ typedef struct {
double tx_bw; double tx_bw;
//! clock source //! clock source
clock_source_t clock_source; clock_source_t clock_source;
//! Manual SDR IP address
char *sdr_addrs;
//! Auto calibration flag //! Auto calibration flag
int autocal[4]; int autocal[4];
//! rf devices work with x bits iqs when oai have its own iq format //! rf devices work with x bits iqs when oai have its own iq format
......
...@@ -955,6 +955,10 @@ extern "C" { ...@@ -955,6 +955,10 @@ extern "C" {
* \param openair0_cfg RF frontend parameters set by application * \param openair0_cfg RF frontend parameters set by application
*/ */
int device_init(openair0_device* device, openair0_config_t *openair0_cfg) { int device_init(openair0_device* device, openair0_config_t *openair0_cfg) {
LOG_D(PHY, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs);
LOG_D(PHY, "openair0_cfg[0].clock_source == '%d'\n", openair0_cfg[0].clock_source);
#if defined(USRP_REC_PLAY) #if defined(USRP_REC_PLAY)
paramdef_t usrp_recplay_params[7]; paramdef_t usrp_recplay_params[7];
struct sysinfo systeminfo; struct sysinfo systeminfo;
...@@ -1023,6 +1027,28 @@ extern "C" { ...@@ -1023,6 +1027,28 @@ extern "C" {
device->openair0_cfg = openair0_cfg; device->openair0_cfg = openair0_cfg;
std::string args = "type=b200"; std::string args = "type=b200";
char *addr_args = NULL;
// Check whether sdr_addrs is set in the config or not
if (openair0_cfg[0].sdr_addrs != NULL) {
if (strcmp(openair0_cfg[0].sdr_addrs, "0.0.0.0") != 0) {
// Check whether sdr_addrs contains multiple IP addresses
// and split and add them to addr_args
if (strstr(openair0_cfg[0].sdr_addrs, ",") != NULL) {
char *addr0 = openair0_cfg[0].sdr_addrs;
// Replace , with \0
strsep(&openair0_cfg[0].sdr_addrs, ",");
char *addr1 = openair0_cfg[0].sdr_addrs;
// Allocate memory for ",addr0=,addr1=\0" and the addresses
size_t addr_args_len = sizeof(char)*(15 + strlen(addr0) + strlen(addr1));
addr_args = (char *)malloc(addr_args_len);
snprintf(addr_args, addr_args_len, ",addr0=%s,addr1=%s", addr0, addr1);
args += addr_args;
LOG_D(PHY, "addr_args == '%s'\n", addr_args);
}
}
}
uhd::device_addrs_t device_adds = uhd::device::find(args); uhd::device_addrs_t device_adds = uhd::device::find(args);
int vers=0,subvers=0,subsubvers=0; int vers=0,subvers=0,subsubvers=0;
...@@ -1038,9 +1064,14 @@ extern "C" { ...@@ -1038,9 +1064,14 @@ extern "C" {
uhd::get_version_string().c_str(),vers,subvers,subsubvers); uhd::get_version_string().c_str(),vers,subvers,subsubvers);
if(device_adds.size() == 0) { if(device_adds.size() == 0) {
double usrp_master_clock = 184.32e6; double usrp_master_clock = 184.32e6;
std::string args = "type=x300"; std::string args = "type=x300";
if (addr_args) {
args += addr_args;
}
// workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate // workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
...@@ -1232,6 +1263,8 @@ extern "C" { ...@@ -1232,6 +1263,8 @@ extern "C" {
} }
} }
LOG_D(PHY, "usrp->get_tx_num_channels() == %d\n", s->usrp->get_tx_num_channels());
LOG_D(PHY, "openair0_cfg[0].tx_num_channels == %d\n", openair0_cfg[0].tx_num_channels);
for(int i=0; i<s->usrp->get_tx_num_channels(); i++) { for(int i=0; i<s->usrp->get_tx_num_channels(); i++) {
::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i); ::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i);
if (i<openair0_cfg[0].tx_num_channels) { if (i<openair0_cfg[0].tx_num_channels) {
......
...@@ -2837,6 +2837,24 @@ void RCconfig_RU(void) { ...@@ -2837,6 +2837,24 @@ void RCconfig_RU(void) {
RC.ru[j]->num_eNB = 0; RC.ru[j]->num_eNB = 0;
for (i=0;i<RC.ru[j]->num_eNB;i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; for (i=0;i<RC.ru[j]->num_eNB;i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0];
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) {
RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr));
}
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) {
if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) {
RC.ru[j]->openair0_cfg.clock_source = internal;
LOG_D(PHY, "RU clock source set as internal\n");
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) {
RC.ru[j]->openair0_cfg.clock_source = external;
LOG_D(PHY, "RU clock source set as external\n");
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) {
RC.ru[j]->openair0_cfg.clock_source = gpsdo;
LOG_D(PHY, "RU clock source set as gpsdo\n");
} else {
LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
}
}
if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) {
if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) {
......
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