aboutsummaryrefslogtreecommitdiffstats
path: root/src/osmo-bts-trx/trx_if.c
AgeCommit message (Collapse)AuthorFilesLines
2018-02-27trx/scheduler: Use integer math for TOA (Timing of Arrival)Harald Welte1-6/+6
There's no need to express TOA as a float: * We receive it as signed 16bit integer in units 1/256 symbol periods * We pass it to L1SAP as signed integer in 1/4 symbol periods So turn it into an int16_t with 1/256 symbol period accuracy throughout the code to avoid both float arithmetic as well as loosing any precision. Change-Id: Idce4178e0b1f7e940ebc22b3e2f340fcd544d4ec
2018-01-19bts-trx: Detect duplicated responses for retransmitted commandsPau Espin Pedrol1-2/+16
It was detected that under some conditions, osmo-trx (with limesdr) may take a long time to answer to CMDs, which means trx_ctrl_timer will trigger re-transmitting the last sent but yet unacked CMD. Due to the high latency in osmo-trx, the original AND the rentrasnmited CMD are handled after a while and RSP messages are sent for both. When osmo-bts-trx receives the first RSP, it was marking the CMD as acked and carried on with next one. Then, when the RSP from the retransmited CMD arrives, it already lost state and doesn't know where does that come from. As a result, osmo-bts-trx shutdowns. The issue can be seen in the following truncated log from osmo-bts-trx with TRX category enabled: 20180117135228175 Enqueuing TRX control command 'CMD RXTUNE 1782000' 20180117135228175 Enqueuing TRX control command 'CMD TXTUNE 1877000' 20180117135228175 Enqueuing TRX control command 'CMD SETTSC 7' 20180117135228175 Enqueuing TRX control command 'CMD POWERON' 20180117135228175 Enqueuing TRX control command 'CMD SETRXGAIN 1' 20180117135228175 Enqueuing TRX control command 'CMD SETPOWER 20' 20180117135228175 Enqueuing TRX control command 'CMD SETSLOT 0 5' ... 20180117135249829 Response message: 'RSP POWEROFF 0' 20180117135249855 Response message: 'RSP RXTUNE 0 1782000' 20180117135249876 Response message: 'RSP TXTUNE 0 1877000' 20180117135249876 Response message: 'RSP SETTSC 0 7' 20180117135250648 Response message: 'RSP POWERON 0' 20180117135251150 Response message: 'RSP SETRXGAIN 0 0' 20180117135253151 No response from transceiver for phy0.0 (CMD SETPOWER 20) 20180117135253777 Response message: 'RSP SETPOWER 0 20' 20180117135254535 Clock indication: fn=2018878 20180117135255777 No response from transceiver for phy0.0 (CMD SETSLOT 0 5) ... 20180117135256858 Response message: 'RSP SETPOWER 0 20' 20180117135256858 Discarding duplicated RSP from old CMD 'RSP SETPOWER 0 20' 20180117135256858 Response message: 'RSP SETSLOT 0 0 5' 20180117135256858 Response message: 'RSP SETSLOT 0 0 5' 20180117135256858 Discarding duplicated RSP from old CMD 'RSP SETSLOT 0 0 5' Change-Id: I3633cba212edde878f83ed36aef922aaca6f503a
2018-01-19bts-trx: trx_if.c: Improve parsing of received RSP messages from TRXPau Espin Pedrol1-69/+127
First the cached CMD sent (struct trx_ctrl_msg) is reworked to have the cmdname and the params in different buffers for easier comparison with RSP later. For the receive path (trx_ctrl_read_cb), new function helpers are added to parse the buffer into cmdname+params+code (parse_rsp) and to compare if a given RSP matches the current CMD we sent (cmd_matches_rsp). The reasoning behind this patch is that a way to check for parameters when receiving a RSP will be needed in future work, as before this patch checking of parameters is ignored. This commit is a preparation for commit to check for duplicated responses. Change-Id: I2474cbc3e4457cf04f78e1c168768295e1132034
2018-01-19bts-trx: trx_if.c: trx_ctrl_read_cb: Move error handling to end of funcPau Espin Pedrol1-6/+7
The move includes a small logic change: If there's a mismatch between the rsp and the cmd, now we bts_shutdown instead of blindly skipping expected RSP and continuing with sending the next CMD in the queue. The change is specially not a problem since next patches are improving the logic furthermore to account for duplicates, different parameters, etc. Change-Id: I7018ded23fe51f364f248ade111aaa80ef46187e
2018-01-19bts-trx: trx_if.c: Log timedout+retransmitted CMDPau Espin Pedrol1-2/+7
Change-Id: Ib573c86a1640640c2a61e80fe1f1412b30342b1a
2017-12-10bts-trx: Avoid enqueueing consecutive duplicate messages to TRXPau Espin Pedrol1-2/+7
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-10bts-trx: trx_ctrl_cmd: Simplify var assignment logicPau Espin Pedrol1-3/+2
Change-Id: I9250e3003cff24035440bbba3e1171650dc83209
2017-11-06trx: Don't assume phy_instance_by_num() returns non-NULLHarald Welte1-0/+2
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-06trx: Avoid NULL+1 dereference in trx_ctrl_read_cb()Harald Welte1-1/+3
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-06trx: Better be safe than sorry before calling strlenHarald Welte1-0/+2
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-08-25osmo-bts-trx: Relax validation to allow TRX data bursts without paddingPau Espin Pedrol1-1/+2
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-09TRX: Remove global variables, move SETBSIC/SETTSC handling into phy_linkHarald Welte1-10/+8
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-07-01TRX: don't free l1h in trx_phy_inst_close()Harald Welte1-1/+0
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-01TRX: merge/simplify l1_if and trx_if codeHarald Welte1-55/+92
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-01TRX: Rename trx_if_data() -> trx_if_send_burst()Harald Welte1-1/+1
The new name makes it clear what the function actually does: Send burst data via the trx interface. Change-Id: I5031541d4ae4244a62a18acf71139db2874927fa
2017-07-01trx_if: Improve error handlingHarald Welte1-3/+8
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-01TRX: trx_if: Improve code description / commentsHarald Welte1-13/+54
Change-Id: I4e19d68782a12e52ba1d3ba2665060275d04866c
2017-06-06trx: Allow BTS and TRX to be on different IPsPau Espin Pedrol1-32/+11
Depends on libosmocore I3c655a4af64fb80497a5aaa811cce8005dba9cd9 Change-Id: I0bd34b7b02c1a9b0c6f6f89f327b486e5620c8d5
2016-12-01trx: Add "maxdlynb" VTY command to control max TA for Normal Bursts.Alexander Chemeris1-0/+5
Originally `maxdly` command in osmo-trx was contrlling max TA for Normal Bursts. This was not a proper behaviour, because it was used to "control maximum distance a handset can attach from" which is controlled by Access Bursts max TA. Osmo-trx was corrected to apply `maxdly` to Access Bursts and a new command was introduced to contrl max TA for Normal Bursts - `maxdlynb`. This patch adds support for this configuration command into osmo-bts-trx. If you wonder why would you need that - some test equipment (namely R&S CMD57) has really bad timing sync and can generate signal a few symbols off. That prevents osmo-trx from properly receiving otherwise perfectly good bursts generated by CMD57. This configuration is a solution for this. Change-Id: Ib5d255299668ac1ef9f0ce95e016f55ba3c82277
2016-08-08osmo-bts-trx: Fix PCS1900 operationMike McTernan1-2/+12
As the ARFCN numbers in DCS (1800) and PCS (1900) are not unique, we need to specify the band in the upper bits of the ARFCN value before calling gsm_arfcn2freq10(). Change-Id: I637b76bc1fc749eed8e364412d76606589991c02
2016-07-28trx: Enable EGPRS handling through burst lengthsTom Tsou1-11/+20
Existing interfaces are coded with the implicit expectation of using a burst sequence length of 148, which is constant with GSM and GPRS. That changes with EGPRS, where the burst length may be 444 due to the use of 8-PSK instead of GMSK modulation. Setup the interface to accept and return a length value with the burst sequence. This allows 444 length bit vectors to/from the EGPRS decoder/encoder. Length is explicitly used as a identifier for 8-PSK vs. GMSK modulated sequences. Change-Id: I90b46b46b11b6ce280e7f8232d5a2fccec2d4f18 Signed-off-by: Tom Tsou <tom.tsou@ettus.com>
2016-06-22Clarify logging messageMax1-1/+1
Change-Id: I3c7be592f4cbdd553f07c4a7084478706a7bd644 Related: OS#1648
2016-06-16TRX: Add vty command to power on/off transceiverMax1-3/+4
Add vty command (under "phy X instance Y" hierarchy) to manually send POWERON or POWEROFF command. It's useful for debugging issues related to BTS/TRX initialization. Change-Id: I6dfebaf118cdf5ad144516b2b839b17350a73ce4 Related: OS#1648
2016-06-16Fix OML activationMax1-1/+3
Previously software activation could have been reported multiple times which broke proper BTS init. Introduce guard variable to ensure reporting happens only once. Note: this is just minimal workaround - ideally proper OML state machine should be implemented. Change-Id: Ifffbdb756bc5d2864f985c01a3299b839c4de7af Related: OS#1648
2016-02-15Introduce new phy_link and phy_instance abstractionHarald Welte1-39/+94
This way we can model a flexible mapping between any number of PHYs, each having multiple instances, and then map BTSs with TRXx on top of those PHYs.
2016-02-15TRX: Move scheduler to src/commonHarald Welte1-1/+1
This is the final step to make the L1 scheduler generally available to other BTS models than OsmoTRX.
2016-02-15TRX: scheduler: Move trx_sched_clock() to scheduler_trx.cHarald Welte1-2/+3
This funciton (and associated static functions) are TRX specific, and scheduler.c should only contain generic code.
2016-02-15TRX: scheduler: don't access l1h->config from schedulerHarald Welte1-0/+4
2016-02-15TRX: factor out the scheduler from remaining codeHarald Welte1-1/+1
The L1 scheduler is a generally useful component that is unfortunately tied quite a bit into the OsmoTRX support. Let's try to separate it out by having separate per-trx/per-ts/per-chan data structures pre-fixed with l1sched_ Using this patch it should be one step easier to use the scheduler for other BTS models, such as the intended upcoming virtual BTS.
2016-01-16TRX: replace some more 2715648 magic numbers with GSM_HYPERFRAMEHarald Welte1-3/+3
2015-09-22trx: fix potential use of uninitialized toa variable.Alexander Chemeris1-1/+1
Not really a bug, as we're smart about it down the stream, but it's better to be strict here as well.
2015-09-22trx: Send POWERON/OFF commands to osmo-bts only for the first channel.Alexander Chemeris1-2/+8
osmo-trx never supported separate power control for trx's, but now it started to be more strict about it.
2015-09-22TRX: Check if Transceiver indicates an out of range clockAndreas Eversberg1-7/+15
If frame number is out of range (>= 2715648), the scheduler's process would end up in an infinite loop. This is because the loop would schedule bursts until the indicated frame number is reached, which would not be possible. The openbts, calypso-bts and osmo-trx might send out out of range clock indications every 3.5 hour.
2015-09-22TRX: Show which TRX does not respond or rejects a commandAndreas Eversberg1-3/+4
2015-09-22TRX: Handover access burst supportAndreas Eversberg1-0/+10
2015-09-22TRX: Fixed typos tranceiver -> transceiverAndreas Eversberg1-12/+12
2015-09-22TRX: Fix: Cleanly free TRX instances during initialization in case of an errorAndreas Eversberg1-3/+3
2015-09-22TRX: Add VTY options to enable and disable SETTSC and SETBSICAndreas Eversberg1-2/+12
2015-09-22TRX: Implementation of MS power and timing advance loopsAndreas Eversberg1-1/+13
2015-09-22TRX: Improved handling of clock indications.Andreas Eversberg1-1/+4
If no clock is received, a POWEROFF is sent until clock is detected.
2015-09-22TRX: Fixes to TRX interfaceAndreas Eversberg1-6/+7
Ignore false response to uncritical commands.
2015-09-22TRX: Minor fixes, especially handle TOA of RACH correctlyAndreas Eversberg1-3/+3
2015-09-22TRX: Use received TRX clocks to determine availablility of tranceiverAndreas Eversberg1-0/+6
Only if transceiver becomes available, control commands are sent. If tranceiver is gone, reset scheduler. The current availability state is sent to BSC via OML state change commands.
2015-09-22TRX: On negative response of critical commands, shutdown BTSAndreas Eversberg1-23/+31
2015-09-22TRX: Introduce osmobts-trx, a layer 1 implementation for OpenBTS tranceiversAndreas Eversberg1-0/+495
The code is quite complete, TCH and PDCH channels are not yet tested.