Commit Graph

188 Commits

Author SHA1 Message Date
Pau Espin 4b4c2ec4b3 bts-trx: Avoid enqueueing consecutive duplicate messages to TRX
While debugging other protocol/timing issues between osmobts-trx and osmo-trx,
I found that sometimes two consecutives "POWER OFF" commands are
enqueued and sent to osmo-trx.
There's no point in doing so, as the write queue already maintains state
and retries the command until a RSP is received, then goes for the next
one.

With this change we hence improve timing response as we don't need to
wait for the second command to be processed, and on top we get cleaner
logs and simplified states which are easier to debug.

Change-Id: Ib6a5e7bfac8bc5e1b372da6a1f801c07a3d5ebb7
2017-12-10 14:05:57 +00:00
Pau Espin 62b575db67 bts-trx: trx_ctrl_cmd: Simplify var assignment logic
Change-Id: I9250e3003cff24035440bbba3e1171650dc83209
2017-12-10 14:05:36 +00:00
Harald Welte 70c4dc8d70 osmo-bts-trx: Fix reported frame number during PRIM_INFO_MEAS
The upper layers (L1SAP, the common part of L1) *always* require frame
numbers in the uplink direction to be reported as the frame number of
the *first* burst, not the last burst of a given block.

This is particularly important in the case of passing up measurement
information, as we use this frame number to detect if the measurement
interval for that specific timeslot has just ended (and hence we must
process the measurements and send an uplink measurement report to the
BSC.

Before this patch, the measurement results were reported with the *last*
frame number, which caused the common/measurement.c code never detect
the end of a measurement window.

On TS2, tons of the following log messages were observed:
<0004> measurement.c:199 (bts=0,trx=0,ts=2,ss=0) no space for uplink measurement, num_ul_meas=104

With this patch, it behves as expected:  the measurements of 25 blocks
(= 100 bursts) are aggregated, after which point the report is computed
and sent.  Subsequently, num_ul_meas is reset to 0 and the cycle
restarts.

Related: OS#2329
Change-Id: I1065ae9c400bb5240a63ab8213aee59aeb9ceeff
2017-12-04 13:25:34 +00:00
Harald Welte cbcd3c5034 scheduler_trx: L1P is for PH (data), L1M for MPH (control)
Almost all log statements in scheduler_trx.c were using the wrong
logging subsystem.  Let's fix this.  Also, make it more obvious from
the log subsystem help text

Change-Id: I4312f8ab0414eb38db0d62f05c95ab961f500c14
2017-12-02 21:05:34 +01:00
Harald Welte 62a6a2680f scheduler: Harmonize log line format; Always print TS name + decoded FN
Change-Id: I5703b46c8a59fe00a3cdc063bcf72872980ec5e5
2017-12-02 21:05:34 +01:00
Harald Welte bb8037b7eb trx: Don't assume phy_instance_by_num() returns non-NULL
In trx_clk_read_cb(), when calling phy_instance_by_num(), that
function might in error cases return a NULL phy-instance. Let's
put an OSMO_ASSERT() there as safeguard to avoid NULL dereference
when dereferencing pinst->trx->bts.

Fixes: Coverity CID#178657
Change-Id: If6b6b45380368e9ee9e03ca1eb7ac56c21e72b03
2017-11-06 03:00:08 +09:00
Harald Welte 8e202b595c trx: Don't call osmo_fr_check_sid with negative 'rc'
In rx_tchf_fn(), if gsm0503_tch_fr_decode() returns a negative
result, we cannot use that result as length argument to
osmo_fr_check_sid()

Change-Id: Ic4080b5bf6c865be3333f923f19a2340e1e272c8
Fixes: Coverity CID#178659
2017-11-06 02:56:41 +09:00
Harald Welte d8d402099f trx: Avoid NULL+1 dereference in trx_ctrl_read_cb()
We unconditionally pass "p+1" into sscanf() despite not knowing
if 'p' is NULL or not.

Change-Id: I40a49c3feb3b55ef577eebd7d567afdbcfe0d624
Fixes: Coverity CID#178661
2017-11-06 02:54:36 +09:00
Harald Welte 6733906f62 trx: Better be safe than sorry before calling strlen
There's a lot of pointer arithmetic in trx_ctrl_read_cb which is
not so nice.  While I believe the current code is safe, Coverity
raises "CID 178665:  Insecure data handling  (INTEGER_OVERFLOW)"
regardin the use of rsp_len in the strcmp().

Let's put some OSMO_ASSERT() in front and hope that makes Coverity
happy.

Change-Id: I5a9b3307f83cdde7c8e9f66932446604f5623b05
2017-11-06 02:50:21 +09:00
Neels Hofmeyr 0c9bc5422a osmo-bts-trx: vty: various fixes of 'write file' and doc
On 'write file':
- Write 'osmotrx' before 'maxdly' and 'maxdlynb' (broken since "Introduce new
  phy_link and phy_instance abstraction"
  d784e50747)
- Fix indenting of 'write file' output, command 'osmotrx timing-advance-loop',
  had a stray space in case there is not a 'no' preceding it.

Add some missing instances of OSMOTRX_STR doc strings.

examples/osmo-bts.cfg:
- Drop 'settsc', the command no longer exists.
- Fix indenting of 'osmotrx rx-gain' command.

osmo-bts does not feature VTY tests, so it is pointless to add example files to
test these fixes. We should probably add VTY tests separately.  However, I have
briefly tested manually (and hence found all of these issues).

Change-Id: I018eaef40345bfa26e12eb7d09e83a52596c1000
2017-10-18 14:02:30 +00:00
Max ec33b0397f Remove build dependency on legacy OpenBSC
* copy-paste gsm_data_shared.* from OpenBSC master
* remove corresponding configure check and option
* remove .deb dependency

Actual refactoring with removal of unnecessary structures/parts, moving
common OpenBSC/OsmoBSC parts into libraries etc. are left for further
patches.

Current patch will make coexistence with *BSC easier and will simplify
our build infrastructure.

Change-Id: I9f004fb5c4c1db29d4792dfd281d388c7063da13
Related: OS#1923
2017-10-08 18:40:09 +02:00
Max 9e36dca82a trx: avoid deactivating lchan on LCHAN_REL_ACT_REACT
* do not deactivate lchan when called with LCHAN_REL_ACT_REACT
* add fixme comment

It's unclear yet if any special steps are required for osmo-bts-trx so
let's just make it compatible with setups [1] using BS_AG_BLKS_RES != 1
for now.

Background: CCCH is auto activated by some OsmoBTS - before we receive
SI3, see 4a85828462. To accommodate for
that we deactivate CCCH in common/rsl.c, which triggers BTS-model
specific callback sapi_deactivate_cb() which updates parameters and
activates it again.

In case of osmo-bts-trx there is no auto-activation and (seems to be) no
need in special interaction with hw to activate channel (no
lchan_activate()) hence we can just skip entire
deactivate/setup/activate again routine.

[1] "channel-descrption bs-ag-blks-res N" in OpenBSC config file.

Related: OS#1575
Change-Id: I20b89ba1e43d1414180b083cd1e085eeffe5d513
2017-09-02 19:44:54 +00:00
Pau Espin 8876a507ff osmo-bts-trx: Relax validation to allow TRX data bursts without padding
Original OpenBTS transcievers add 2 bytes of padding to the end of data
bursts, having in total 158 bytes. As those two extra bytes are being
ignored after the initial validation, let's relax this validation a bit
in order to accept transcievers that decide no to send these two extra
bytes.

Change-Id: I94c3cb160bfed0ba9c41ed7ef5f8d8a65b81ad07
2017-08-25 09:34:51 +00:00
Max aa11997480 osmo-bts-trx: remove global variables from loops
* move TA related globals into phy_link
* move power loop related globals into phy_link
* prefix corresponding vty vars with osmotrx

Change-Id: I01d7c1abad67e51b886a4ecf2de072929d67da27
Related: OS#1848
2017-08-24 19:06:48 +00:00
Max 9a30b77813 osmo-bts-trx: fix 'osmotrx legacy-setbsic'
It was introduced in fe6c75d24a1751341bcee91cb45c7ac7f5d07da3:

* fix typo in config write
* add missing vty help string

Change-Id: Id42359dfbb8ad02f34dd2540db66f3ed69ad5181
2017-08-24 19:06:48 +00:00
Alexander Chemeris 2bbf98afa3 Fix static build of osmo-bts-trx and osmo-bts-virtual.
New libosmocore has some plugin system which requires dlopen(). So we need
to make sure we always link with libdl, even when building statically.

Note that this doesn't fix static build of tests - they are still failing
with some errors.

Change-Id: I8315d6e032e34528def268a49fd88d07bc06ab2e
2017-08-20 19:29:30 +00:00
Alexander Chemeris ed662e0799 osmo-bts-trx: Increase a maximum allowed MS power reduction step from 2dB to 4dB.
We tend to start MS with high power to make sure distant phones get good QoS,
but this also means that we need to reduce their power rather quickly. OTOH
we can't make this step too high because this may lead to power output
oscillation. From my (manual, limited) testing 4dB looks like a reasonable
compromise.

Change-Id: I58785513e5739474b881ed7f2a312ecc690e7e60
2017-08-20 01:45:29 +03:00
Alexander Chemeris b0578dda95 osmo-bts-trx: Remove an unused variable. Resolves a compiler warning.
Change-Id: I2464e872f81021cbc3ccbc4e2e32c394d6afcf70
2017-08-19 22:38:20 +00:00
Alexander Chemeris d4450051fc osmo-bts-trx: Fix MS power control loop.
The following two commits from 2014-12-06 introduced a new variable to control
MS power - ms_power_ctrl, but kept the old ms_power variable in place. They
have also changed the meaning of the ms_power variable - it now keeps original
RSL configured value. So when much later osmo-trx-bts code was merged to master
the code was compiling fine and this change in the meaning was overlooked.

In osmo-bts:
579651bf30 power/sysmobts: Add a manual ms power level control
In OpenBSC:
f6f86b0eec18da165db136b14bf2db87fde4b4ac osmo-bts: Introduce new struct for a power loop in the BTS code

Change-Id: I713e39b882db32a0d17aa04790d16fa79afa1fb1
2017-08-19 22:35:10 +00:00
Pau Espin 506a7f98b2 osmo-bts-trx: Enable osmotrx tx-attenuation oml by default
There are currently two ways to specify power reductions to be sent to
osmo-trx from osmo-bts-trx:
* osmotrx tx-attenuation oml
* osmotrx tx-attenuation <0-50>

None of them is enabled by default, which means if none of them is
specified in the config file of osmo-bts-trx, SETPOWER cmd won't be sent
to osmo-trx, which in turn won't turn on the transciever.

Let's enable osmo tx-attenuation oml by default and leave it up to the
bsc to decide which power reduction to use. If the user wants to
configure a specific tx-attentuation, it can still do so in exactly the
same way he used to do it.

Change-Id: Ia8640751630ee37e5f5d1f470bad892a08e80654
2017-08-15 14:59:04 +02:00
Harald Welte fe6c75d24a TRX: Remove global variables, move SETBSIC/SETTSC handling into phy_link
Whether or not we are talking to an OpenBTS (SETBSIC) or OsmoTRX
(SETTSC) transceiver is a property of the phy_link, and not a property
of the BTS.  Also, we *really, really* should never use global
variables. I'm very happy this is being cleaned up, finally.

Change-Id: I51aeb17661dfd63ff347f7b2c0d7ffa383ec814c
2017-08-09 13:03:33 +00:00
Harald Welte cd1b08b14f TRX: Remove bogus extern global variable declarations
Those global variable declarations for non-existing variables were
introduced in 8a8d73a691, let's remove
them again.  The source / destination IP address is a parameter of the
phy_link, and not a global variable.

Related: OS#1848
Change-Id: I94b5f934fc3bd00b0467d90029d3053b16594186
2017-08-09 11:18:46 +00:00
Harald Welte d6da809d2f TRX / VIRT-PHY: Make check for BCCH/CCCH more specific
In bts_model_l1sap_down() we want to identify BCCH/CCCH channel numbers,
but our check is a bit non-specific.  Let's make the check more specific
to only cover the BCCH, Uplink CCCH and Downlink CCCH C-bits as defined
n 3GPP TS 08.58 Section 9.3.1

Change-Id: Ia20ab09b96c87c0dfbfaf98e5b2a8d36423fac67
2017-07-30 17:38:37 +02:00
Pau Espin db4ab8e5ce cosmetic: Move error goto path to the end of the function
Change-Id: I3ad15a9edbfe74de3deb7298441d54fd9d0178ad
2017-07-24 22:00:00 +00:00
Pau Espin 69de62a573 cosmetic: scheduler_trx.c: Add function to get rid of ugly goto path
Change-Id: I9c2e166e6f182f703ccf49aa883c223e377c8421
2017-07-24 22:00:00 +00:00
Pau Espin 9dccaa2064 cosmetic: scheduler_trx: Remove trailing whitespace
Change-Id: Ib057b5e5219ad2acfaee2dcc9ade098daa9ac985
2017-07-24 21:59:59 +00:00
Harald Welte 9b97d0f683 TRX: permit transmission of all-zero loopback frames
For some reason, osmo-bts-trx attempted to interpret/validate the
contents of the downlink TCH block that it was about to transmit.  If
such checks are made, they should clearly be in the common part above
L1SAP, and not in the bts-model specific part.

Also, having the checks in place didn't allow us to send an all-zero
downlink block, as is required for detection of uplink FER in a loopback
testing setup, e.g. with CMU-300.

Change-Id: I6388de98e4a7e20843a1be88a58bba8d2c9aa0d5
2017-07-02 07:02:29 +00:00
Harald Welte cc1602f592 TRX: don't free l1h in trx_phy_inst_close()
l1h is allocated in bts_model_phy_instance_set_defaults() and not in
trx_phy_inst_open().  Hence, trx_phy_inst_close() should not free() it!

Change-Id: I0ac4e57a882e5a31143499c1662d8d8e52320938
2017-07-01 07:38:03 +00:00
Harald Welte f2eaba8869 TRX: merge/simplify l1_if and trx_if code
Related code / function structure still dates back to the pre-phy_link
days.  Let's clean this up to make things less convoluted and reduce the
number of non-static symbols needed between code split over two files.

Change-Id: I1f30ae1f547a5c01c516d4a05032193294c25f2d
2017-07-01 07:38:01 +00:00
Harald Welte cdf20fec7c TRX: Rename trx_if_data() -> trx_if_send_burst()
The new name makes it clear what the function actually does: Send burst
data via the trx interface.

Change-Id: I5031541d4ae4244a62a18acf71139db2874927fa
2017-07-01 07:38:01 +00:00
Harald Welte bb71947829 trx_if: Improve error handling
There ware some error conditions that the previous code didn't catch
and/or report, such as unparseable TRX control strings, non-terminated
buffers, ...

Change-Id: I354d0c121880553ce1bd59b7394d52b104b7d6da
2017-07-01 07:38:01 +00:00
Harald Welte c19ab9ed2f TRX: trx_if: Improve code description / comments
Change-Id: I4e19d68782a12e52ba1d3ba2665060275d04866c
2017-07-01 07:38:00 +00:00
Philipp Maier b7425f3642 osmo-bts-trx: fix missing frame number in MEAS IND
The layer 1 interface (l1_if.c) for osmo-bts-trx does not include
the frame number into the measurement indications it forwards
to higher layers. The frame number is required to properly
detect the end of a measurement period.

Change-Id: Ife3c791ff50e8a866a97b9783ac7ef3ef2402a70
2017-06-29 17:29:56 +02:00
Harald Welte 53ce11ab95 TRX: Use timerfd and CLOCK_MONOTONIC for GSM frame timer
using gettimeofday() is not suitable for the GSM frame timer, as it
relies on the normal 'wall clock' system time, which may be adjusted by
ntp, gps or other means at runtime.

Switching to a different clock source means we cannot use
osmo_timer_list anymore, but timerfd integrates just fine with our
libosmocore select() loop handling.

Change-Id: I51b19adde14ebb7ef3bb863d45e06243c323e22e
Closes: #2325
2017-06-28 23:43:28 +00:00
Vadim Yanitskiy 0b7a3e9f62 scheduler_trx.c: strip unused variable
Change-Id: I870dad2a00f68cca1c31a719221fc30a07b30c20
2017-06-15 14:40:21 +00:00
Vadim Yanitskiy 0227e4d04c cosmetic: fix some typos
Change-Id: Ib9172735bc7a05d9d7425a0e66dd90ff2569ee05
2017-06-15 14:40:21 +00:00
Max de9357251c Set and report BTS features
Set (possibly incomplete) list of BTS model-specific features and report
them in response to attribute request via OML.

Change-Id: I5f8a6681c3562ec261441e84dde6e085b516d92f
Related: OS#1614
2017-06-15 12:55:16 +00:00
Pau Espin e3a3906ee9 trx: Save osmotrx base-port vty properties
Change-Id: I0898a8c4eb3899fc1c0f6b17da33b8c7851b90d6
2017-06-06 19:48:53 +00:00
Pau Espin 8a8d73a691 trx: Allow BTS and TRX to be on different IPs
Depends on libosmocore I3c655a4af64fb80497a5aaa811cce8005dba9cd9

Change-Id: I0bd34b7b02c1a9b0c6f6f89f327b486e5620c8d5
2017-06-06 19:23:18 +00:00
Harald Welte 43c763f5af osmo-bts-trx: Remove duplicate parsing of NM_ATT_CONN_FAIL_CRIT
For some reason, osmo-bts-trx did another take at parsing
NM_ATT_CONN_FAIL_CRIT and storing the second octet in
btsb->radio_link_timeout, just like the generic code already does in
oml_rx_set_bts_attr(), but without proper checking and any error
message.  Let's remove it.

Change-Id: Idb0179e1443c0b5a97e59919dba684a001e90192
2017-05-29 19:55:30 +00:00
Harald Welte 05ba5c2a10 Consistently check for minimum attribute/TLV length in RSL and OML
Make more use of TLVP_PRES_LEN() instead of plain TLVP_PRESENT() and
implicitly assuming a certain length of the information element.

What this obviously doesn't introduce is some kind of error
generation/reporting in case the minimum length is not fulfilled.  An IE
that's too small is silently ignored by TLVP_PRES_LEN() and treated as
if the IE wouldn't exist in the first place.

Change-Id: If5c4eee65711c49bc8ba4675221b1d5fd16198e9
2017-05-29 19:55:30 +00:00
Harald Welte ed9e022eb4 rx_tchh_fn(): Avoid copy+pasting formula to determine odd-ness of fn
Change-Id: Ic2a0bdaa70cc28c1ce8237351b0a0c6b998cf0a3
2017-05-27 08:24:05 +00:00
Harald Welte a493ce9e66 scheduler_trx: Avoid copy+pasting determining CMR from FN
instead, let's introduce a specific function for that.  Also, as this
can be easily determined from the frame number, skip one argument to
tx_tch_common().

Change-Id: Ibbb9b685cf0b6a45339b0874438a500dd6254bc2
2017-05-27 08:24:05 +00:00
Harald Welte 031e8fedac scheduler_trx.c: Avoid code duplication for BER10k computation
Use an (inline) function rather than code copy+pasting

Change-Id: I42e76a4707968e428cbd2e43d5df71ef445efece
2017-05-27 08:24:05 +00:00
Harald Welte b4c9c8f35d scheduler_trx.c: Fix typos, improve comments, cosmetics
Change-Id: I5e2ce70aea8d62657ce3a7d6c16e5a7f8b76c22f
2017-05-27 08:24:05 +00:00
Harald Welte ed51c3d145 Remove unusued left-over gsm0503_conv.c
gsm0503_conv.c should have been removed as part of
efbef50efc but somehow was left here. It's
not referenced/compiled by the Makefile anymore, and the gsm053_conv.c
in libosmogsm has superseded it anyway.

Change-Id: Icdcca1bc55a83c76ec47918dc4dd301155210091
2017-05-27 08:24:05 +00:00
Max efbef50efc osmo-bts-trx: use libosmocoding
Remove built-in functions and use libosmocoding instead.

Change-Id: I1b41bb1a8de655639107ec1f3b75afc240fd316f
2017-05-22 09:37:26 +00:00
Max 8913b29be2 Set BTS variant while initializing BTS model
This will allow proper BTS attribute reporting via OML in follow-up
patches.

Change-Id: I1c49d6c39fb4dac7a46ee25ceacf4c6ef0f0b736
Related: OS#1614
2017-05-10 07:50:00 +00:00
Vadim Yanitskiy 028820510e osmo-bts-trx/l1_if.c: cosmetic: drop double check
Change-Id: I25a8f85ee65e1c0dd54049ffacc039702ca36c8f
2017-05-09 22:18:19 +00:00
Vadim Yanitskiy 957843959d osmo-bts-trx/l1_if.c: use channel combination III for TCH/H
Currently the channel combination II is used for TCH/H, which
allows only one lchan to be allocated. The reason is that it
saves a bit of CPU by disabling UL burst detection on lchan 1.

There is also the channel combination III, which allows to
increase channel capacity, providing two lchans on a single
TCH/H timeslot.

Ideally we should implement some dynamic II <-> III switching
depending on the network load level. But for now this change
replaces the channel combination of TCH/H by III, until dynamic
switching is implemented.

Fixes issue: https://osmocom.org/issues/1795

Change-Id: I8fd4abb42c153fcd26bcfe22a2554b5c2d02d810
2017-03-23 11:35:05 +00:00