This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Pau Espin Pedrol gerrit-no-reply at lists.osmocom.orgReview at https://gerrit.osmocom.org/6651 osmo-trx: Drop cmd lines and use VTY cfg Change-Id: Ib8de1a5da4b3c0b6a49e00033f616e1d66656adf --- M Transceiver52M/osmo-trx.cpp 1 file changed, 99 insertions(+), 319 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-trx refs/changes/51/6651/1 diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index b6daf08..82492fb 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -55,51 +55,12 @@ #include "debug.h" } -/* Samples-per-symbol for downlink path - * 4 - Uses precision modulator (more computation, less distortion) - * 1 - Uses minimized modulator (less computation, more distortion) - * - * Other values are invalid. Receive path (uplink) is always - * downsampled to 1 sps. Default to 4 sps for all cases. - */ -#define DEFAULT_TX_SPS 4 - -/* - * Samples-per-symbol for uplink (receiver) path - * Do not modify this value. EDGE configures 4 sps automatically on - * B200/B210 devices only. Use of 4 sps on the receive path for other - * configurations is not supported. - */ -#define DEFAULT_RX_SPS 1 - -/* Default configuration parameters */ -#define DEFAULT_TRX_PORT 5700 -#define DEFAULT_TRX_IP "127.0.0.1" -#define DEFAULT_CHANS 1 #define DEFAULT_CONFIG_FILE "osmo-trx.cfg" +#define charp2str(a) ((a) ? std::string(a) : std::string("")) + struct trx_config { - std::string local_addr; - std::string remote_addr; - std::string dev_args; char* config_file; - unsigned port; - unsigned tx_sps; - unsigned rx_sps; - unsigned chans; - unsigned rtsc; - unsigned rach_delay; - bool extref; - bool gpsref; - FillerType filler; - bool mcbts; - double offset; - double rssi_offset; - bool swap_channels; - bool edge; - int sched_rr; - std::vector<std::string> rx_paths; - std::vector<std::string> tx_paths; }; volatile bool gshutdown = false; @@ -112,80 +73,6 @@ RadioInterface *radio; Transceiver *transceiver; -/* Setup configuration values - * Don't query the existence of the Log.Level because it's a - * mandatory value. That is, if it doesn't exist, the configuration - * table will crash or will have already crashed. Everything else we - * can survive without and use default values if the database entries - * are empty. - */ -bool trx_setup_config(struct trx_config *config) -{ - std::string refstr, fillstr, divstr, mcstr, edgestr; - std::vector<std::string>::const_iterator si; - - if (config->mcbts && config->chans > 5) { - std::cout << "Unsupported number of channels" << std::endl; - return false; - } - - edgestr = config->edge ? "Enabled" : "Disabled"; - mcstr = config->mcbts ? "Enabled" : "Disabled"; - - if (config->extref) - refstr = "External"; - else if (config->gpsref) - refstr = "GPS"; - else - refstr = "Internal"; - - switch (config->filler) { - case FILLER_DUMMY: - fillstr = "Dummy bursts"; - break; - case FILLER_ZERO: - fillstr = "Disabled"; - break; - case FILLER_NORM_RAND: - fillstr = "Normal busrts with random payload"; - break; - case FILLER_EDGE_RAND: - fillstr = "EDGE busrts with random payload"; - break; - case FILLER_ACCESS_RAND: - fillstr = "Access busrts with random payload"; - break; - } - - std::ostringstream ost(""); - ost << "Config Settings" << std::endl; - ost << " Device args............. " << config->dev_args << std::endl; - ost << " TRX Base Port........... " << config->port << std::endl; - ost << " TRX Address............. " << config->local_addr << std::endl; - ost << " GSM Core Address........." << config->remote_addr << std::endl; - ost << " Channels................ " << config->chans << std::endl; - ost << " Tx Samples-per-Symbol... " << config->tx_sps << std::endl; - ost << " Rx Samples-per-Symbol... " << config->rx_sps << std::endl; - ost << " EDGE support............ " << edgestr << std::endl; - ost << " Reference............... " << refstr << std::endl; - ost << " C0 Filler Table......... " << fillstr << std::endl; - ost << " Multi-Carrier........... " << mcstr << std::endl; - ost << " Tuning offset........... " << config->offset << std::endl; - ost << " RSSI to dBm offset...... " << config->rssi_offset << std::endl; - ost << " Swap channels........... " << config->swap_channels << std::endl; - ost << " Tx Antennas............."; - for (si = config->tx_paths.begin(); si != config->tx_paths.end(); ++si) - ost << " '" << ((*si != "") ? *si : "<default>") << "'"; - ost << std::endl; - ost << " Rx Antennas............."; - for (si = config->rx_paths.begin(); si != config->rx_paths.end(); ++si) - ost << " '" << ((*si != "") ? *si : "<default>") << "'"; - ost << std::endl; - - std::cout << ost << std::endl; - return true; -} - /* Create radio interface * The interface consists of sample rate changes, frequency shifts, * channel multiplexing, and other conversions. The transceiver core @@ -193,24 +80,24 @@ * The radio interface connects the main transceiver with the device * object, which may be operating some other rate. */ -RadioInterface *makeRadioInterface(struct trx_config *config, +RadioInterface *makeRadioInterface(struct trx_ctx *trx, RadioDevice *usrp, int type) { RadioInterface *radio = NULL; switch (type) { case RadioDevice::NORMAL: - radio = new RadioInterface(usrp, config->tx_sps, - config->rx_sps, config->chans); + radio = new RadioInterface(usrp, trx->cfg.tx_sps, + trx->cfg.rx_sps, trx->cfg.num_chans); break; case RadioDevice::RESAMP_64M: case RadioDevice::RESAMP_100M: - radio = new RadioInterfaceResamp(usrp, config->tx_sps, - config->rx_sps); + radio = new RadioInterfaceResamp(usrp, trx->cfg.tx_sps, + trx->cfg.rx_sps); break; case RadioDevice::MULTI_ARFCN: - radio = new RadioInterfaceMulti(usrp, config->tx_sps, - config->rx_sps, config->chans); + radio = new RadioInterfaceMulti(usrp, trx->cfg.tx_sps, + trx->cfg.rx_sps, trx->cfg.num_chans); break; default: LOG(ALERT) << "Unsupported radio interface configuration"; @@ -231,21 +118,21 @@ * and decoding schemes. Also included are the socket interfaces for * connecting to the upper layer stack. */ -int makeTransceiver(struct trx_config *config, RadioInterface *radio) +int makeTransceiver(struct trx_ctx *trx, RadioInterface *radio) { VectorFIFO *fifo; - transceiver = new Transceiver(config->port, config->local_addr.c_str(), - config->remote_addr.c_str(), config->tx_sps, - config->rx_sps, config->chans, GSM::Time(3,0), - radio, config->rssi_offset); - if (!transceiver->init(config->filler, config->rtsc, - config->rach_delay, config->edge)) { + transceiver = new Transceiver(trx->cfg.base_port, trx->cfg.bind_addr, + trx->cfg.remote_addr, trx->cfg.tx_sps, + trx->cfg.rx_sps, trx->cfg.num_chans, GSM::Time(3,0), + radio, trx->cfg.rssi_offset); + if (!transceiver->init(trx->cfg.filler, trx->cfg.rtsc, + trx->cfg.rach_delay, trx->cfg.egprs)) { LOG(ALERT) << "Failed to initialize transceiver"; return -1; } - for (size_t i = 0; i < config->chans; i++) { + for (size_t i = 0; i < trx->cfg.num_chans; i++) { fifo = radio->receiveFIFO(i); if (fifo && transceiver->receiveFIFO(fifo, i)) continue; @@ -253,7 +140,6 @@ LOG(ALERT) << "Could not attach FIFO to channel " << i; return -1; } - return 0; } @@ -290,194 +176,31 @@ osmo_init_ignore_signals(); } - -static std::vector<std::string> comma_delimited_to_vector(char* opt) { - std::string str = std::string(opt); - std::vector<std::string> result; - std::stringstream ss(str); - - while( ss.good() ) - { - std::string substr; - getline(ss, substr, ','); - result.push_back(substr); - } - return result; -} - static void print_help() { fprintf(stdout, "Options:\n" " -h This text\n" - " -a UHD device args\n" - " -i IP address of GSM core\n" - " -j IP address of osmo-trx\n" - " -p Base port number\n" - " -e Enable EDGE receiver\n" - " -m Enable multi-ARFCN transceiver (default=disabled)\n" - " -x Enable external 10 MHz reference\n" - " -g Enable GPSDO reference\n" - " -s Tx samples-per-symbol (1 or 4)\n" - " -b Rx samples-per-symbol (1 or 4)\n" - " -c Number of ARFCN channels (default=1)\n" - " -f Enable C0 filler table\n" - " -o Set baseband frequency offset (default=auto)\n" - " -r Random Normal Burst test mode with TSC\n" - " -A Random Access Burst test mode with delay\n" - " -R RSSI to dBm offset in dB (default=0)\n" - " -S Swap channels (UmTRX only)\n" - " -t SCHED_RR real-time priority (1..32)\n" - " -y comma-delimited list of Tx paths (num elements matches -c)\n" - " -z comma-delimited list of Rx paths (num elements matches -c)\n" + " -c Filename The config file to use\n" ); } static void handle_options(int argc, char **argv, struct trx_config *config) { int option; - bool tx_path_set = false, rx_path_set = false; - - config->local_addr = DEFAULT_TRX_IP; - config->remote_addr = DEFAULT_TRX_IP; config->config_file = (char *)DEFAULT_CONFIG_FILE; - config->port = DEFAULT_TRX_PORT; - config->tx_sps = DEFAULT_TX_SPS; - config->rx_sps = DEFAULT_RX_SPS; - config->chans = DEFAULT_CHANS; - config->rtsc = 0; - config->rach_delay = 0; - config->extref = false; - config->gpsref = false; - config->filler = FILLER_ZERO; - config->mcbts = false; - config->offset = 0.0; - config->rssi_offset = 0.0; - config->swap_channels = false; - config->edge = false; - config->sched_rr = -1; - config->tx_paths = std::vector<std::string>(DEFAULT_CHANS, ""); - config->rx_paths = std::vector<std::string>(DEFAULT_CHANS, ""); - while ((option = getopt(argc, argv, "ha:i:j:p:c:dmxgfo:s:b:r:A:R:Set:y:z:C:")) != -1) { + while ((option = getopt(argc, argv, "hc:")) != -1) { switch (option) { case 'h': print_help(); exit(0); break; - case 'a': - config->dev_args = optarg; - break; - case 'i': - config->remote_addr = optarg; - break; - case 'j': - config->local_addr = optarg; - break; - case 'p': - config->port = atoi(optarg); - break; case 'c': - config->chans = atoi(optarg); - break; - case 'm': - config->mcbts = true; - break; - case 'x': - config->extref = true; - break; - case 'g': - config->gpsref = true; - break; - case 'f': - config->filler = FILLER_DUMMY; - break; - case 'o': - config->offset = atof(optarg); - break; - case 's': - config->tx_sps = atoi(optarg); - break; - case 'b': - config->rx_sps = atoi(optarg); - break; - case 'r': - config->rtsc = atoi(optarg); - config->filler = FILLER_NORM_RAND; - break; - case 'A': - config->rach_delay = atoi(optarg); - config->filler = FILLER_ACCESS_RAND; - break; - case 'R': - config->rssi_offset = atof(optarg); - break; - case 'S': - config->swap_channels = true; - break; - case 'e': - config->edge = true; - break; - case 't': - config->sched_rr = atoi(optarg); - break; - case 'y': - config->tx_paths = comma_delimited_to_vector(optarg); - tx_path_set = true; - break; - case 'z': - config->rx_paths = comma_delimited_to_vector(optarg); - rx_path_set = true; - break; - case 'C': config->config_file = optarg; break; default: - print_help(); - exit(0); + goto bad_config; } - } - - /* Force 4 SPS for EDGE or multi-ARFCN configurations */ - if ((config->edge) || (config->mcbts)) { - config->tx_sps = 4; - config->rx_sps = 4; - } - - if (config->gpsref && config->extref) { - printf("External and GPSDO references unavailable at the same time\n\n"); - goto bad_config; - } - - if (config->edge && (config->filler == FILLER_NORM_RAND)) - config->filler = FILLER_EDGE_RAND; - - if ((config->tx_sps != 1) && (config->tx_sps != 4) && - (config->rx_sps != 1) && (config->rx_sps != 4)) { - printf("Unsupported samples-per-symbol %i\n\n", config->tx_sps); - goto bad_config; - } - - if (config->rtsc > 7) { - printf("Invalid training sequence %i\n\n", config->rtsc); - goto bad_config; - } - - if (config->rach_delay > 68) { - printf("RACH delay is too big %i\n\n", config->rach_delay); - goto bad_config; - } - - if (!tx_path_set) { - config->tx_paths = std::vector<std::string>(config->chans, ""); - } else if (config->tx_paths.size() != config->chans) { - printf("Num of channels and num of Tx Antennas doesn't match\n\n"); - goto bad_config; - } - if (!rx_path_set) { - config->rx_paths = std::vector<std::string>(config->chans, ""); - } else if (config->rx_paths.size() != config->chans) { - printf("Num of channels and num of Rx Antennas doesn't match\n\n"); - goto bad_config; } return; @@ -487,7 +210,24 @@ exit(0); } -static int set_sched_rr(int prio) +int trx_validate_config(struct trx_ctx *trx) +{ + if (trx->cfg.multi_arfcn && trx->cfg.num_chans > 5) { + std::cerr << "Unsupported number of channels" << std::endl; + return -1; + } + + /* Force 4 SPS for EDGE or multi-ARFCN configurations */ + if ((trx->cfg.egprs || trx->cfg.multi_arfcn) && + (trx->cfg.tx_sps!=4 || trx->cfg.tx_sps!=4)) { + std::cerr << "EDGE and Multi-Carrier options require 4 tx and rx sps. Check you config." << std::endl; + return -1; + } + + return 0; +} + +static int set_sched_rr(unsigned int prio) { struct sched_param param; int rc; @@ -502,6 +242,42 @@ return 0; } +static void print_config(struct trx_ctx *trx) +{ + unsigned int i; + std::ostringstream ost(""); + + ost << "Config Settings" << std::endl; + ost << " Device args............. " << charp2str(trx->cfg.dev_args) << std::endl; + ost << " TRX Base Port........... " << trx->cfg.base_port << std::endl; + ost << " TRX Address............. " << charp2str(trx->cfg.bind_addr) << std::endl; + ost << " GSM Core Address........." << charp2str(trx->cfg.remote_addr) << std::endl; + ost << " Channels................ " << trx->cfg.num_chans << std::endl; + ost << " Tx Samples-per-Symbol... " << trx->cfg.tx_sps << std::endl; + ost << " Rx Samples-per-Symbol... " << trx->cfg.rx_sps << std::endl; + ost << " EDGE support............ " << trx->cfg.egprs << std::endl; + ost << " Reference............... " << trx->cfg.clock_ref << std::endl; + ost << " C0 Filler Table......... " << trx->cfg.filler << std::endl; + ost << " Multi-Carrier........... " << trx->cfg.multi_arfcn << std::endl; + ost << " Tuning offset........... " << trx->cfg.offset << std::endl; + ost << " RSSI to dBm offset...... " << trx->cfg.rssi_offset << std::endl; + ost << " Swap channels........... " << trx->cfg.swap_channels << std::endl; + ost << " Tx Antennas............."; + for (i = 0; i < trx->cfg.num_chans; i++) { + std::string p = charp2str(trx->cfg.chans[i].tx_path); + ost << " '" << ((p != "") ? p : "<default>") << "'"; + } + ost << std::endl; + ost << " Rx Antennas............."; + for (i = 0; i < trx->cfg.num_chans; i++) { + std::string p = charp2str(trx->cfg.chans[i].rx_path); + ost << " '" << ((p != "") ? p : "<default>") << "'"; + } + ost << std::endl; + + std::cout << ost << std::endl; +} + static void trx_stop() { std::cout << "Shutting down transceiver..." << std::endl; @@ -511,37 +287,39 @@ delete usrp; } -static int trx_start(struct trx_config *config) +static int trx_start(struct trx_ctx *trx) { - int type, chans, ref; + int type, chans; + unsigned int i; + std::vector<std::string> rx_paths, tx_paths; RadioDevice::InterfaceType iface = RadioDevice::NORMAL; /* Create the low level device object */ - if (config->mcbts) + if (trx->cfg.multi_arfcn) iface = RadioDevice::MULTI_ARFCN; - if (config->extref) - ref = REF_EXTERNAL; - else if (config->gpsref) - ref = REF_GPS; - else - ref = REF_INTERNAL; + /* Generate vector of rx/tx_path: */ + for (i = 0; i < trx->cfg.num_chans; i++) { + rx_paths.push_back(charp2str(trx->cfg.chans[i].rx_path)); + tx_paths.push_back(charp2str(trx->cfg.chans[i].tx_path)); + } - usrp = RadioDevice::make(config->tx_sps, config->rx_sps, iface, - config->chans, config->offset, config->tx_paths, config->rx_paths); - type = usrp->open(config->dev_args, ref, config->swap_channels); + usrp = RadioDevice::make(trx->cfg.tx_sps, trx->cfg.rx_sps, iface, + trx->cfg.num_chans, trx->cfg.offset, + tx_paths, rx_paths); + type = usrp->open(charp2str(trx->cfg.dev_args), trx->cfg.clock_ref, trx->cfg.swap_channels); if (type < 0) { LOG(ALERT) << "Failed to create radio device" << std::endl; goto shutdown; } /* Setup the appropriate device interface */ - radio = makeRadioInterface(config, usrp, type); + radio = makeRadioInterface(trx, usrp, type); if (!radio) goto shutdown; /* Create the transceiver core */ - if(makeTransceiver(config, radio) < 0) + if(makeTransceiver(trx, radio) < 0) goto shutdown; chans = transceiver->numChans(); @@ -625,20 +403,22 @@ exit(1); } - if (config.sched_rr != -1) { - if (set_sched_rr(config.sched_rr) < 0) - return EXIT_FAILURE; - } + print_config(g_trx_ctx); /* Check database sanity */ - if (!trx_setup_config(&config)) { - std::cerr << "Config: Database failure - exiting" << std::endl; + if (trx_validate_config(g_trx_ctx) < 0) { + std::cerr << "Config failure - exiting" << std::endl; return EXIT_FAILURE; + } + + if (g_trx_ctx->cfg.sched_rr) { + if (set_sched_rr(g_trx_ctx->cfg.sched_rr) < 0) + return EXIT_FAILURE; } srandom(time(NULL)); - if(trx_start(&config) < 0) + if(trx_start(g_trx_ctx) < 0) return EXIT_FAILURE; while (!gshutdown) -- To view, visit https://gerrit.osmocom.org/6651 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib8de1a5da4b3c0b6a49e00033f616e1d66656adf Gerrit-PatchSet: 1 Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>