lists.osmocom.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
June
May
April
March
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
List overview
Download
gerrit-log
July 2023
----- 2025 -----
June 2025
May 2025
April 2025
March 2025
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
gerrit-log@lists.osmocom.org
1 participants
3051 discussions
Start a n
N
ew thread
[S] Change in osmo-trx[master]: ms: drop the tx burst padding
by Hoernchen
Attention is currently required from: laforge, fixeria. Hoernchen has posted comments on this change. (
https://gerrit.osmocom.org/c/osmo-trx/+/33926
) Change subject: ms: drop the tx burst padding ...................................................................... Patch Set 3: Code-Review+2 -- To view, visit
https://gerrit.osmocom.org/c/osmo-trx/+/33926
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: Ied5c3ab5dde975e11b0ef6d9cbc86be19173c4e8 Gerrit-Change-Number: 33926 Gerrit-PatchSet: 3 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-Attention: laforge <laforge(a)osmocom.org> Gerrit-Attention: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Comment-Date: Fri, 28 Jul 2023 12:19:37 +0000 Gerrit-HasComments: No Gerrit-Has-Labels: Yes Gerrit-MessageType: comment
1 year, 11 months
1
0
0
0
[S] Change in osmo-trx[master]: ms: fix blocking logging
by Hoernchen
Hoernchen has submitted this change. (
https://gerrit.osmocom.org/c/osmo-trx/+/33558
) ( 3 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: ms: fix blocking logging ...................................................................... ms: fix blocking logging Change-Id: I0f5dcb13d1bd9e626e1eeab6ca767ca1b5ae43b8 --- M Transceiver52M/ms/logging.c 1 file changed, 10 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/Transceiver52M/ms/logging.c b/Transceiver52M/ms/logging.c index 9ee0738..ee59299 100644 --- a/Transceiver52M/ms/logging.c +++ b/Transceiver52M/ms/logging.c @@ -76,6 +76,7 @@ void trxc_log_init(void *tallctx) { osmo_init_logging2(tallctx, &trxcon_log_info); + log_target_file_switch_to_wqueue(osmo_stderr_target); trxcon_set_log_cfg(&trxcon_log_cfg[0], ARRAY_SIZE(trxcon_log_cfg)); } -- To view, visit
https://gerrit.osmocom.org/c/osmo-trx/+/33558
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I0f5dcb13d1bd9e626e1eeab6ca767ca1b5ae43b8 Gerrit-Change-Number: 33558 Gerrit-PatchSet: 5 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[M] Change in osmo-trx[master]: devices: add freq/gain override for uhd
by Hoernchen
Hoernchen has submitted this change. (
https://gerrit.osmocom.org/c/osmo-trx/+/32764
) Change subject: devices: add freq/gain override for uhd ...................................................................... devices: add freq/gain override for uhd This allows using arbitrary gain and frequencies. Change-Id: I3c1b9a067cafc6d696b9aa2da8ee0480ec1e094f --- M CommonLibs/config_defs.h M CommonLibs/trx_vty.c M Transceiver52M/device/uhd/UHDDevice.cpp 3 files changed, 122 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved diff --git a/CommonLibs/config_defs.h b/CommonLibs/config_defs.h index 33be73f..bf49bcf 100644 --- a/CommonLibs/config_defs.h +++ b/CommonLibs/config_defs.h @@ -57,4 +57,14 @@ unsigned int stack_size; unsigned int num_chans; struct trx_chan chans[TRX_CHAN_MAX]; + struct { + bool ul_freq_override; + bool dl_freq_override; + bool ul_gain_override; + bool dl_gain_override; + double ul_freq; + double dl_freq; + double ul_gain; + double dl_gain; + } overrides; }; diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c index 6724189..1878d83 100644 --- a/CommonLibs/trx_vty.c +++ b/CommonLibs/trx_vty.c @@ -285,6 +285,60 @@ return CMD_SUCCESS; } +DEFUN_ATTR(cfg_ul_freq_override, cfg_ul_freq_override_cmd, + "ul-freq-override FLOAT", + "Overrides Rx carrier frequency\n" + "Frequency in Hz (e.g. 145300000)\n", + CMD_ATTR_HIDDEN) +{ + struct trx_ctx *trx = trx_from_vty(vty); + + trx->cfg.overrides.ul_freq_override = true; + trx->cfg.overrides.ul_freq = atof(argv[0]); + + return CMD_SUCCESS; +} +DEFUN_ATTR(cfg_dl_freq_override, cfg_dl_freq_override_cmd, + "dl-freq-override FLOAT", + "Overrides Tx carrier frequency\n" + "Frequency in Hz (e.g. 145300000)\n", + CMD_ATTR_HIDDEN) +{ + struct trx_ctx *trx = trx_from_vty(vty); + + trx->cfg.overrides.dl_freq_override = true; + trx->cfg.overrides.dl_freq = atof(argv[0]); + + return CMD_SUCCESS; +} + +DEFUN_ATTR(cfg_ul_gain_override, cfg_ul_gain_override_cmd, + "ul-gain-override FLOAT", + "Overrides Rx gain\n" + "gain in dB\n", + CMD_ATTR_HIDDEN) +{ + struct trx_ctx *trx = trx_from_vty(vty); + + trx->cfg.overrides.ul_gain_override = true; + trx->cfg.overrides.ul_gain = atof(argv[0]); + + return CMD_SUCCESS; +} +DEFUN_ATTR(cfg_dl_gain_override, cfg_dl_gain_override_cmd, + "dl-gain-override FLOAT", + "Overrides Tx gain\n" + "gain in dB\n", + CMD_ATTR_HIDDEN) +{ + struct trx_ctx *trx = trx_from_vty(vty); + + trx->cfg.overrides.dl_gain_override = true; + trx->cfg.overrides.dl_gain = atof(argv[0]); + + return CMD_SUCCESS; +} + DEFUN(cfg_swap_channels, cfg_swap_channels_cmd, "swap-channels (disable|enable)", "Swap primary and secondary channels of the PHY (if any)\n" @@ -638,6 +692,14 @@ vty_out(vty, " stack-size %u%s", trx->cfg.stack_size, VTY_NEWLINE); if (trx->cfg.ul_fn_offset != 0) vty_out(vty, " ul-fn-offset %d%s", trx->cfg.ul_fn_offset, VTY_NEWLINE); + if (trx->cfg.overrides.dl_freq_override) + vty_out(vty, " dl-freq-override %f%s", trx->cfg.overrides.dl_freq, VTY_NEWLINE); + if (trx->cfg.overrides.ul_freq_override) + vty_out(vty, " ul-freq-override %f%s", trx->cfg.overrides.ul_freq, VTY_NEWLINE); + if (trx->cfg.overrides.dl_gain_override) + vty_out(vty, " dl-gain-override %f%s", trx->cfg.overrides.dl_gain, VTY_NEWLINE); + if (trx->cfg.overrides.ul_gain_override) + vty_out(vty, " ul-gain-override %f%s", trx->cfg.overrides.ul_gain, VTY_NEWLINE); trx_rate_ctr_threshold_write_config(vty, " "); for (i = 0; i < trx->cfg.num_chans; i++) { @@ -803,6 +865,10 @@ install_element(TRX_NODE, &cfg_chan_cmd); install_element(TRX_NODE, &cfg_ul_fn_offset_cmd); + install_element(TRX_NODE, &cfg_ul_freq_override_cmd); + install_element(TRX_NODE, &cfg_dl_freq_override_cmd); + install_element(TRX_NODE, &cfg_ul_gain_override_cmd); + install_element(TRX_NODE, &cfg_dl_gain_override_cmd); install_node(&chan_node, dummy_config_write); install_element(CHAN_NODE, &cfg_chan_rx_path_cmd); install_element(CHAN_NODE, &cfg_chan_tx_path_cmd); diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index 95ea8e7..ec772aa 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -295,6 +295,9 @@ return 0.0f; } + if (cfg->overrides.ul_gain_override) + return rx_gains[chan]; + usrp_dev->set_rx_gain(db, chan); rx_gains[chan] = usrp_dev->get_rx_gain(chan); @@ -337,6 +340,9 @@ return 0.0f; } + if (cfg->overrides.dl_gain_override) + return atten; // ensures caller does not apply digital attenuation + get_dev_band_desc(desc); tx_power = desc.nom_out_tx_power - atten; db = TxPower2TxGain(desc, tx_power); @@ -626,6 +632,32 @@ // Print configuration LOGC(DDEV, INFO) << "Device configuration: " << usrp_dev->get_pp_string(); + if (cfg->overrides.dl_freq_override) { + uhd::tune_request_t treq_tx = uhd::tune_request_t(cfg->overrides.dl_freq, 0); + auto tres = usrp_dev->set_tx_freq(treq_tx, 0); + tx_freqs[0] = usrp_dev->get_tx_freq(0); + LOGCHAN(0, DDEV, INFO) << "OVERRIDE set_freq(" << tx_freqs[0] << ", TX): " << tres.to_pp_string() << std::endl; + } + + if (cfg->overrides.ul_freq_override) { + uhd::tune_request_t treq_rx = uhd::tune_request_t(cfg->overrides.ul_freq, 0); + auto tres = usrp_dev->set_rx_freq(treq_rx, 0); + rx_freqs[0] = usrp_dev->get_rx_freq(0); + LOGCHAN(0, DDEV, INFO) << "OVERRIDE set_freq(" << rx_freqs[0] << ", RX): " << tres.to_pp_string() << std::endl; + } + + if (cfg->overrides.ul_gain_override) { + usrp_dev->set_rx_gain(cfg->overrides.ul_gain, 0); + rx_gains[0] = usrp_dev->get_rx_gain(0); + LOGCHAN(0, DDEV, INFO) << " OVERRIDE RX gain:" << rx_gains[0] << std::endl; + } + + if (cfg->overrides.dl_gain_override) { + usrp_dev->set_tx_gain(cfg->overrides.dl_gain, 0); + tx_gains[0] = usrp_dev->get_tx_gain(0); + LOGCHAN(0, DDEV, INFO) << " OVERRIDE TX gain:" << tx_gains[0] << std::endl; + } + if (iface == MULTI_ARFCN) return MULTI_ARFCN; @@ -978,6 +1010,9 @@ uhd::tune_result_t tres; std::string str_dir = tx ? "Tx" : "Rx"; + if (cfg->overrides.dl_freq_override || cfg->overrides.ul_freq_override) + return true; + if (!update_band_from_freq(freq, chan, tx)) return false; -- To view, visit
https://gerrit.osmocom.org/c/osmo-trx/+/32764
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I3c1b9a067cafc6d696b9aa2da8ee0480ec1e094f Gerrit-Change-Number: 32764 Gerrit-PatchSet: 11 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[L] Change in osmo-trx[master]: devices: unify band handling
by Hoernchen
Hoernchen has submitted this change. (
https://gerrit.osmocom.org/c/osmo-trx/+/32763
) ( 10 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: devices: unify band handling ...................................................................... devices: unify band handling This is basically common, but optional code. Change-Id: I64f5a462451e967d4750d8e4f1d5832cbab41cff --- M Transceiver52M/device/bladerf/bladerf.cpp M Transceiver52M/device/bladerf/bladerf.h M Transceiver52M/device/common/Makefile.am A Transceiver52M/device/common/bandmanager.h M Transceiver52M/device/lms/LMSDevice.cpp M Transceiver52M/device/lms/LMSDevice.h M Transceiver52M/device/uhd/UHDDevice.cpp M Transceiver52M/device/uhd/UHDDevice.h 8 files changed, 242 insertions(+), 326 deletions(-) Approvals: pespin: Looks good to me, but someone else must approve laforge: Looks good to me, approved Jenkins Builder: Verified fixeria: Looks good to me, but someone else must approve diff --git a/Transceiver52M/device/bladerf/bladerf.cpp b/Transceiver52M/device/bladerf/bladerf.cpp index 3d9aab9..3e830b1 100644 --- a/Transceiver52M/device/bladerf/bladerf.cpp +++ b/Transceiver52M/device/bladerf/bladerf.cpp @@ -47,25 +47,11 @@ LOGC(DDEV, ERROR) << bladerf_strerror(status); \ } -/* Device Type, Tx-SPS, Rx-SPS */ -typedef std::tuple<blade_dev_type, int, int> dev_key; - -/* Device parameter descriptor */ -struct dev_desc { - unsigned channels; - double mcr; - double rate; - double offset; - std::string str; -}; - -static const std::map<dev_key, dev_desc> dev_param_map{ +static const dev_map_t dev_param_map{ { std::make_tuple(blade_dev_type::BLADE2, 4, 4), { 1, 26e6, GSMRATE, B2XX_TIMING_4_4SPS, "B200 4 SPS" } }, }; -typedef std::tuple<blade_dev_type, enum gsm_band> dev_band_key; -typedef std::map<dev_band_key, dev_band_desc>::const_iterator dev_band_map_it; -static const std::map<dev_band_key, dev_band_desc> dev_band_nom_power_param_map{ +static const power_map_t dev_band_nom_power_param_map{ { std::make_tuple(blade_dev_type::BLADE2, GSM_BAND_850), { 89.75, 13.3, -7.5 } }, { std::make_tuple(blade_dev_type::BLADE2, GSM_BAND_900), { 89.75, 13.3, -7.5 } }, { std::make_tuple(blade_dev_type::BLADE2, GSM_BAND_1800), { 89.75, 7.5, -11.0 } }, @@ -85,9 +71,9 @@ } blade_device::blade_device(InterfaceType iface, const struct trx_cfg *cfg) - : RadioDevice(iface, cfg), dev(nullptr), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false), - band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0), - ts_initial(0), ts_offset(0), async_event_thrd(NULL) + : RadioDevice(iface, cfg), band_manager(dev_band_nom_power_param_map, dev_param_map), dev(nullptr), + rx_gain_min(0.0), rx_gain_max(0.0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), + prev_ts(0), ts_initial(0), ts_offset(0), async_event_thrd(NULL) { } @@ -104,47 +90,6 @@ delete rx_buffers[i]; } -void blade_device::assign_band_desc(enum gsm_band req_band) -{ - dev_band_map_it it; - - it = dev_band_nom_power_param_map.find(dev_band_key(dev_type, req_band)); - if (it == dev_band_nom_power_param_map.end()) { - dev_desc desc = dev_param_map.at(dev_key(dev_type, tx_sps, rx_sps)); - LOGC(DDEV, ERROR) << "No Power parameters exist for device " << desc.str << " on band " - << gsm_band_name(req_band) << ", using B210 ones as fallback"; - it = dev_band_nom_power_param_map.find(dev_band_key(blade_dev_type::BLADE2, req_band)); - } - OSMO_ASSERT(it != dev_band_nom_power_param_map.end()) - band_desc = it->second; -} - -bool blade_device::set_band(enum gsm_band req_band) -{ - if (band_ass_curr_sess && req_band != band) { - LOGC(DDEV, ALERT) << "Requesting band " << gsm_band_name(req_band) << " different from previous band " - << gsm_band_name(band); - return false; - } - - if (req_band != band) { - band = req_band; - assign_band_desc(band); - } - band_ass_curr_sess = true; - return true; -} - -void blade_device::get_dev_band_desc(dev_band_desc &desc) -{ - if (band == 0) { - LOGC(DDEV, ERROR) - << "Power parameters requested before Tx Frequency was set! Providing band 900 by default..."; - assign_band_desc(GSM_BAND_900); - } - desc = band_desc; -} - void blade_device::init_gains() { double tx_gain_min, tx_gain_max; @@ -457,7 +402,7 @@ for (size_t i = 0; i < rx_buffers.size(); i++) rx_buffers[i]->reset(); - band_ass_curr_sess = false; + band_reset(); started = false; return true; @@ -580,27 +525,13 @@ bool blade_device::setTxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - if (chan >= tx_freqs.size()) { LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan; return false; } ScopedLock lock(tune_lock); - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 0); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Tx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) - << "Unknown GSM band for Tx Frequency " << wFreq << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) + if (!update_band_from_freq(wFreq, chan, true)) return false; if (!set_freq(wFreq, chan, true)) @@ -611,27 +542,13 @@ bool blade_device::setRxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - if (chan >= rx_freqs.size()) { LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan; return false; } ScopedLock lock(tune_lock); - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 1); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) - << "Unknown GSM band for Rx Frequency " << wFreq << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) + if (!update_band_from_freq(wFreq, chan, false)) return false; return set_freq(wFreq, chan, false); diff --git a/Transceiver52M/device/bladerf/bladerf.h b/Transceiver52M/device/bladerf/bladerf.h index 4db2569..e32581e 100644 --- a/Transceiver52M/device/bladerf/bladerf.h +++ b/Transceiver52M/device/bladerf/bladerf.h @@ -22,10 +22,12 @@ #pragma once +#include <map> #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "bandmanager.h" #include "radioDevice.h" #include "smpl_buf.h" @@ -33,8 +35,6 @@ #include <osmocom/gsm/gsm_utils.h> } -#include <bladerf.h> - enum class blade_dev_type { BLADE1, BLADE2 }; struct dev_band_desc { @@ -52,7 +52,21 @@ double rxgain2rssioffset_rel; /* dB */ }; -class blade_device : public RadioDevice { +/* Device parameter descriptor */ +struct dev_desc { + unsigned channels; + double mcr; + double rate; + double offset; + std::string desc_str; +}; + +using dev_key = std::tuple<blade_dev_type, int, int>; +using dev_band_key = std::tuple<blade_dev_type, enum gsm_band>; +using power_map_t = std::map<dev_band_key, dev_band_desc>; +using dev_map_t = std::map<dev_key, dev_desc>; + +class blade_device : public RadioDevice, public band_manager<power_map_t, dev_map_t> { public: blade_device(InterfaceType iface, const struct trx_cfg *cfg); ~blade_device(); @@ -153,9 +167,6 @@ std::vector<double> tx_gains, rx_gains; std::vector<double> tx_freqs, rx_freqs; - bool band_ass_curr_sess; /* true if "band" was set after last POWEROFF */ - enum gsm_band band; - struct dev_band_desc band_desc; size_t tx_spp, rx_spp; bool started; @@ -178,9 +189,6 @@ bool flush_recv(size_t num_pkts); bool set_freq(double freq, size_t chan, bool tx); - void get_dev_band_desc(dev_band_desc &desc); - bool set_band(enum gsm_band req_band); - void assign_band_desc(enum gsm_band req_band); Thread *async_event_thrd; Mutex tune_lock; diff --git a/Transceiver52M/device/common/Makefile.am b/Transceiver52M/device/common/Makefile.am index 4d29e98..1a33592 100644 --- a/Transceiver52M/device/common/Makefile.am +++ b/Transceiver52M/device/common/Makefile.am @@ -4,7 +4,7 @@ AM_CXXFLAGS = -lpthread $(LIBOSMOCORE_CFLAGS) -noinst_HEADERS = radioDevice.h smpl_buf.h +noinst_HEADERS = radioDevice.h smpl_buf.h bandmanager.h noinst_LTLIBRARIES = libdevice_common.la diff --git a/Transceiver52M/device/common/bandmanager.h b/Transceiver52M/device/common/bandmanager.h new file mode 100644 index 0000000..a198937 --- /dev/null +++ b/Transceiver52M/device/common/bandmanager.h @@ -0,0 +1,133 @@ +#pragma once +/* + * (C) 2022 by sysmocom s.f.m.c. GmbH <info(a)sysmocom.de> + * All Rights Reserved + * + * Author: Eric Wild <ewild(a)sysmocom.de> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <
http://www.gnu.org/licenses/
>. + * + */ + +#include <string> +#include <tuple> + +#include "Logger.h" + +extern "C" { +#include <osmocom/gsm/gsm_utils.h> +} + +template <typename powermapt, typename devmapt> +class band_manager { + using powerkeyt = typename powermapt::key_type; + using powermappedt = typename powermapt::mapped_type; + using devkeyt = typename devmapt::key_type; + const devkeyt &m_dev_type; + const powermapt &m_power_map; + const devmapt &m_dev_map; + powerkeyt m_fallback; + enum gsm_band m_band; + powermappedt m_band_desc; + bool band_ass_curr_sess{}; /* true if "band" was set after last POWEROFF */ + + // looks up either first tuple element (->enum) or straight enum + template <typename T, typename std::enable_if<std::is_enum<T>::value>::type *dummy = nullptr> + auto key_helper(T &t) -> T + { + return t; + } + + template <typename T> + auto key_helper(T t) -> typename std::tuple_element<0, T>::type + { + return std::get<0>(t); + } + + void assign_band_desc(enum gsm_band req_band) + { + auto key = key_helper(m_dev_type); + auto fallback_key = key_helper(m_fallback); + auto it = m_power_map.find({ key, req_band }); + if (it == m_power_map.end()) { + auto desc = m_dev_map.at(m_dev_type); + LOGC(DDEV, ERROR) << "No Tx Power measurements exist for device " << desc.desc_str + << " on band " << gsm_band_name(req_band) << ", using fallback.."; + it = m_power_map.find({ fallback_key, req_band }); + } + OSMO_ASSERT(it != m_power_map.end()); + m_band_desc = it->second; + } + + bool set_band(enum gsm_band req_band) + { + if (band_ass_curr_sess && req_band != m_band) { + LOGC(DDEV, ALERT) << "Requesting band " << gsm_band_name(req_band) + << " different from previous band " << gsm_band_name(m_band); + return false; + } + + if (req_band != m_band) { + m_band = req_band; + assign_band_desc(m_band); + } + band_ass_curr_sess = true; + return true; + } + + public: + band_manager(const devkeyt &dev_type, const powermapt &power_map, const devmapt &dev_map, powerkeyt fallback) + : m_dev_type(dev_type), m_power_map(power_map), m_dev_map(dev_map), m_fallback(fallback), + m_band((enum gsm_band)0) + { + } + band_manager(const powermapt &power_map, const devmapt &dev_map) + : m_dev_type(dev_map.begin()->first), m_power_map(power_map), m_dev_map(dev_map), + m_fallback(m_power_map.begin()->first), m_band((enum gsm_band)0) + { + } + void band_reset() + { + band_ass_curr_sess = false; + } + + void get_dev_band_desc(powermappedt &desc) + { + if (m_band == 0) { + LOGC(DDEV, ERROR) + << "Power parameters requested before Tx Frequency was set! Providing band 900 by default..."; + assign_band_desc(GSM_BAND_900); + } + desc = m_band_desc; + } + + bool update_band_from_freq(double wFreq, int chan, bool is_tx) + { + enum gsm_band req_band; + auto dirstr = is_tx ? "Tx" : "Rx"; + auto req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, !is_tx); + if (req_arfcn == 0xffff) { + LOGCHAN(chan, DDEV, ALERT) + << "Unknown ARFCN for " << dirstr << " Frequency " << wFreq / 1000 << " kHz"; + return false; + } + if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { + LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for " << dirstr << " Frequency " << wFreq + << " Hz (ARFCN " << req_arfcn << " )"; + return false; + } + + return set_band(req_band); + } +}; \ No newline at end of file diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index e336e77..451d2b9 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -52,39 +52,16 @@ #define LMS_DEV_SDR_MINI_PREFIX_NAME "LimeSDR-Mini" #define LMS_DEV_NET_MICRO_PREFIX_NAME "LimeNET-Micro" -/* Device parameter descriptor */ -struct dev_desc { - /* Does LimeSuite allow switching the clock source for this device? - * LimeSDR-Mini does not have switches but needs soldering to select - * external/internal clock. Any call to LMS_SetClockFreq() will fail. - */ - bool clock_src_switchable; - /* Does LimeSuite allow using REF_INTERNAL for this device? - * LimeNET-Micro does not like selecting internal clock - */ - bool clock_src_int_usable; - /* Sample rate coef (without having TX/RX samples per symbol into account) */ - double rate; - /* Sample rate coef (without having TX/RX samples per symbol into account), if multi-arfcn is enabled */ - double rate_multiarfcn; - /* Coefficient multiplied by TX sample rate in order to shift Tx time */ - double ts_offset_coef; - /* Coefficient multiplied by TX sample rate in order to shift Tx time, if multi-arfcn is enabled */ - double ts_offset_coef_multiarfcn; - /* Device Name Prefix as presented by LimeSuite API LMS_GetDeviceInfo() */ - std::string name_prefix; -}; -static const std::map<enum lms_dev_type, struct dev_desc> dev_param_map { + +static const dev_map_t dev_param_map { { LMS_DEV_SDR_USB, { true, true, GSMRATE, MCBTS_SPACING, 8.9e-5, 7.9e-5, LMS_DEV_SDR_USB_PREFIX_NAME } }, { LMS_DEV_SDR_MINI, { false, true, GSMRATE, MCBTS_SPACING, 8.9e-5, 8.2e-5, LMS_DEV_SDR_MINI_PREFIX_NAME } }, { LMS_DEV_NET_MICRO, { true, false, GSMRATE, MCBTS_SPACING, 8.9e-5, 7.9e-5, LMS_DEV_NET_MICRO_PREFIX_NAME } }, { LMS_DEV_UNKNOWN, { true, true, GSMRATE, MCBTS_SPACING, 8.9e-5, 7.9e-5, "UNKNOWN" } }, }; -typedef std::tuple<lms_dev_type, enum gsm_band> dev_band_key; -typedef std::map<dev_band_key, dev_band_desc>::const_iterator dev_band_map_it; -static const std::map<dev_band_key, dev_band_desc> dev_band_nom_power_param_map { +static const power_map_t dev_band_nom_power_param_map { { std::make_tuple(LMS_DEV_SDR_USB, GSM_BAND_850), { 73.0, 11.2, -6.0 } }, { std::make_tuple(LMS_DEV_SDR_USB, GSM_BAND_900), { 73.0, 10.8, -6.0 } }, { std::make_tuple(LMS_DEV_SDR_USB, GSM_BAND_1800), { 65.0, -3.5, -17.0 } }, /* FIXME: OS#4583: 1800Mhz is failing above TxGain=65, which is around -3.5dBm (already < 0 dBm) */ @@ -122,8 +99,8 @@ enum lms_dev_type dev_type = it->first; struct dev_desc desc = it->second; - if (strncmp(device_info->deviceName, desc.name_prefix.c_str(), desc.name_prefix.length()) == 0) { - LOGC(DDEV, INFO) << "Device identified as " << desc.name_prefix; + if (strncmp(device_info->deviceName, desc.desc_str.c_str(), desc.desc_str.length()) == 0) { + LOGC(DDEV, INFO) << "Device identified as " << desc.desc_str; return dev_type; } it++; @@ -132,8 +109,9 @@ } LMSDevice::LMSDevice(InterfaceType iface, const struct trx_cfg *cfg) - : RadioDevice(iface, cfg), m_lms_dev(NULL), started(false), band_ass_curr_sess(false), band((enum gsm_band)0), - m_dev_type(LMS_DEV_UNKNOWN) + : RadioDevice(iface, cfg), + band_manager(m_dev_type, dev_band_nom_power_param_map, dev_param_map, {LMS_DEV_SDR_USB, GSM_BAND_850}), m_lms_dev(NULL), + started(false), m_dev_type(LMS_DEV_UNKNOWN) { LOGC(DDEV, INFO) << "creating LMS device..."; @@ -220,47 +198,6 @@ return -1; } -void LMSDevice::assign_band_desc(enum gsm_band req_band) -{ - dev_band_map_it it; - - it = dev_band_nom_power_param_map.find(dev_band_key(m_dev_type, req_band)); - if (it == dev_band_nom_power_param_map.end()) { - dev_desc desc = dev_param_map.at(m_dev_type); - LOGC(DDEV, ERROR) << "No Tx Power measurements exist for device " - << desc.name_prefix << " on band " << gsm_band_name(req_band) - << ", using LimeSDR-USB ones as fallback"; - it = dev_band_nom_power_param_map.find(dev_band_key(LMS_DEV_SDR_USB, req_band)); - } - OSMO_ASSERT(it != dev_band_nom_power_param_map.end()); - band_desc = it->second; -} - -bool LMSDevice::set_band(enum gsm_band req_band) -{ - if (band_ass_curr_sess && req_band != band) { - LOGC(DDEV, ALERT) << "Requesting band " << gsm_band_name(req_band) - << " different from previous band " << gsm_band_name(band); - return false; - } - - if (req_band != band) { - band = req_band; - assign_band_desc(band); - } - band_ass_curr_sess = true; - return true; -} - -void LMSDevice::get_dev_band_desc(dev_band_desc& desc) -{ - if (band == 0) { - LOGC(DDEV, ERROR) << "Power parameters requested before Tx Frequency was set! Providing band 900 by default..."; - assign_band_desc(GSM_BAND_900); - } - desc = band_desc; -} - int LMSDevice::open() { lms_info_str_t* info_list; @@ -466,7 +403,7 @@ LMS_DestroyStream(m_lms_dev, &m_lms_stream_rx[i]); } - band_ass_curr_sess = false; + band_reset(); started = false; return true; @@ -483,8 +420,8 @@ break; case REF_INTERNAL: if (!dev_desc.clock_src_int_usable) { - LOGC(DDEV, ERROR) << "Device type " << dev_desc.name_prefix - << " doesn't support internal reference clock"; + LOGC(DDEV, ERROR) + << "Device type " << dev_desc.desc_str << " doesn't support internal reference clock"; return false; } /* According to lms using LMS_CLOCK_EXTREF with a @@ -502,8 +439,8 @@ if (LMS_SetClockFreq(m_lms_dev, lms_clk_id, freq) < 0) return false; } else { - LOGC(DDEV, INFO) << "Device type " << dev_desc.name_prefix - << " doesn't support switching clock source through SW"; + LOGC(DDEV, INFO) + << "Device type " << dev_desc.desc_str << " doesn't support switching clock source through SW"; } return true; @@ -996,9 +933,6 @@ bool LMSDevice::setTxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - if (chan >= chans) { LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan; return false; @@ -1006,18 +940,7 @@ LOGCHAN(chan, DDEV, NOTICE) << "Setting Tx Freq to " << wFreq << " Hz"; - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100 , 0); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Tx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Tx Frequency " << wFreq - << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) + if (!update_band_from_freq(wFreq, chan, true)) return false; if (LMS_SetLOFrequency(m_lms_dev, LMS_CH_TX, chan, wFreq) < 0) { @@ -1030,23 +953,9 @@ bool LMSDevice::setRxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - LOGCHAN(chan, DDEV, NOTICE) << "Setting Rx Freq to " << wFreq << " Hz"; - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 1); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Rx Frequency " << wFreq - << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) + if (!update_band_from_freq(wFreq, chan, false)) return false; if (LMS_SetLOFrequency(m_lms_dev, LMS_CH_RX, chan, wFreq) < 0) { diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h index 75d11cf..2e5ca4c 100644 --- a/Transceiver52M/device/lms/LMSDevice.h +++ b/Transceiver52M/device/lms/LMSDevice.h @@ -18,11 +18,13 @@ #ifndef _LMS_DEVICE_H_ #define _LMS_DEVICE_H_ +#include <map> #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "radioDevice.h" +#include "bandmanager.h" #include "smpl_buf.h" #include <sys/time.h> @@ -69,8 +71,35 @@ double rxgain2rssioffset_rel; /* dB */ }; +/* Device parameter descriptor */ +struct dev_desc { + /* Does LimeSuite allow switching the clock source for this device? + * LimeSDR-Mini does not have switches but needs soldering to select + * external/internal clock. Any call to LMS_SetClockFreq() will fail. + */ + bool clock_src_switchable; + /* Does LimeSuite allow using REF_INTERNAL for this device? + * LimeNET-Micro does not like selecting internal clock + */ + bool clock_src_int_usable; + /* Sample rate coef (without having TX/RX samples per symbol into account) */ + double rate; + /* Sample rate coef (without having TX/RX samples per symbol into account), if multi-arfcn is enabled */ + double rate_multiarfcn; + /* Coefficient multiplied by TX sample rate in order to shift Tx time */ + double ts_offset_coef; + /* Coefficient multiplied by TX sample rate in order to shift Tx time, if multi-arfcn is enabled */ + double ts_offset_coef_multiarfcn; + /* Device Name Prefix as presented by LimeSuite API LMS_GetDeviceInfo() */ + std::string desc_str; +}; + +using dev_band_key_t = std::tuple<lms_dev_type, gsm_band>; +using power_map_t = std::map<dev_band_key_t, dev_band_desc>; +using dev_map_t = std::map<lms_dev_type, struct dev_desc>; + /** A class to handle a LimeSuite supported device */ -class LMSDevice:public RadioDevice { +class LMSDevice:public RadioDevice, public band_manager<power_map_t, dev_map_t> { private: lms_device_t *m_lms_dev; @@ -87,9 +116,6 @@ TIMESTAMP ts_initial, ts_offset; std::vector<double> tx_gains, rx_gains; - bool band_ass_curr_sess; /* true if "band" was set after last POWEROFF */ - enum gsm_band band; - struct dev_band_desc band_desc; enum lms_dev_type m_dev_type; @@ -101,9 +127,6 @@ void update_stream_stats_rx(size_t chan, bool *overrun); void update_stream_stats_tx(size_t chan, bool *underrun); bool do_clock_src_freq(enum ReferenceType ref, double freq); - void get_dev_band_desc(dev_band_desc& desc); - bool set_band(enum gsm_band req_band); - void assign_band_desc(enum gsm_band req_band); public: /** Object constructor */ diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index a0021db..95ea8e7 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -91,19 +91,7 @@ * USRP1 with timestamps is not supported by UHD. */ -/* Device Type, Tx-SPS, Rx-SPS */ -typedef std::tuple<uhd_dev_type, int, int> dev_key; - -/* Device parameter descriptor */ -struct dev_desc { - unsigned channels; - double mcr; - double rate; - double offset; - std::string str; -}; - -static const std::map<dev_key, dev_desc> dev_param_map { +static const dev_map_t dev_param_map { { std::make_tuple(USRP2, 1, 1), { 1, 0.0, 390625, 1.2184e-4, "N2XX 1 SPS" } }, { std::make_tuple(USRP2, 4, 1), { 1, 0.0, 390625, 7.6547e-5, "N2XX 4/1 Tx/Rx SPS" } }, { std::make_tuple(USRP2, 4, 4), { 1, 0.0, 390625, 4.6080e-5, "N2XX 4 SPS" } }, @@ -129,9 +117,7 @@ { std::make_tuple(B2XX_MCBTS, 4, 4), { 1, 51.2e6, MCBTS_SPACING*4, B2XX_TIMING_MCBTS, "B200/B210 4 SPS Multi-ARFCN" } }, }; -typedef std::tuple<uhd_dev_type, enum gsm_band> dev_band_key; -typedef std::map<dev_band_key, dev_band_desc>::const_iterator dev_band_map_it; -static const std::map<dev_band_key, dev_band_desc> dev_band_nom_power_param_map { +static const power_map_t dev_band_nom_power_param_map { { std::make_tuple(B200, GSM_BAND_850), { 89.75, 13.3, -7.5 } }, { std::make_tuple(B200, GSM_BAND_900), { 89.75, 13.3, -7.5 } }, { std::make_tuple(B200, GSM_BAND_1800), { 89.75, 7.5, -11.0 } }, @@ -221,8 +207,8 @@ } uhd_device::uhd_device(InterfaceType iface, const struct trx_cfg *cfg) - : RadioDevice(iface, cfg), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false), - band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0, 0), + : RadioDevice(iface, cfg), band_manager(dev_band_nom_power_param_map, dev_param_map), rx_gain_min(0.0), + rx_gain_max(0.0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0, 0), ts_initial(0), ts_offset(0), async_event_thrd(NULL) { } @@ -235,47 +221,6 @@ delete rx_buffers[i]; } -void uhd_device::assign_band_desc(enum gsm_band req_band) -{ - dev_band_map_it it; - - it = dev_band_nom_power_param_map.find(dev_band_key(dev_type, req_band)); - if (it == dev_band_nom_power_param_map.end()) { - dev_desc desc = dev_param_map.at(dev_key(dev_type, tx_sps, rx_sps)); - LOGC(DDEV, ERROR) << "No Power parameters exist for device " - << desc.str << " on band " << gsm_band_name(req_band) - << ", using B210 ones as fallback"; - it = dev_band_nom_power_param_map.find(dev_band_key(B210, req_band)); - } - OSMO_ASSERT(it != dev_band_nom_power_param_map.end()) - band_desc = it->second; -} - -bool uhd_device::set_band(enum gsm_band req_band) -{ - if (band_ass_curr_sess && req_band != band) { - LOGC(DDEV, ALERT) << "Requesting band " << gsm_band_name(req_band) - << " different from previous band " << gsm_band_name(band); - return false; - } - - if (req_band != band) { - band = req_band; - assign_band_desc(band); - } - band_ass_curr_sess = true; - return true; -} - -void uhd_device::get_dev_band_desc(dev_band_desc& desc) -{ - if (band == 0) { - LOGC(DDEV, ERROR) << "Power parameters requested before Tx Frequency was set! Providing band 900 by default..."; - assign_band_desc(GSM_BAND_900); - } - desc = band_desc; -} - void uhd_device::init_gains() { double tx_gain_min, tx_gain_max; @@ -340,7 +285,7 @@ rx_rate = usrp_dev->get_rx_rate(); ts_offset = static_cast<TIMESTAMP>(desc.offset * rx_rate); - LOGC(DDEV, INFO) << "Rates configured for " << desc.str; + LOGC(DDEV, INFO) << "Rates configured for " << desc.desc_str; } double uhd_device::setRxGain(double db, size_t chan) @@ -791,7 +736,7 @@ for (size_t i = 0; i < rx_buffers.size(); i++) rx_buffers[i]->reset(); - band_ass_curr_sess = false; + band_reset(); started = false; return true; @@ -1031,17 +976,19 @@ { std::vector<double> freqs; uhd::tune_result_t tres; + std::string str_dir = tx ? "Tx" : "Rx"; + + if (!update_band_from_freq(freq, chan, tx)) + return false; + uhd::tune_request_t treq = select_freq(freq, chan, tx); - std::string str_dir; if (tx) { tres = usrp_dev->set_tx_freq(treq, chan); tx_freqs[chan] = usrp_dev->get_tx_freq(chan); - str_dir = "Tx"; } else { tres = usrp_dev->set_rx_freq(treq, chan); rx_freqs[chan] = usrp_dev->get_rx_freq(chan); - str_dir = "Rx"; } LOGCHAN(chan, DDEV, INFO) << "set_freq(" << freq << ", " << str_dir << "): " << tres.to_pp_string() << std::endl; @@ -1071,59 +1018,20 @@ bool uhd_device::setTxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - if (chan >= tx_freqs.size()) { LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan; return false; } - ScopedLock lock(tune_lock); - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100 , 0); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Tx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Tx Frequency " << wFreq - << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) - return false; - - if (!set_freq(wFreq, chan, true)) - return false; - - return true; + return set_freq(wFreq, chan, true); } bool uhd_device::setRxFreq(double wFreq, size_t chan) { - uint16_t req_arfcn; - enum gsm_band req_band; - if (chan >= rx_freqs.size()) { LOGC(DDEV, ALERT) << "Requested non-existent channel " << chan; return false; } - ScopedLock lock(tune_lock); - - req_arfcn = gsm_freq102arfcn(wFreq / 1000 / 100, 1); - if (req_arfcn == 0xffff) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown ARFCN for Rx Frequency " << wFreq / 1000 << " kHz"; - return false; - } - if (gsm_arfcn2band_rc(req_arfcn, &req_band) < 0) { - LOGCHAN(chan, DDEV, ALERT) << "Unknown GSM band for Rx Frequency " << wFreq - << " Hz (ARFCN " << req_arfcn << " )"; - return false; - } - - if (!set_band(req_band)) - return false; return set_freq(wFreq, chan, false); } diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h index 299d98c..f5e5232 100644 --- a/Transceiver52M/device/uhd/UHDDevice.h +++ b/Transceiver52M/device/uhd/UHDDevice.h @@ -30,6 +30,7 @@ #include "config.h" #endif +#include "bandmanager.h" #include "radioDevice.h" #include "smpl_buf.h" @@ -71,6 +72,19 @@ double rxgain2rssioffset_rel; /* dB */ }; +struct dev_desc { + unsigned channels; + double mcr; + double rate; + double offset; + std::string desc_str; +}; + +using dev_key = std::tuple<uhd_dev_type, int, int>; +using dev_band_key = std::tuple<uhd_dev_type, enum gsm_band>; +using power_map_t = std::map<dev_band_key, dev_band_desc>; +using dev_map_t = std::map<dev_key, dev_desc>; + /* uhd_device - UHD implementation of the Device interface. Timestamped samples are sent to and received from the device. An intermediate buffer @@ -78,7 +92,7 @@ Events and errors such as underruns are reported asynchronously by the device and received in a separate thread. */ -class uhd_device : public RadioDevice { +class uhd_device : public RadioDevice, public band_manager<power_map_t, dev_map_t> { public: uhd_device(InterfaceType iface, const struct trx_cfg *cfg); ~uhd_device(); @@ -160,9 +174,6 @@ std::vector<double> tx_gains, rx_gains; std::vector<double> tx_freqs, rx_freqs; - bool band_ass_curr_sess; /* true if "band" was set after last POWEROFF */ - enum gsm_band band; - struct dev_band_desc band_desc; size_t tx_spp, rx_spp; bool started; @@ -191,10 +202,6 @@ uhd::tune_request_t select_freq(double wFreq, size_t chan, bool tx); bool set_freq(double freq, size_t chan, bool tx); - void get_dev_band_desc(dev_band_desc& desc); - bool set_band(enum gsm_band req_band); - void assign_band_desc(enum gsm_band req_band); Thread *async_event_thrd; - Mutex tune_lock; }; -- To view, visit
https://gerrit.osmocom.org/c/osmo-trx/+/32763
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I64f5a462451e967d4750d8e4f1d5832cbab41cff Gerrit-Change-Number: 32763 Gerrit-PatchSet: 11 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[L] Change in osmo-trx[master]: transceiver: pass cfg struct instead of args
by Hoernchen
Hoernchen has submitted this change. (
https://gerrit.osmocom.org/c/osmo-trx/+/32762
) Change subject: transceiver: pass cfg struct instead of args ...................................................................... transceiver: pass cfg struct instead of args Passing 7 args is a bit much, just pass the config struct instead. Change-Id: I48386900d15ff4d770c70a4efc246d32f921904b --- M CommonLibs/trx_vty.c M Transceiver52M/device/bladerf/bladerf.cpp M Transceiver52M/device/bladerf/bladerf.h M Transceiver52M/device/common/radioDevice.h M Transceiver52M/device/ipc/IPCDevice.cpp M Transceiver52M/device/ipc/IPCDevice.h M Transceiver52M/device/ipc/uhdwrap.cpp M Transceiver52M/device/ipc/uhdwrap.h M Transceiver52M/device/lms/LMSDevice.cpp M Transceiver52M/device/lms/LMSDevice.h M Transceiver52M/device/uhd/UHDDevice.cpp M Transceiver52M/device/uhd/UHDDevice.h M Transceiver52M/device/usrp1/USRPDevice.cpp M Transceiver52M/device/usrp1/USRPDevice.h M Transceiver52M/osmo-trx.cpp 15 files changed, 161 insertions(+), 180 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve fixeria: Looks good to me, approved diff --git a/CommonLibs/trx_vty.c b/CommonLibs/trx_vty.c index ba55f92..6724189 100644 --- a/CommonLibs/trx_vty.c +++ b/CommonLibs/trx_vty.c @@ -607,7 +607,7 @@ vty_out(vty, " remote-ip %s%s", trx->cfg.remote_addr, VTY_NEWLINE); if (trx->cfg.base_port != DEFAULT_TRX_PORT) vty_out(vty, " base-port %u%s", trx->cfg.base_port, VTY_NEWLINE); - if (trx->cfg.dev_args) + if (strlen(trx->cfg.dev_args)) vty_out(vty, " dev-args %s%s", trx->cfg.dev_args, VTY_NEWLINE); if (trx->cfg.tx_sps != DEFAULT_TX_SPS) vty_out(vty, " tx-sps %u%s", trx->cfg.tx_sps, VTY_NEWLINE); @@ -760,6 +760,7 @@ trx->cfg.rx_sps = DEFAULT_RX_SPS; trx->cfg.filler = FILLER_ZERO; trx->cfg.rssi_offset = 0.0f; + trx->cfg.dev_args = ""; return trx; } diff --git a/Transceiver52M/device/bladerf/bladerf.cpp b/Transceiver52M/device/bladerf/bladerf.cpp index 4f0110b..3d9aab9 100644 --- a/Transceiver52M/device/bladerf/bladerf.cpp +++ b/Transceiver52M/device/bladerf/bladerf.cpp @@ -84,11 +84,10 @@ return desc.nom_uhd_tx_gain - (desc.nom_out_tx_power - tx_power_dbm); } -blade_device::blade_device(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths) - : RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), dev(nullptr), rx_gain_min(0.0), - rx_gain_max(0.0), band_ass_curr_sess(false), band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), - aligned(false), drop_cnt(0), prev_ts(0), ts_initial(0), ts_offset(0), async_event_thrd(NULL) +blade_device::blade_device(InterfaceType iface, const struct trx_cfg *cfg) + : RadioDevice(iface, cfg), dev(nullptr), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false), + band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0), + ts_initial(0), ts_offset(0), async_event_thrd(NULL) { } @@ -312,15 +311,15 @@ return desc.nom_out_tx_power; } -int blade_device::open(const std::string &args, int ref, bool swap_channels) +int blade_device::open() { bladerf_log_set_verbosity(BLADERF_LOG_LEVEL_VERBOSE); bladerf_set_usb_reset_on_open(true); - auto success = bladerf_open(&dev, args.c_str()); + auto success = bladerf_open(&dev, cfg->dev_args); if (success != 0) { struct bladerf_devinfo *info; auto num_devs = bladerf_get_device_list(&info); - LOGC(DDEV, ALERT) << "No bladerf devices found with identifier '" << args << "'"; + LOGC(DDEV, ALERT) << "No bladerf devices found with identifier '" << cfg->dev_args << "'"; if (num_devs) { for (int i = 0; i < num_devs; i++) LOGC(DDEV, ALERT) << "Found device:" << info[i].product << " serial " << info[i].serial; @@ -346,7 +345,7 @@ rx_gains.resize(chans); rx_buffers.resize(chans); - switch (ref) { + switch (cfg->clock_ref) { case REF_INTERNAL: case REF_EXTERNAL: break; @@ -355,7 +354,7 @@ return -1; } - if (ref == REF_EXTERNAL) { + if (cfg->clock_ref == REF_EXTERNAL) { bool is_locked; int status = bladerf_set_pll_enable(dev, true); CHKRET() @@ -374,7 +373,8 @@ } } - LOGC(DDEV, INFO) << "Selected clock source is " << ((ref == REF_INTERNAL) ? "internal" : "external 10Mhz"); + LOGC(DDEV, INFO) + << "Selected clock source is " << ((cfg->clock_ref == REF_INTERNAL) ? "internal" : "external 10Mhz"); set_rates(); @@ -687,8 +687,7 @@ return (double)2047; } -RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths) +RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg) { - return new blade_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); + return new blade_device(type, cfg); } diff --git a/Transceiver52M/device/bladerf/bladerf.h b/Transceiver52M/device/bladerf/bladerf.h index 07b7d6a..4db2569 100644 --- a/Transceiver52M/device/bladerf/bladerf.h +++ b/Transceiver52M/device/bladerf/bladerf.h @@ -54,11 +54,10 @@ class blade_device : public RadioDevice { public: - blade_device(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths); + blade_device(InterfaceType iface, const struct trx_cfg *cfg); ~blade_device(); - int open(const std::string &args, int ref, bool swap_channels); + int open(); bool start(); bool stop(); bool restart(); diff --git a/Transceiver52M/device/common/radioDevice.h b/Transceiver52M/device/common/radioDevice.h index 404ef75..5c962d1 100644 --- a/Transceiver52M/device/common/radioDevice.h +++ b/Transceiver52M/device/common/radioDevice.h @@ -51,13 +51,10 @@ MULTI_ARFCN, }; - static RadioDevice *make(size_t tx_sps, size_t rx_sps, InterfaceType type, - size_t chans = 1, double offset = 0.0, - const std::vector<std::string>& tx_paths = std::vector<std::string>(1, ""), - const std::vector<std::string>& rx_paths = std::vector<std::string>(1, "")); + static RadioDevice *make(InterfaceType type, const struct trx_cfg *cfg); /** Initialize the USRP */ - virtual int open(const std::string &args, int ref, bool swap_channels)=0; + virtual int open() = 0; virtual ~RadioDevice() { } @@ -164,23 +161,30 @@ double lo_offset; std::vector<std::string> tx_paths, rx_paths; std::vector<struct device_counters> m_ctr; + const struct trx_cfg *cfg; - RadioDevice(size_t tx_sps, size_t rx_sps, InterfaceType type, size_t chan_num, double offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths): - tx_sps(tx_sps), rx_sps(rx_sps), iface(type), chans(chan_num), lo_offset(offset), - tx_paths(tx_paths), rx_paths(rx_paths), m_ctr(chans) - { - if (iface == MULTI_ARFCN) { - LOGC(DDEV, INFO) << "Multi-ARFCN: "<< chan_num << " logical chans -> 1 physical chans"; - chans = 1; - } +#define charp2str(a) ((a) ? std::string(a) : std::string("")) - for (size_t i = 0; i < chans; i++) { - memset(&m_ctr[i], 0, sizeof(m_ctr[i])); - m_ctr[i].chan = i; - } - } + RadioDevice(InterfaceType type, const struct trx_cfg *cfg) + : tx_sps(cfg->tx_sps), rx_sps(cfg->rx_sps), iface(type), chans(cfg->num_chans), lo_offset(cfg->offset), + m_ctr(chans), cfg(cfg) + { + /* Generate vector of rx/tx_path: */ + for (unsigned int i = 0; i < cfg->num_chans; i++) { + rx_paths.push_back(charp2str(cfg->chans[i].rx_path)); + tx_paths.push_back(charp2str(cfg->chans[i].tx_path)); + } + + if (iface == MULTI_ARFCN) { + LOGC(DDEV, INFO) << "Multi-ARFCN: " << chans << " logical chans -> 1 physical chans"; + chans = 1; + } + + for (size_t i = 0; i < chans; i++) { + memset(&m_ctr[i], 0, sizeof(m_ctr[i])); + m_ctr[i].chan = i; + } + } bool set_antennas() { unsigned int i; diff --git a/Transceiver52M/device/ipc/IPCDevice.cpp b/Transceiver52M/device/ipc/IPCDevice.cpp index 4b4ba37..1d2b89a 100644 --- a/Transceiver52M/device/ipc/IPCDevice.cpp +++ b/Transceiver52M/device/ipc/IPCDevice.cpp @@ -56,11 +56,10 @@ static int ipc_chan_sock_cb(struct osmo_fd *bfd, unsigned int flags); -IPCDevice::IPCDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths) - : RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), sk_chan_state(chans, ipc_per_trx_sock_state()), - tx_attenuation(), tmp_state(IPC_IF_MSG_GREETING_REQ), shm(NULL), shm_dec(0), - rx_buffers(chans), started(false), tx_gains(chans), rx_gains(chans) +IPCDevice::IPCDevice(InterfaceType iface, const struct trx_cfg *cfg) + : RadioDevice(iface, cfg), sk_chan_state(chans, ipc_per_trx_sock_state()), tx_attenuation(), + tmp_state(IPC_IF_MSG_GREETING_REQ), shm(NULL), shm_dec(0), rx_buffers(chans), started(false), tx_gains(chans), + rx_gains(chans) { LOGC(DDEV, INFO) << "creating IPC device..."; @@ -771,11 +770,12 @@ return rc; } -int IPCDevice::open(const std::string &args, int ref, bool swap_channels) +int IPCDevice::open() { std::string k, v; std::string::size_type keyend; int rc; + std::string args(cfg->dev_args); if ((keyend = args.find('=')) != std::string::npos) { k = args.substr(0, keyend++); @@ -810,7 +810,7 @@ while (tmp_state != IPC_IF_MSG_INFO_CNF) osmo_select_main(0); - ipc_tx_open_req(&master_sk_state, chans, ref); + ipc_tx_open_req(&master_sk_state, chans, cfg->clock_ref); /* Wait until confirmation is recieved */ while (tmp_state != IPC_IF_MSG_OPEN_CNF) osmo_select_main(0); @@ -1259,16 +1259,15 @@ return send_chan_wait_rsp(chan, msg, IPC_IF_MSG_SETFREQ_CNF); } -RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chans, double lo_offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths) +RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg) { - if (tx_sps != rx_sps) { + if (cfg->tx_sps != cfg->rx_sps) { LOGC(DDEV, ERROR) << "IPC Requires tx_sps == rx_sps"; return NULL; } - if (lo_offset != 0.0) { + if (cfg->offset != 0.0) { LOGC(DDEV, ERROR) << "IPC doesn't support lo_offset"; return NULL; } - return new IPCDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); + return new IPCDevice(type, cfg); } diff --git a/Transceiver52M/device/ipc/IPCDevice.h b/Transceiver52M/device/ipc/IPCDevice.h index f70c95e..0cf3d46 100644 --- a/Transceiver52M/device/ipc/IPCDevice.h +++ b/Transceiver52M/device/ipc/IPCDevice.h @@ -115,12 +115,11 @@ int ipc_chan_sock_write(osmo_fd *bfd); /** Object constructor */ - IPCDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string> &tx_paths, const std::vector<std::string> &rx_paths); + IPCDevice(InterfaceType iface, const struct trx_cfg *cfg); virtual ~IPCDevice() override; /** Instantiate the IPC */ - virtual int open(const std::string &args, int ref, bool swap_channels) override; + virtual int open() override; /** Start the IPC */ virtual bool start() override; diff --git a/Transceiver52M/device/ipc/uhdwrap.cpp b/Transceiver52M/device/ipc/uhdwrap.cpp index d7114da..302f763 100644 --- a/Transceiver52M/device/ipc/uhdwrap.cpp +++ b/Transceiver52M/device/ipc/uhdwrap.cpp @@ -35,9 +35,12 @@ #include "Threads.h" #include "Utils.h" -int uhd_wrap::open(const std::string &args, int ref, bool swap_channels) +// no vty source for cfg params here, so we have to build our own +static struct trx_cfg actual_cfg = {}; + +int uhd_wrap::open() { - int rv = uhd_device::open(args, ref, swap_channels); + int rv = uhd_device::open(); samps_per_buff_rx = rx_stream->get_max_num_samps(); samps_per_buff_tx = tx_stream->get_max_num_samps(); channel_count = usrp_dev->get_rx_num_channels(); @@ -84,36 +87,33 @@ extern "C" void *uhdwrap_open(struct ipc_sk_if_open_req *open_req) { - unsigned int rx_sps, tx_sps; + actual_cfg.num_chans = open_req->num_chans; + actual_cfg.swap_channels = false; + /* FIXME: this is actually the sps value, not the sample rate! + * sample rate is looked up according to the sps rate by uhd backend */ + actual_cfg.rx_sps = open_req->rx_sample_freq_num / open_req->rx_sample_freq_den; + actual_cfg.tx_sps = open_req->tx_sample_freq_num / open_req->tx_sample_freq_den; /* FIXME: dev arg string* */ /* FIXME: rx frontend bw? */ /* FIXME: tx frontend bw? */ - ReferenceType cref; switch (open_req->clockref) { case FEATURE_MASK_CLOCKREF_EXTERNAL: - cref = ReferenceType::REF_EXTERNAL; + actual_cfg.clock_ref = ReferenceType::REF_EXTERNAL; break; case FEATURE_MASK_CLOCKREF_INTERNAL: default: - cref = ReferenceType::REF_INTERNAL; + actual_cfg.clock_ref = ReferenceType::REF_INTERNAL; break; } - std::vector<std::string> tx_paths; - std::vector<std::string> rx_paths; for (unsigned int i = 0; i < open_req->num_chans; i++) { - tx_paths.push_back(open_req->chan_info[i].tx_path); - rx_paths.push_back(open_req->chan_info[i].rx_path); + actual_cfg.chans[i].rx_path = open_req->chan_info[i].tx_path; + actual_cfg.chans[i].tx_path = open_req->chan_info[i].rx_path; } - /* FIXME: this is actually the sps value, not the sample rate! - * sample rate is looked up according to the sps rate by uhd backend */ - rx_sps = open_req->rx_sample_freq_num / open_req->rx_sample_freq_den; - tx_sps = open_req->tx_sample_freq_num / open_req->tx_sample_freq_den; - uhd_wrap *uhd_wrap_dev = - new uhd_wrap(tx_sps, rx_sps, RadioDevice::NORMAL, open_req->num_chans, 0.0, tx_paths, rx_paths); - uhd_wrap_dev->open("", cref, false); + uhd_wrap *uhd_wrap_dev = new uhd_wrap(RadioDevice::NORMAL, &actual_cfg); + uhd_wrap_dev->open(); return uhd_wrap_dev; } diff --git a/Transceiver52M/device/ipc/uhdwrap.h b/Transceiver52M/device/ipc/uhdwrap.h index e235fe7..44cd9aa 100644 --- a/Transceiver52M/device/ipc/uhdwrap.h +++ b/Transceiver52M/device/ipc/uhdwrap.h @@ -41,7 +41,7 @@ // void ipc_sock_close() override {}; int wrap_read(TIMESTAMP *timestamp); - virtual int open(const std::string &args, int ref, bool swap_channels) override; + virtual int open() override; // bool start() override; // bool stop() override; diff --git a/Transceiver52M/device/lms/LMSDevice.cpp b/Transceiver52M/device/lms/LMSDevice.cpp index d1ec2e4..e336e77 100644 --- a/Transceiver52M/device/lms/LMSDevice.cpp +++ b/Transceiver52M/device/lms/LMSDevice.cpp @@ -131,12 +131,9 @@ return LMS_DEV_UNKNOWN; } -LMSDevice::LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths): - RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), - m_lms_dev(NULL), started(false), band_ass_curr_sess(false), band((enum gsm_band)0), - m_dev_type(LMS_DEV_UNKNOWN) +LMSDevice::LMSDevice(InterfaceType iface, const struct trx_cfg *cfg) + : RadioDevice(iface, cfg), m_lms_dev(NULL), started(false), band_ass_curr_sess(false), band((enum gsm_band)0), + m_dev_type(LMS_DEV_UNKNOWN) { LOGC(DDEV, INFO) << "creating LMS device..."; @@ -264,7 +261,7 @@ desc = band_desc; } -int LMSDevice::open(const std::string &args, int ref, bool swap_channels) +int LMSDevice::open() { lms_info_str_t* info_list; lms_range_t range_sr; @@ -292,9 +289,9 @@ for (i = 0; i < n; i++) LOGC(DDEV, INFO) << "Device [" << i << "]: " << info_list[i]; - dev_id = info_list_find(info_list, n, args); + dev_id = info_list_find(info_list, n, cfg->dev_args); if (dev_id == -1) { - LOGC(DDEV, ERROR) << "No LMS device found with address '" << args << "'"; + LOGC(DDEV, ERROR) << "No LMS device found with address '" << cfg->dev_args << "'"; delete[] info_list; return -1; } @@ -312,13 +309,13 @@ m_dev_type = parse_dev_type(m_lms_dev); dev_desc = dev_param_map.at(m_dev_type); - if ((ref != REF_EXTERNAL) && (ref != REF_INTERNAL)){ + if ((cfg->clock_ref != REF_EXTERNAL) && (cfg->clock_ref != REF_INTERNAL)) { LOGC(DDEV, ERROR) << "Invalid reference type"; goto out_close; } /* if reference clock is external, setup must happen _before_ calling LMS_Init */ - if (ref == REF_EXTERNAL) { + if (cfg->clock_ref == REF_EXTERNAL) { LOGC(DDEV, INFO) << "Setting External clock reference to 10MHz"; /* FIXME: Assume an external 10 MHz reference clock. make external reference frequency configurable */ @@ -333,7 +330,7 @@ } /* if reference clock is internal, setup must happen _after_ calling LMS_Init */ - if (ref == REF_INTERNAL) { + if (cfg->clock_ref == REF_INTERNAL) { LOGC(DDEV, INFO) << "Setting Internal clock reference"; /* Internal freq param is not used */ if (!do_clock_src_freq(REF_INTERNAL, 0)) @@ -1060,18 +1057,15 @@ return true; } -RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chans, double lo_offset, - const std::vector < std::string > &tx_paths, - const std::vector < std::string > &rx_paths) +RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg) { - if (tx_sps != rx_sps) { - LOGC(DDEV, ERROR) << "LMS Requires tx_sps == rx_sps"; + if (cfg->tx_sps != cfg->rx_sps) { + LOGC(DDEV, ERROR) << "LMS requires tx_sps == rx_sps"; return NULL; } - if (lo_offset != 0.0) { + if (cfg->offset != 0.0) { LOGC(DDEV, ERROR) << "LMS doesn't support lo_offset"; return NULL; } - return new LMSDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); + return new LMSDevice(type, cfg); } diff --git a/Transceiver52M/device/lms/LMSDevice.h b/Transceiver52M/device/lms/LMSDevice.h index ab28250..75d11cf 100644 --- a/Transceiver52M/device/lms/LMSDevice.h +++ b/Transceiver52M/device/lms/LMSDevice.h @@ -107,23 +107,22 @@ public: /** Object constructor */ - LMSDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths); - ~LMSDevice(); + LMSDevice(InterfaceType iface, const struct trx_cfg *cfg); + ~LMSDevice(); - /** Instantiate the LMS */ - int open(const std::string &args, int ref, bool swap_channels); + /** Instantiate the LMS */ + int open(); - /** Start the LMS */ - bool start(); + /** Start the LMS */ + bool start(); - /** Stop the LMS */ - bool stop(); + /** Stop the LMS */ + bool stop(); - enum TxWindowType getWindowType() { - return TX_WINDOW_LMS1; - } + enum TxWindowType getWindowType() + { + return TX_WINDOW_LMS1; + } /** Read samples from the LMS. diff --git a/Transceiver52M/device/uhd/UHDDevice.cpp b/Transceiver52M/device/uhd/UHDDevice.cpp index f109660..a0021db 100644 --- a/Transceiver52M/device/uhd/UHDDevice.cpp +++ b/Transceiver52M/device/uhd/UHDDevice.cpp @@ -220,15 +220,10 @@ return desc.nom_uhd_tx_gain - (desc.nom_out_tx_power - tx_power_dbm); } -uhd_device::uhd_device(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths) - : RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths), - rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false), - band((enum gsm_band)0), tx_spp(0), rx_spp(0), - started(false), aligned(false), drop_cnt(0), - prev_ts(0,0), ts_initial(0), ts_offset(0), async_event_thrd(NULL) +uhd_device::uhd_device(InterfaceType iface, const struct trx_cfg *cfg) + : RadioDevice(iface, cfg), rx_gain_min(0.0), rx_gain_max(0.0), band_ass_curr_sess(false), + band((enum gsm_band)0), tx_spp(0), rx_spp(0), started(false), aligned(false), drop_cnt(0), prev_ts(0, 0), + ts_initial(0), ts_offset(0), async_event_thrd(NULL) { } @@ -548,7 +543,7 @@ } } -int uhd_device::open(const std::string &args, int ref, bool swap_channels) +int uhd_device::open() { const char *refstr; int clock_lock_attempts = 15; @@ -564,10 +559,10 @@ #endif // Find UHD devices - uhd::device_addr_t addr(args); + uhd::device_addr_t addr(cfg->dev_args); uhd::device_addrs_t dev_addrs = uhd::device::find(addr); if (dev_addrs.size() == 0) { - LOGC(DDEV, ALERT) << "No UHD devices found with address '" << args << "'"; + LOGC(DDEV, ALERT) << "No UHD devices found with address '" << cfg->dev_args << "'"; return -1; } @@ -576,7 +571,7 @@ try { usrp_dev = uhd::usrp::multi_usrp::make(addr); } catch(uhd::key_error::exception &e) { - LOGC(DDEV, ALERT) << "UHD make failed, device " << args << ", exception:\n" << e.what(); + LOGC(DDEV, ALERT) << "UHD make failed, device " << cfg->dev_args << ", exception:\n" << e.what(); return -1; } @@ -590,8 +585,8 @@ } try { - set_channels(swap_channels); - } catch (const std::exception &e) { + set_channels(cfg->swap_channels); + } catch (const std::exception &e) { LOGC(DDEV, ALERT) << "Channel setting failed - " << e.what(); return -1; } @@ -607,7 +602,7 @@ rx_gains.resize(chans); rx_buffers.resize(chans); - switch (ref) { + switch (cfg->clock_ref) { case REF_INTERNAL: refstr = "internal"; break; @@ -1378,11 +1373,8 @@ } #ifndef IPCMAGIC -RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chans, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths) +RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg) { - return new uhd_device(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); + return new uhd_device(type, cfg); } #endif diff --git a/Transceiver52M/device/uhd/UHDDevice.h b/Transceiver52M/device/uhd/UHDDevice.h index 659fd18..299d98c 100644 --- a/Transceiver52M/device/uhd/UHDDevice.h +++ b/Transceiver52M/device/uhd/UHDDevice.h @@ -80,17 +80,17 @@ */ class uhd_device : public RadioDevice { public: - uhd_device(size_t tx_sps, size_t rx_sps, InterfaceType type, - size_t chan_num, double offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths); - ~uhd_device(); + uhd_device(InterfaceType iface, const struct trx_cfg *cfg); + ~uhd_device(); - int open(const std::string &args, int ref, bool swap_channels); - bool start(); - bool stop(); - bool restart(); - enum TxWindowType getWindowType() { return tx_window; } + int open(); + bool start(); + bool stop(); + bool restart(); + enum TxWindowType getWindowType() + { + return tx_window; + } int readSamples(std::vector<short *> &bufs, int len, bool *overrun, TIMESTAMP timestamp, bool *underrun); diff --git a/Transceiver52M/device/usrp1/USRPDevice.cpp b/Transceiver52M/device/usrp1/USRPDevice.cpp index 852b715..63a9bcc 100644 --- a/Transceiver52M/device/usrp1/USRPDevice.cpp +++ b/Transceiver52M/device/usrp1/USRPDevice.cpp @@ -60,11 +60,7 @@ const double USRPDevice::masterClockRate = 52.0e6; -USRPDevice::USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, - size_t chan_num, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths): - RadioDevice(tx_sps, rx_sps, iface, chan_num, lo_offset, tx_paths, rx_paths) +USRPDevice::USRPDevice(InterfaceType iface, const struct trx_cfg *cfg) : RadioDevice(iface, cfg) { LOGC(DDEV, INFO) << "creating USRP device..."; @@ -94,7 +90,7 @@ #endif } -int USRPDevice::open(const std::string &, int, bool) +int USRPDevice::open() { writeLock.unlock(); @@ -658,22 +654,19 @@ bool USRPDevice::setRxFreq(double wFreq) { return true;}; #endif -RadioDevice *RadioDevice::make(size_t tx_sps, size_t rx_sps, - InterfaceType iface, size_t chans, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths) +RadioDevice *RadioDevice::make(InterfaceType type, const struct trx_cfg *cfg) { - if (tx_sps != rx_sps) { - LOGC(DDEV, ERROR) << "USRP1 requires tx_sps == rx_sps"; - return NULL; - } - if (chans != 1) { - LOGC(DDEV, ERROR) << "USRP1 supports only 1 channel"; - return NULL; - } - if (lo_offset != 0.0) { - LOGC(DDEV, ERROR) << "USRP1 doesn't support lo_offset"; - return NULL; - } - return new USRPDevice(tx_sps, rx_sps, iface, chans, lo_offset, tx_paths, rx_paths); + if (cfg->tx_sps != cfg->rx_sps) { + LOGC(DDEV, ERROR) << "USRP1 requires tx_sps == rx_sps"; + return NULL; + } + if (cfg->num_chans != 1) { + LOGC(DDEV, ERROR) << "USRP1 supports only 1 channel"; + return NULL; + } + if (cfg->offset != 0.0) { + LOGC(DDEV, ERROR) << "USRP1 doesn't support lo_offset"; + return NULL; + } + return new USRPDevice(type, cfg); } diff --git a/Transceiver52M/device/usrp1/USRPDevice.h b/Transceiver52M/device/usrp1/USRPDevice.h index aa8dc69..4957ee6 100644 --- a/Transceiver52M/device/usrp1/USRPDevice.h +++ b/Transceiver52M/device/usrp1/USRPDevice.h @@ -104,20 +104,21 @@ public: /** Object constructor */ - USRPDevice(size_t tx_sps, size_t rx_sps, InterfaceType iface, size_t chan_num, double lo_offset, - const std::vector<std::string>& tx_paths, - const std::vector<std::string>& rx_paths); + USRPDevice(InterfaceType iface, const struct trx_cfg *cfg); - /** Instantiate the USRP */ - int open(const std::string &, int, bool); + /** Instantiate the USRP */ + int open(); - /** Start the USRP */ - bool start(); + /** Start the USRP */ + bool start(); - /** Stop the USRP */ - bool stop(); + /** Stop the USRP */ + bool stop(); - enum TxWindowType getWindowType() { return TX_WINDOW_USRP1; } + enum TxWindowType getWindowType() + { + return TX_WINDOW_USRP1; + } /** Read samples from the USRP. diff --git a/Transceiver52M/osmo-trx.cpp b/Transceiver52M/osmo-trx.cpp index ad41338..89a577b 100644 --- a/Transceiver52M/osmo-trx.cpp +++ b/Transceiver52M/osmo-trx.cpp @@ -571,24 +571,14 @@ static int trx_start(struct trx_ctx *trx) { 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 (trx->cfg.multi_arfcn) iface = RadioDevice::MULTI_ARFCN; - /* 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(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); + usrp = RadioDevice::make(iface, &trx->cfg); + type = usrp->open(); if (type < 0) { LOG(ALERT) << "Failed to create radio device" << std::endl; goto shutdown; -- To view, visit
https://gerrit.osmocom.org/c/osmo-trx/+/32762
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-trx Gerrit-Branch: master Gerrit-Change-Id: I48386900d15ff4d770c70a4efc246d32f921904b Gerrit-Change-Number: 32762 Gerrit-PatchSet: 4 Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Hoernchen <ewild(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de> Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-CC: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[S] Change in libosmo-gprs[master]: cosmetic: sm: Fix wrong reference in comment
by pespin
pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33955
) ( 1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: cosmetic: sm: Fix wrong reference in comment ...................................................................... cosmetic: sm: Fix wrong reference in comment Change-Id: I8828e0019f6446c3a17d09e8483573bf752c159f --- M src/sm/sm_prim.c 1 file changed, 10 insertions(+), 1 deletion(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/sm/sm_prim.c b/src/sm/sm_prim.c index 66df8c2..0051d88 100644 --- a/src/sm/sm_prim.c +++ b/src/sm/sm_prim.c @@ -231,7 +231,7 @@ return rc; } -/* TS 24.007 6.6.1.1 SMREG-Attach.request:*/ +/* TS 24.007 6.5.1.1 SMREG-PDP_ACTIVATE.request:*/ static int gprs_sm_prim_handle_smreg_pdp_act_req(struct osmo_gprs_sm_prim *sm_prim) { int rc = 0; -- To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33955
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I8828e0019f6446c3a17d09e8483573bf752c159f Gerrit-Change-Number: 33955 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[S] Change in libosmo-gprs[master]: sndcp: Initialize N201-U & N201-I to default settings
by pespin
pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33952
) Change subject: sndcp: Initialize N201-U & N201-I to default settings ...................................................................... sndcp: Initialize N201-U & N201-I to default settings LLC is only expected to signal new values if SNDCP XID params are received, or if the default N201 values change. Change-Id: I68f54d329b326895ed8f010cf50f20fa30948d30 --- M src/sndcp/sndcp.c 1 file changed, 32 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/sndcp/sndcp.c b/src/sndcp/sndcp.c index 5decfac..d71cac9 100644 --- a/src/sndcp/sndcp.c +++ b/src/sndcp/sndcp.c @@ -34,6 +34,23 @@ struct gprs_sndcp_ctx *g_sndcp_ctx; +struct gprs_sndcp_llc_params { + uint16_t n201_u; + uint16_t n201_i; +}; + +/* Section 8.9.9 LLC layer parameter default values */ +static const struct gprs_sndcp_llc_params llc_default_params[GPRS_SNDCP_NUM_NSAPIS] = { + [1] = { .n201_u = 400, }, + [2] = { .n201_u = 270, }, + [3] = { .n201_u = 500, .n201_i = 1503, }, + [5] = { .n201_u = 500, .n201_i = 1503, }, + [7] = { .n201_u = 270, }, + [8] = { .n201_u = 270, }, + [9] = { .n201_u = 500, .n201_i = 1503, }, + [11] = { .n201_u = 500, .n201_i = 1503, }, +}; + int osmo_gprs_sndcp_init(enum osmo_gprs_sndcp_location location) { if (g_sndcp_ctx) @@ -126,6 +143,9 @@ sne->rx_state = GPRS_SNDCP_RX_S_FIRST; INIT_LLIST_HEAD(&sne->defrag.frag_list); + sne->n201_u = llc_default_params[llc_sapi].n201_u; + sne->n201_i = llc_default_params[llc_sapi].n201_i; + sne->snme = snme; gprs_sndcp_snme_attach_sne(snme, sne); -- To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33952
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I68f54d329b326895ed8f010cf50f20fa30948d30 Gerrit-Change-Number: 33952 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[S] Change in libosmo-gprs[master]: sm: Forward RadioPrio & QoS in SNSM-Activate.ind
by pespin
pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33956
) Change subject: sm: Forward RadioPrio & QoS in SNSM-Activate.ind ...................................................................... sm: Forward RadioPrio & QoS in SNSM-Activate.ind Change-Id: Ia8226f6e687f86b2502b27f9979dce13cf751c01 --- M src/sm/sm.c 1 file changed, 13 insertions(+), 2 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/src/sm/sm.c b/src/sm/sm.c index 308117f..38b18f7 100644 --- a/src/sm/sm.c +++ b/src/sm/sm.c @@ -264,8 +264,10 @@ sme->ms->gmm.tlli, sme->nsapi, sme->llc_sapi); - //sndcp_prim_tx->snsm.activat_ind.qos_params = ; /* TODO */ - //sndcp_prim_tx->snsm.activat_ind.radio_prio = 0; /* TODO */ + sndcp_prim_tx->snsm.activate_ind.radio_prio = sme->radio_prio; + sndcp_prim_tx->snsm.activate_ind.qos_profile_len = sme->qos_len; + if (sme->qos_len) + memcpy(sndcp_prim_tx->snsm.activate_ind.qos_profile, &sme->qos, sme->qos_len); rc = gprs_sm_prim_call_sndcp_up_cb(sndcp_prim_tx); return rc; -- To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33956
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: Ia8226f6e687f86b2502b27f9979dce13cf751c01 Gerrit-Change-Number: 33956 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[S] Change in libosmo-gprs[master]: sndcp: Use radio_prio assigned by SM when submitting LLC unitdata.req
by pespin
pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33957
) Change subject: sndcp: Use radio_prio assigned by SM when submitting LLC unitdata.req ...................................................................... sndcp: Use radio_prio assigned by SM when submitting LLC unitdata.req Change-Id: I632329bb1f34efb4d9263241e2cda5b559f1ff59 --- M include/osmocom/gprs/sndcp/sndcp_private.h M src/sndcp/sndcp.c M src/sndcp/sndcp_prim.c 3 files changed, 28 insertions(+), 8 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/sndcp/sndcp_private.h b/include/osmocom/gprs/sndcp/sndcp_private.h index 21c6a40..5630c97 100644 --- a/include/osmocom/gprs/sndcp/sndcp_private.h +++ b/include/osmocom/gprs/sndcp/sndcp_private.h @@ -151,6 +151,9 @@ /* The NSAPI we shall use on top of LLC */ uint8_t nsapi; + /* Radio Priority (MS only, used by LLC/RLCMAC), TS 24.008 10.5.7.2 */ + uint8_t radio_prio; + /* NPDU number for the GTP->SNDCP side */ uint16_t tx_npdu_nr; /* SNDCP eeceiver state */ diff --git a/src/sndcp/sndcp.c b/src/sndcp/sndcp.c index d71cac9..7e82b5d 100644 --- a/src/sndcp/sndcp.c +++ b/src/sndcp/sndcp.c @@ -222,6 +222,18 @@ return rc; } +int gprs_sndcp_sne_submit_llc_ll_unitdata_req(struct gprs_sndcp_entity *sne, uint8_t *data, unsigned int len) +{ + struct osmo_gprs_llc_prim *llc_prim_tx; + int rc; + + llc_prim_tx = osmo_gprs_llc_prim_alloc_ll_unitdata_req(sne->snme->tlli, sne->llc_sapi, data, len); + OSMO_ASSERT(llc_prim_tx); + llc_prim_tx->ll.unitdata_req.radio_prio = sne->radio_prio; + rc = gprs_sndcp_prim_call_down_cb(llc_prim_tx); + return rc; +} + int gprs_sndcp_sne_submit_sn_xid_cnf(struct gprs_sndcp_entity *sne) { struct osmo_gprs_sndcp_prim *sndcp_prim_tx; @@ -530,7 +542,6 @@ unsigned int len; uint8_t *data; int rc, more; - struct osmo_gprs_llc_prim *llc_prim_tx; fmsg = msgb_alloc_headroom(sne->n201_u+256, 128, "SNDCP Frag"); if (!fmsg) { @@ -588,9 +599,7 @@ sch->more = more; /* Send down the stack SNDCP->LLC as LL-UNITDATA.req: */ - llc_prim_tx = osmo_gprs_llc_prim_alloc_ll_unitdata_req(sne->snme->tlli, sne->llc_sapi, fmsg->data, fmsg->len); - OSMO_ASSERT(llc_prim_tx); - rc = gprs_sndcp_prim_call_down_cb(llc_prim_tx); + rc = gprs_sndcp_sne_submit_llc_ll_unitdata_req(sne, fmsg->data, fmsg->len); msgb_free(fmsg); /* abort in case of error, do not advance frag_nr / next_byte */ if (rc < 0) { @@ -622,7 +631,6 @@ uint8_t dcomp = 0; int rc; struct msgb *msg = msgb_alloc_headroom(npdu_len + 256, 128, "sndcp-tx"); - struct osmo_gprs_llc_prim *llc_prim_tx; memcpy(msgb_put(msg, npdu_len), npdu, npdu_len); @@ -711,9 +719,7 @@ sch->nsapi = sne->nsapi; /* Send down the stack SNDCP->LLC as LL-UNITDATA.req: */ - llc_prim_tx = osmo_gprs_llc_prim_alloc_ll_unitdata_req(sne->snme->tlli, sne->llc_sapi, msg->data, msg->len); - OSMO_ASSERT(llc_prim_tx); - rc = gprs_sndcp_prim_call_down_cb(llc_prim_tx); + rc = gprs_sndcp_sne_submit_llc_ll_unitdata_req(sne, msg->data, msg->len); free_ret: msgb_free(msg); return rc; diff --git a/src/sndcp/sndcp_prim.c b/src/sndcp/sndcp_prim.c index e371416..2e2139c 100644 --- a/src/sndcp/sndcp_prim.c +++ b/src/sndcp/sndcp_prim.c @@ -661,6 +661,8 @@ if (g_sndcp_ctx->location != OSMO_GPRS_SNDCP_LOCATION_MS) return 0; + sne->radio_prio = sndcp_prim->snsm.activate_ind.radio_prio; + /* TODO: when supporting and using LLC ABM mode, flow should go through * LL-ESTABLISH.req, as per TS 24.007 C.6 "No LLC link exists yet, * establish a link and exchange XID" -- To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33957
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I632329bb1f34efb4d9263241e2cda5b559f1ff59 Gerrit-Change-Number: 33957 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
[S] Change in libosmo-gprs[master]: llc: Set proper Radio Priority when submitting GRR-UNITDATA.req
by pespin
pespin has submitted this change. (
https://gerrit.osmocom.org/c/libosmo-gprs/+/33958
) Change subject: llc: Set proper Radio Priority when submitting GRR-UNITDATA.req ...................................................................... llc: Set proper Radio Priority when submitting GRR-UNITDATA.req Change-Id: I2ace165003469c2a43d7333634171896699d5a5d --- M include/osmocom/gprs/llc/llc_private.h M src/llc/llc.c M src/llc/llc_ll.c M src/llc/llc_llgmm.c 4 files changed, 20 insertions(+), 4 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified pespin: Looks good to me, approved diff --git a/include/osmocom/gprs/llc/llc_private.h b/include/osmocom/gprs/llc/llc_private.h index e5c197e..2d3f02f 100644 --- a/include/osmocom/gprs/llc/llc_private.h +++ b/include/osmocom/gprs/llc/llc_private.h @@ -323,7 +323,7 @@ int gprs_llc_lle_tx_xid(const struct gprs_llc_lle *lle, uint8_t *xid_payload, unsigned int xid_payload_len, bool is_cmd); int gprs_llc_lle_tx_xid_req(struct gprs_llc_lle *lle, uint8_t *l3par, unsigned int l3par_len); int gprs_llc_lle_tx_xid_resp(struct gprs_llc_lle *lle, uint8_t *l3par, unsigned int l3par_len); -int gprs_llc_lle_tx_ui(struct gprs_llc_lle *lle, uint8_t *l3_pdu, size_t l3_pdu_len, bool encryptable); +int gprs_llc_lle_tx_ui(struct gprs_llc_lle *lle, uint8_t *l3_pdu, size_t l3_pdu_len, bool encryptable, uint8_t radio_prio); int gprs_llc_lle_tx_null(const struct gprs_llc_lle *lle); /* llc_prim.c: */ diff --git a/src/llc/llc.c b/src/llc/llc.c index d58b454..cff6c16 100644 --- a/src/llc/llc.c +++ b/src/llc/llc.c @@ -255,6 +255,7 @@ int rc; struct msgb *msg; struct osmo_gprs_llc_prim *llc_prim; + const uint8_t radio_prio = 1; /* Use highest prio for GMM messages, TS 24.008 10.5.7.2 */ struct gprs_llc_pdu_decoded pdu_dec = { .sapi = lle->sapi, .fmt = OSMO_GPRS_LLC_FMT_U, @@ -287,6 +288,7 @@ llc_prim->grr.ll_pdu = msgb_l3(msg); llc_prim->grr.ll_pdu_len = msgb_l3len(msg); llc_prim->grr.unitdata_req.sapi = lle->sapi; + llc_prim->grr.unitdata_req.radio_prio = radio_prio; } /* Send GRR-UNITDATA.req */ @@ -299,6 +301,7 @@ { int rc; struct msgb *msg; + const uint8_t radio_prio = 4; /* Use lowest prio for GMM messages, TS 24.008 10.5.7.2 */ struct gprs_llc_pdu_decoded pdu_dec = { .sapi = lle->sapi, .fmt = OSMO_GPRS_LLC_FMT_U, @@ -329,6 +332,7 @@ llc_prim->grr.ll_pdu = msgb_l3(msg); llc_prim->grr.ll_pdu_len = msgb_l3len(msg); llc_prim->grr.unitdata_req.sapi = lle->sapi; + llc_prim->grr.unitdata_req.radio_prio = radio_prio; } /* Send BSSGP-DL-UNITDATA.req (SGSN) / GRR-UNITDATA.req (MS) */ @@ -340,7 +344,7 @@ 'encryptable' indicates whether particular message can be encrypted according to 3GPP TS 24.008 § 4.7.1.2 */ -int gprs_llc_lle_tx_ui(struct gprs_llc_lle *lle, uint8_t *l3_pdu, size_t l3_pdu_len, bool encryptable) +int gprs_llc_lle_tx_ui(struct gprs_llc_lle *lle, uint8_t *l3_pdu, size_t l3_pdu_len, bool encryptable, uint8_t radio_prio) { struct osmo_gprs_llc_prim *llc_prim; struct msgb *msg; @@ -393,6 +397,7 @@ llc_prim->grr.ll_pdu = msgb_l3(msg); llc_prim->grr.ll_pdu_len = msgb_l3len(msg); llc_prim->grr.unitdata_req.sapi = lle->sapi; + llc_prim->grr.unitdata_req.radio_prio = radio_prio; } /* Increment V(U) */ diff --git a/src/llc/llc_ll.c b/src/llc/llc_ll.c index 8a3c2ae..ad87dba 100644 --- a/src/llc/llc_ll.c +++ b/src/llc/llc_ll.c @@ -309,7 +309,8 @@ } rc = gprs_llc_lle_tx_ui(lle, llc_prim->ll.l3_pdu, llc_prim->ll.l3_pdu_len, - llc_prim->ll.unitdata_req.apply_gea); + llc_prim->ll.unitdata_req.apply_gea, + llc_prim->ll.unitdata_req.radio_prio); ret_free: msgb_free(llc_prim->oph.msg); diff --git a/src/llc/llc_llgmm.c b/src/llc/llc_llgmm.c index f33d6de..438de51 100644 --- a/src/llc/llc_llgmm.c +++ b/src/llc/llc_llgmm.c @@ -283,6 +283,7 @@ struct gprs_llc_lle *lle; int rc; struct gprs_llc_llme *llme = gprs_llc_find_llme_by_tlli(llc_prim->llgmm.tlli); + const uint8_t radio_prio = 1; /* Use highest prio for GMM messages, TS 24.008 10.5.7.2 */ if (!llme) { LOGLLC(LOGL_NOTICE, "Rx %s: Unknown TLLI 0x%08x\n", @@ -308,7 +309,7 @@ case OSMO_GPRS_LLC_LLGM_TRIGGER_CELL_UPDATE: case OSMO_GPRS_LLC_LLGM_TRIGGER_PAGE_RESP: default: - rc = gprs_llc_lle_tx_ui(lle, NULL, 0, false); + rc = gprs_llc_lle_tx_ui(lle, NULL, 0, false, radio_prio); break; } -- To view, visit
https://gerrit.osmocom.org/c/libosmo-gprs/+/33958
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmo-gprs Gerrit-Branch: master Gerrit-Change-Id: I2ace165003469c2a43d7333634171896699d5a5d Gerrit-Change-Number: 33958 Gerrit-PatchSet: 2 Gerrit-Owner: pespin <pespin(a)sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge(a)osmocom.org> Gerrit-Reviewer: osmith <osmith(a)sysmocom.de> Gerrit-Reviewer: pespin <pespin(a)sysmocom.de> Gerrit-MessageType: merged
1 year, 11 months
1
0
0
0
← Newer
1
...
24
25
26
27
28
29
30
...
306
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
Results per page:
10
25
50
100
200