Commit Graph

665 Commits

Author SHA1 Message Date
Harald Welte 54eceac257 l1sap: sysmobts: remove obsolete get_lapdm_chan_by_hl2() 2015-09-22 16:39:03 +02:00
Harald Welte d410eb9787 l1sap: correctly set chan_nr on PRIM_PH_RACH / INDICATION
In case of a RACH INDICATION on CCCH, we need to set CHAN_NR to
0x88 (RSL_CHAN_RACH).  In other cases, chan_nr needs to reflect
the actual logical channel (TCH/SDCCH) on whcih the handover happened.
2015-09-22 16:39:02 +02:00
Harald Welte 9ae5b50d78 l1sap: RACH: Detect hand-over even on TRX0
I don't understand why we would detect handover only on TRX1-n,
but not on TRX0.  It is perfectly valid for a handover to occur
on TRX0.
2015-09-22 16:39:02 +02:00
Harald Welte 52476fc1d4 l1sap: fix missing include file and resulting compiler warning 2015-09-22 16:39:02 +02:00
Harald Welte e969f08892 l1sap: fix coding style 2015-09-22 16:39:02 +02:00
Harald Welte 7b1b832618 l1sap: Use L1SAP_IS_CHAN_RACH instead of magic number 0x88 2015-09-22 16:39:02 +02:00
Andreas Eversberg e0146997a6 Add RACH message to PH-/MPH-/TCH-SAP interface
This part moves RACH message primitives from osmo-bts-sysmo to common
part.
2015-09-22 16:39:02 +02:00
Harald Welte a391d3691a l1sap: Split ph_data_req() into smaller parts
... in an effort to avoid introducing new/more spaghetti code

Also, use offsetof() instead of pointer calculation to determine
the start of GsmL1_Prim_t.u.phDataReq.msgUnitParam.u8Buffer
2015-09-22 16:39:02 +02:00
Andreas Eversberg 5e90f2a809 Add BCCH message to PH-/MPH-/TCH-SAP interface
This first part moves BCCH message primitives from osmo-bts-sysmo to common
part. A new file "common/l1sap.c" is introduced to implement handling of
layer 1 messages from/to BTS model.
2015-09-22 16:39:02 +02:00
Holger Hans Peter Freyther 1eaa3d72ea audio/rsl: Honor the speech mode and don't send anything
Spotted by Ciaby while debugging an audio issue. Do not
send anything to port==0 to the BSC/NITB. Look at the
upper bits of the speech_mode to determine if sending is
allowed. 0x1 means recv_only and all other modes allow us
to send.

Manually verified with a single phone call with LCR bridge
mode to send a CRCX early but a MDCX sendrecv later. The
audio starts to flow after the MDCX message. Virtual Addr
space didn't increase over 10 calls. The l1p_msg is freed
by the caller.

The code might not re-set speech_mode from one call to
another but if it is ever != 0 it can be expected that
the BSC will always set it. This is because we do not
(and don't want to) allocate the lchan dynamically on
every usage.

Fixes: SYS#2111
2015-09-21 14:34:22 +02:00
Holger Hans Peter Freyther 668f8df3be audio/rsl: Include statistics for one call
Use the new libosmo-abis API to query the session for the
statistics and then send it as a TLV element to the BSC.
This can be used to do post processing about the call. E.g
to figure out if no audio arrived at all.
2015-09-21 14:34:07 +02:00
Holger Hans Peter Freyther cc4a08bdc7 audio/rsl: Include the connection identifier in the DLCX ind
I have traces that include the connection identifier in the
DLCX indication.
2015-09-21 10:14:11 +02:00
Holger Hans Peter Freyther a7c276b72b meas: Do not send incomplete measurement reports
The RSL_IE_MEAS_RES_NR is mandatory element with a minimum
of 5 octets (two for TL and three for the value). When we
establish a new channel we might not have had enough time
in a TDMA frame to calculate the average. The issue is not
easy to reproduce. At the point we receive the measurement
report we have two uplink measurements queued. As it is not
easy to reproduce and only occurs when a channel is new
I have decided to drop the message instead of sending made
up uplink measurement reports.

As of now lchan_build_rsl_ul_meas will always return 3 and
the condition will never be false.

Avoids: SYS#1781
2015-07-14 09:55:56 +02:00
Holger Hans Peter Freyther f869a95f3b write_queue: Check the result of osmo_wqueue_enqueue and free
The write_queue is designed to have a maximum amount of pending
messages and will refuse to take new messages when it has been
reached. The caller can decide if it wants to flush the queue
and add the message again, create a log. But in all cases the
ownership of the msgb has not been transferred. Fix the potential
memory leak in the failure situation.
2015-03-28 18:31:10 +01:00
Andreas Eversberg 24839068f5 sysmo-bts: Use correct boundaries of L1 msg when forwarding to L1 proxy
In case of a headroom in a message, the 'head' pointer will not point to
the actual data.
2015-03-25 23:19:58 +01:00
Holger Hans Peter Freyther b631bd21d2 power: Make it possible to force a power level
Use the standard RSL commands to order a logical channel
to use a fixed power level.

The code is not fully verified and there was a last minute
change to invoke bts_model_adjst_ms_pwr.
2015-02-05 22:32:53 +01:00
Holger Hans Peter Freyther 579651bf30 power/sysmobts: Add a manual ms power level control
Currently the DSP is instructed to achieve a given uplink
power target but there are circumstances (e.g. EMV testing)
where we need more control over it. The "manual/software/osmo"
power control can only be implemented per TRX and not per
lchan. Add a very very basic control that checks the MS Power
used by the phone, the actual receive level and then adjust
the power.

The code doesn't take the history into account, if the phone
can not reach the requested power level the code will be stuck
(e.g. no timeout based on multiframes). It has a mode for a
fixed power control but no way to set it yet.

The change of the mode requires a restart of the software.
2015-02-05 22:32:47 +01:00
Holger Hans Peter Freyther 0d6946741c sysmobts: Check mgr->calib.bts_conn for NULL
Check the right variable for NULL.

Fixes: CID 1262214
2015-01-10 18:06:29 +01:00
Holger Hans Peter Freyther 84e4dd92d4 sysmobts: Improve some log messages for calib control
* Print the GPS FD that was opened (e.g. to see if it was
  closed again)
* Print the state changes/expectations
* Print the correct to be applied. I wondered if I shouldo do
  a cor = cor * -1.. cor = -cor.. or add CLOCK_CORR(err) macro
  to use it inside the printf and correction and decided the
  gain is not worth the risk.
2015-01-10 09:15:27 +01:00
Holger Hans Peter Freyther 55da9874c0 sysmobts: Create a calibration loop that will be run
Continously run the calibration process. Everytime we call the
reset function classify the outcome. In case of a failure schedule
the next command soon and otherwise wait several hours.

Remember if the process was started through the VTY or the run
loop. In case it can't be started immediately reset and schedule
a new run.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther d8d5f5904f sysmobts: Start the calibration the first time the link is up
After a reboot the system might have been off for a long time
and the currently used value might be wrong. Remember that we
never ran the calibration and execute it on start.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther 9acc82ce4a sysmobts: Initial version to use libgps to determine FIX state
We should only calibrate the clock if there is a GPS fix. Start
gpsd to determine if there is a fix or not. Work around trimble
decoding issues (sent an email upstream). We need to gain some
more experience to see if there memory leaks. We also need to
re-schedule the calibration depending on the outcome.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther c017e309c4 sysmobts: The correction for GPS is in the reverse direction
Change the sign before passing it as correction value. The error
is the difference between the TCXO and GPS. We need to correct by
the reverse of the error. This seems to be different depending on
the clock source we have.

This is a last minute untested change.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther 2e59b20204 sysmobts: Use the ctrl interface for calibration
This runs the entire procedure for calibration with reasonable
error and success checking. It can be triggered from the VTY
of the sysmobts-mgr right now.

What is missing is to hook up with GPSD to check if the system
has a fix and provide a mode that will continously run the
calibration command.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther fd425b1484 sysmobts: Copy more of l1if_rf_clock_info_reset into the CTRL code
The CTRL code should have used/extended the l1_if calibration
code. The sysmobts-mgr code first needs to determine if the
clock adjustment is necessary at all. This is done by first
resetting the counters, then waiting, then asking for the diff
and then applying the correction value. But the reference clock
is only set by the application comand.

Copy more code of l1if_rf_clock_info_reset to set the reference
clock as value. This is leaving some todos inside the code that
will be resolved as part of SYS#835.

Related: SYS#835
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther 50131c125e sysmobts: Begin with calib control from the sysmobts manager
In the long run we will connect to GPSD and wait for a fix and
then run the calibration. The first step is to open (and re-open)
the control connection to the BTS.

As the connection is on localhost there should not be a computation
overhead to always have the connection open. When connecting assume
that the ASYNC connect worked directly as otherwise we get no
notification of the failure.

This looks like a "bug" of libosmo-abis that should check if the
socket has been connected or not.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther 5a03e129a6 msg: Generalize the message structure test
This was taken out of LaF0rge's OML router branch and is now
used by the extended calibration feature.
2015-01-09 21:57:13 +01:00
Holger Hans Peter Freyther b7ebf545e6 cbch: Speculative change to not change CHAN ACK for CBCH
Use the rel_act_kind to not send RSL channel acks for the
CBCH to the BSC. This is similar to what we do for the BCCH
a couple of lines above.
2015-01-06 19:23:02 +01:00
Harald Welte 8fc2630dd4 SMS-CB: Clean up + centralize generation of NULL block 2014-12-30 13:45:02 +01:00
Harald Welte bd988f6ad3 SMS-CB: Use GSM412_SEQ_NULL_MSG rather than 0xf 2014-12-30 13:34:57 +01:00
Harald Welte 1e245336ec SMS-CB: use gsm412_block_type from libosmocore
.. and not our own local re-definition of the structure.
2014-12-30 13:33:54 +01:00
Harald Welte 4457c0d9ba SMS-CB: Use GSM412_ #defines from libosmocore rather than our own 2014-12-30 13:32:52 +01:00
Harald Welte 660116fb9d CBCH: Implement CBCH block segmentation and RSL_MT_SMS_BC_CMD
* CBCH load indications are not yet sent
* The queue length is not yet limited!
2014-12-30 00:32:13 +01:00
Harald Welte b15d2c9d2f Initial CBCH support
This should handle OML channel combinations with CBCH and activate the
CBCH SAPI towards the DSP correspondingly.  What is still missing is
sending any actual information over the CBCH in respons to the
PH-RTS.ind coming up from L1.
2014-12-30 00:28:31 +01:00
Holger Hans Peter Freyther 50dc96507c sysmobts: Include the serial number in the find response
Read the serial number once and format it as a string. In
case no serial number is present -1 will be returned.

Manually tested with a slightly modified version. serial_nr
was the expected one.
2014-12-26 01:46:24 +01:00
Holger Hans Peter Freyther c265bef48c sysmobts: Add slave on/off action for the sysmoBTS2050
Add new power actions for the sysmoBTS2050. This allows to
switch off the secondary/slave when the system temperature
is too high and back on when the normal level is reached.

Do not allow to switch off the master (so remove the enum
value), do not check if the slave is switching itself off.
2014-12-16 20:22:28 +01:00
Holger Hans Peter Freyther 02a2afa962 sysmobts: Comment out the varpoware options that are not implemented 2014-12-16 20:22:28 +01:00
Holger Hans Peter Freyther ffc193443c sysmobts: Add "normal" actions to execute
Instead of keeping state to remember what was done and needs
to be undone this patch introduces actions that will be executed
when the system is back to normal.

By design the system is considered to be in the normal state
and these actions will be only executed after the system is
coming back to the normal state.

One advantage of this scheme is that an operator can decide
that an overheated systems hould be off duty and requires manual
interaction to be allowed back in service.

The change has only been smoke tested

Fixes: SYS#833
2014-12-16 20:22:28 +01:00
Holger Hans Peter Freyther 8968b48643 sysmobts: Remove unused global variables
We do not need to have these variables anymore. Just remove them.
2014-12-16 15:12:56 +01:00
Holger Hans Peter Freyther 641a934931 sysmobts: Read the clock calibration from another place
Read the clock calibration from the place that will be read by
the BTS process. Use the standard eeprom code for doing that.
The code assumes that this and the other eeprom code don't
write/invlidate the others reason. If that assumption would not
be true calls to eeprom_free_resources should be added.
2014-12-16 15:12:55 +01:00
Holger Hans Peter Freyther 69897d7eed sysmobts: Don't list non integer parameters in the help
The command can only read integer parameters. Don't offer
buffers as this will lead to error 22.
2014-12-16 15:09:22 +01:00
Holger Hans Peter Freyther 0d09e75f9c eeprom: Fix brown paper bag introduced a long while ago
91d204e2db while adding checks
to resolve coverity issues. We simply had no one writing to
the eeprom so this was unnoticed for a long time.
2014-12-16 15:09:22 +01:00
Holger Hans Peter Freyther 42cc96e2c1 sysmobts: Add an option to stop the systemd sysmobts.service
For systems without direct access to the PA the best option
is to simply switch off the bts service. This will stop the
transmission which will take load from the DSP/FPGA/RF circuit
and indirectly from the PA as well.

We should introduce "pa-on and bts-on" that can be executed
as "normal" action.
2014-12-12 14:53:23 +01:00
Holger Hans Peter Freyther 8381a6a483 sysmobts: Actions can be executed in all levels
Somebody could decide to switch off the PA in the warning level
already. Support this mode of operation. This means we could have
a config that:

* Enables the PA in the normal level
* Disables it in the critical level

With kdbus or better IPC we could even have the PA and other
parts be represented as service that talk to a bts manager and
then simply execute start/stop requests. This would make the
entire TODO entry irrelevant as state would be managed by
systemd and one can see the time the service was executed.
2014-12-12 14:40:25 +01:00
Holger Hans Peter Freyther 4d4dc26742 bts: Move BTS and children into the enabled state after opstart
With "show bts 0" all objects were still listed as dependency.
Once the BTS has been started.. move all the other objects into
the enabled state. Our OpenBSC OML code doesn't care but people
using the VTY to inspect state will be more happy.

One day... we will create proper statemachines inside the BTS
and the BSC instead of changing the state in the BTS impl.

Fixes: ONW#1330
2014-11-10 15:16:16 +01:00
Holger Hans Peter Freyther 48eb374a96 bts: Start with the site manager being enabled and available
We would never transition the sitemanager to anything. Our SW
does not support SW activation's so we are always ready.

Related: ONW#1330
2014-11-10 15:12:38 +01:00
Holger Hans Peter Freyther 2fa6ef2687 bts: Mark NSVC1 as offline. We do not expose a second NSVC
OsmoBSC> show bts 0
  ...
  GPRS NSVC1: Oper 'Disabled', Admin 'unknown 0x0', Avail 'Off line'
2014-11-10 13:18:59 +01:00
Holger Hans Peter Freyther 6d8bcbd192 bts: Fix typo in OML comment 2014-11-10 13:01:33 +01:00
Holger Hans Peter Freyther b89a5fa55d bts: In case the line isn't created do not exit with code 1
The service file will prevent a re-launch of the sysmobts.service
in case the main process exits with '1'. In case the ethernet is
not available yet the routine would fail and the sysmobts process
will not be restarted.

unable to connect/bind socket: Network is unreachable
<000f> input/ipaccess.c:885 cannot open OML BTS link: Network is unreachable
unable to connect to BSC
root@sysmobts-v2:~# echo $?
2

Fixes: SYS#736
2014-11-10 12:53:22 +01:00
Holger Hans Peter Freyther 1cce69364d abis: Fix compiler warning and remove const from syntax
libosmo-abis doesn't make it easy to have these parameters
as const.. just declare it non-const in the api. We pass
a static string but we know it will not be modified.
2014-11-10 12:02:45 +01:00
Holger Hans Peter Freyther 8332e29c9f tch: Avoid compiler warnings when using the direct RTP mode
tch.c: In function 'l1_to_rtppayload_amr':
tch.c:247:29: warning: unused variable 'amr_mrc' [-Wunused-variable]
  struct amr_multirate_conf *amr_mrc = &lchan->tch.amr_mr;
                             ^
tch.c: In function 'rtppayload_to_l1_amr':
tch.c:335:10: warning: unused variable 'amr_if2_core_len' [-Wunused-variable]
  uint8_t amr_if2_core_len = payload_len - 2;
2014-11-10 11:59:53 +01:00
Holger Hans Peter Freyther be63f03254 sysmobts: Call the routine send and receive instead of get 2014-11-10 11:58:21 +01:00
Andreas Eversberg 9f22fcfd36 Correctly fill system information messages from BSC
SI 5*/6 require L2 header of 0x03,0x03. All SI might be less than 23
octets, so they need to be filled with 0x2b.
2014-08-27 23:45:47 +02:00
Harald Welte 11b14fd662 tx_power: Check actual TRX output power against intended value
We use the completion call-back from L1 to compare the instructed
TRX board output power with the actual value as reported  back from
L1.

Right now we only print an error message in case the values disagree.

In the future we might want to either use that value as part of our
calculation or send an OML alarm report to the BSC.
2014-08-25 19:01:24 +02:00
Harald Welte 9e873335ec Revert "add nominal transmit power for upcoming sysmoBTS 1020 and 1100"
This reverts commit d0866fe477, as it
was a bit premature.  We need to address this more properly.
2014-08-25 18:06:29 +02:00
Holger Hans Peter Freyther 04585dd90a tx: Generate a working configuration file on "write"
We do not have the vty test script to do roundtrip testing. There
is no max-initinal-pout, then there was a typo inside 'initial' and
for the relative step size the unit is dB/mdB. Fix both of that.
2014-08-25 16:06:56 +02:00
Holger Hans Peter Freyther 645cba8532 tx: Fix another typo i found today morning 2014-08-25 16:01:29 +02:00
Holger Hans Peter Freyther adddb65f46 sysmobts: Remove left-over from non-generic power control 2014-08-25 16:01:23 +02:00
Holger Hans Peter Freyther fbf04438b7 ctrl: Use msgb_free to free message 2014-08-25 16:01:23 +02:00
Harald Welte e0e9b30f5c tx_power.c: fix potential array out-of-bounds access 2014-08-25 10:05:55 +02:00
Harald Welte 68b9b376cf make use of libosmocore 'gsm_meas_rep_unidir'
Back in March 2013, some structures and defines related to decoded
measurement reports have been moved from openbsc to libosmocore
(libosmocore e128f4663104ed64e33e362cff2566f36d65e658) so that they can
be used also from osmo-bts.  This finally follows up on that.

You need openbsc 7ff4f0e0fc692bfab829da50edb104e58b271e7e or later.
2014-08-25 09:22:00 +02:00
Harald Welte d0866fe477 add nominal transmit power for upcoming sysmoBTS 1020 and 1100 2014-08-25 08:48:37 +02:00
Harald Welte 913044ecc5 tx_power.c: Fix typos in comments 2014-08-25 08:46:48 +02:00
Harald Welte 1fb66c8e6a disable clock control interface on HW_SYSMOBTS_V1 2014-08-24 18:16:45 +02:00
Harald Welte be18984959 ctrl: Add sysmobts control interface
This sysmobts specific control interface allows for clock calibration
from an external program by means of the "trx.0.clock-info" and
"trx.0.clock-correction" values.
2014-08-24 17:07:02 +02:00
Harald Welte 9d0fd073e9 l1_if: pass private 'void *data' from call to callback
When enqueueing a command towards the L1, we can now pass along
a private data pointer, which then gets passed to the call-back
upon completion.
2014-08-24 17:05:23 +02:00
Harald Welte 8e4cc1cbb8 fix build problem introduced with control interface 2014-08-24 17:04:54 +02:00
Harald Welte 993575bcd8 use libocmocore #defines for VTY port numbers 2014-08-24 16:59:07 +02:00
Harald Welte 0ff0f2d00f ctrl_if: Move control interface to port 4238
... which is now defined in libosmocore
2014-08-24 16:59:05 +02:00
Harald Welte d9a2aa8d99 add control interface to common BTS (for thermal attenuation)
Using this control interface, an external program can request
attentuation of the transmitter for thermal management reasons. The
external application doesn't have to know anthing about the actual
transmit power, but it can just configure a certian value of milli-dB
(1/10000 bel) and update (increase/decrease) that value depending on
the thermal environment.
2014-08-24 16:42:02 +02:00
Harald Welte e43feaf231 New generic transmit power handling
In order to support transmit power reduction by thermal management
as well as the variety of new internal / external PA configurations
of BTSs, we need a slightly more complex system.

Also, as at high power a single dB can be quite a big difference,
we are now doing all computations in milli-dB(m), i.e. 1/10000 bel.

Ramping is now used both for up and down ramping, as that is useful in
cases where you want to gracefully shut down a cell by shrinking its
radius, gradually handing over subscribers to neighboring cells.

Furthermore, this code is becoming part of the 'common' codebase, as it
is not really specific to how sysmobts is working.

The user can specify a single aggregate value for external system
gain/attenuation.  Let's say you have 1dB loss of antenna cable, so you
can put that as 'user-gain -1' into the config, which means that a
'transmit power of 20dBm' will be compensatet for that and the TRX is
instructed to output 21dBm to compensate the cable loss.  Similarly,
external PAs can be described by a positive user-gain.

One of the next steps will be to communicate those values and the
nominal power capability of the specific BTS to the BSC, so the BSC will
automatically show correct signal levels in the VTY and log files.

The code includes provisions for future extensions regarding
* an external and an internal PA with calibration tables
* a thermal attenuation setting to be controlled by the site manager
2014-08-24 10:46:21 +02:00
Harald Welte fcca2e8218 remove copy of gsm_bts_num()
... which is now available from gsm_data_shared.[ch] of openbsc
2014-08-24 10:46:21 +02:00
Holger Hans Peter Freyther 15f899f89e sysmobts: Use the uc connection on both slave and master
We can use this on both slave and master. But only have the
master switch on the PA.
2014-08-22 00:06:01 +02:00
Holger Hans Peter Freyther 1f8053e366 sysmobts: Enable the PA on start and disable it as first action
The PA will be unconditionally turned. This makes it possible
that in case of a crash, the PA will be turned on and then we
will do the temperature measurement and turn it off again. There
are no known crashes with the sysmobts-mgr right now so the risk
seems to be okay. In case we can't switch off the PA we have no
way to escalate it right now. We have not seen a dead uc either
so the risk is okay as well.

We can't switch the PA back on once we reach the normal level
as the BTS might transmit with full power and we would need more
current than the power supply/rails can carry. So leave the
system off right now.

What is missing is to use the OML router to actually inform
the BSC that something bad has happened at the BTS.
2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther e02d7796c3 sysmobts: Show the current temperature controls state int he VTY 2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther 714ccb9992 sysmobts: Provide information about the state transitions 2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther b0674e9636 sysmobts: Implement a small state machine for temp control
Check the temperature and move between "NORMAL", "WARNING"
and "CRITICAL" state. We will only return from CRITICAL to
WARNING when the temperature has significantly changed, and
when being in state "WARNING" we enter an intermediate state
to allow an easy hysteris.
2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther d036cce744 sysmobts: Remove the sbt2050 timer and move defines back
We haven't done anything with the result of the micro controller
query and querying every six hours for the temperature of the
system will not help us. We need to query the temperatures more
frequently but avoid writing to the eeprom too frequently so we
will start another timer for that.
2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther c42bf5fdf5 sysmobts: Simplify some includes/dependencies 2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther ca71d07e44 sysmobts: Begin to add various limits and actions
The idea is that for different parts of the system we can define
thresholds for warning and critical (severe) temperate thresholds.
And once any of these temperatures is reached we will execute an
action. When crossing from NORMAL to WARNING or WARNING to SEVERE
we will need to apply some hysteris before switching back to the
lower level. E.g. when being SEVERE mode, at least wait until we
are below the warning level again. Besides being able to switch
off things we could start reducing the transmit power of the system
until the system is cold enough again.

No action is implemented so far, everything is varpoware!
2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther c7ee5acba9 sysmobts: Fix the temperature log message alignment 2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther 9698570d47 sysmobts: Move ipaccess-find counterpart to a dedicated source file 2014-08-21 23:55:27 +02:00
Holger Hans Peter Freyther 7be58a173a sysmobts: Fix the build when no 2050 uc header file was found
Fix the build (provide empty stubs) when the header file is not
present.
2014-08-21 18:03:25 +02:00
Holger Hans Peter Freyther 5e1363071f sysmobts: Fix the power request result
We want to know which componets are enabled and the voltage and
current used by the components.
2014-08-21 16:25:07 +02:00
Holger Hans Peter Freyther 4059e29a29 sysmobts: Read the temperature sensors on the device
Read the sensors that are always present and the ones that
are only present on the sysmoBTS 2050.
2014-08-21 16:25:07 +02:00
Holger Hans Peter Freyther 46c085d794 sysmobts: Add is_sbts2050_master 2014-08-21 16:25:07 +02:00
Holger Hans Peter Freyther b1ceb40363 sysmobts: Read the model number and trx once from the device
Use it for the ipaccess-find response and for the sysmobts
classification code. This can be used by the vty in a second.
2014-08-21 16:25:07 +02:00
Holger Hans Peter Freyther 3ecb2bb604 sysmobts: Initialize fd with an invalid fd
Initialize the ucinfo with an invalid fd to prevent writing
on fd=0 by accident.
2014-08-21 16:25:07 +02:00
Holger Hans Peter Freyther 575f633483 sysmobts: Use another logp region as it is mostly related to remp 2014-08-21 15:49:06 +02:00
Holger Hans Peter Freyther 54a8b313b4 sysmobts: There is only one uc make it a singleton
Move the init and polling into the sysmoBTS related part. In the
future we should have _one_ temperature control.
2014-08-21 15:49:06 +02:00
Holger Hans Peter Freyther c84ca8c82f sysmobts: Clean-up the parsing routines 2014-08-21 15:49:06 +02:00
Holger Hans Peter Freyther 035187b44e sysmobts: Move the sysmoBTS 2050 controller handling
Move the code to a separate file to keep things nicely apart
of each other.
2014-08-21 15:49:06 +02:00
Holger Hans Peter Freyther 013df51ca8 sysmobts: Add VTY support to the sysmobts-mgr
Add VTY support to the manager. This way we can interactively
inspect the state of the system and trigger events.
2014-08-21 15:49:06 +02:00
Harald Welte 07198750b2 adopt to recent libosmocore ipa rename 2014-08-20 23:30:28 +02:00
Harald Welte ac76388c77 TLVP_PRES_LEN is now in libosmocore, avoid redefining it 2014-08-18 20:48:56 +02:00
Harald Welte bc82b0189a replace oml_{osmo,ipa}_magic[] with abis_nm_{osmo,ipa}_magic
the latter is now in libosmogsm.
2014-08-18 20:48:56 +02:00
Harald Welte fcd5c367d1 Migrate to osmo_get_macaddr() in recent libosmocore
get_mac_addr() is generally useful and shouldn't be hidden in
the osmo-bts/abis.c file
2014-08-18 20:48:56 +02:00
Holger Hans Peter Freyther 88d60a1f86 sysmobts: Add a unit test that checks of the behavior
We need to build a lot more code to be able to test these two
new routines. I didn't want to move the code to a utils file
as the check is called from a hot path. Add accessors to the
inlined variant to be used by the unit test.

While writing the unit tests I noticed that a re-transmission
of the ciphering command would lead to an attempt to enable
ciphering again. I am not sure that this MphConfig is idempotent.
2014-08-09 09:42:56 +02:00
Holger Hans Peter Freyther 2cc37035d7 sysmobts: Deal with ciphering when we have a transport clash
The network is configured with early classmark sending. This means
that the phone might send a "classmark change" message at the same
time we send a ciphering mode command. When we received the CM
message we assumed we have just received the first ciphered message
and enabled ciphering for tx as well.

When we snoop the Ciphering Mode Command extract the N(S) variable
and when we receive an I frame from the MS see if it handled our
message by comparing the MS N(R) to BTS N(S) + 1.
2014-08-09 09:42:56 +02:00
Holger Hans Peter Freyther caca1899ce sysmobts: Make sure that the omlrouter is in a FHS path
I wondered if I should use the 'abstract namespace' feature
of Linux but just put the router into /var/run/ to make it
work out of the box. Change the signature to provide a sane
error message.
2014-07-31 17:43:08 +02:00
Holger Hans Peter Freyther 0655cac6f1 sysmobts: Verify the structure of IPA and OML messages
Extend the router to verify that the message received is
properly encoded. The code can deal with the basic structure
of ETSI OML and vendor specific messages for ip.access and
the osmocom project.
2014-07-31 16:58:26 +02:00
Holger Hans Peter Freyther b05d72d21b sysmobts: Begin with an OML router that will be used by the manager
Begin with the basics of a OML Router. This is currently only
capable of accepting a connection and read messages but it will
evolve into a router in multiple stages. The first usage will
be by the sysmobts-mgr. An OML Error Indication will be sent by
the sysmobts-mgr and it will be forwarded to the BSC. In the
second step we will set a relative power reduction from the
sysmobts-mgr.

In the long-term this code will be used to communicate with a
second TRX.
2014-07-31 16:57:39 +02:00
Holger Hans Peter Freyther 9e1dbf532e sysmobts: Remove debug left over from enabling the RTP mode 2014-07-31 16:57:39 +02:00
Holger Hans Peter Freyther a19912db34 sysmobts: Enable the direct RTP mode for firmware >= 3.11
We need to patch the CMR due wanting to support systems that still
have Audiocodes hardware in their chain. I have manually tested
and could listen to my own voice on:

TCH/H	&	AMR 5.9		& PTSN			& BSC
TCH/F	&	FR1		& Other subscriber	& NITB
TCH/F	&	EFR		& Other subscriber	& NITB
TCH/H	&	HR1		& Other subscriber	& NITB
TCH/H	&	AMR 5.9		& Other subscriber	& NITB

The tests were done using the Nokia E71, a Blackberry curve and
for the PTSN a HTC 8S were used.
2014-07-31 14:39:32 +02:00
Holger Hans Peter Freyther eececf5fa9 sysmobts: Make it possible to slowly ramp up the output power
For systems with a bigger PA enabling the full output power at
once might draw more current than a power supply can provide. This
code will step up the output power in smaller steps to avoid this
situation.
2014-07-30 18:22:12 +02:00
Holger Hans Peter Freyther bc24955e91 sysmobts: Provide VTY routines to do clock calibrations
The sysmoBTS2050 does not have a OCXO and we should not rely
on the GPS module to always have a fix. Instead use the TCXO
by default and from time to time (and we know we have a fix
calibrate the TCXO). This can be done by:

  trx 0 rf-clock-info reset
  wait...
  trx 0 rf-clock-info correct
  write

The output is currently only written to the log as the VTY
connection might go away during the operation. The reset will
set the approriate reference clock and the correct will attempt
to determine and apply the correction. The write terminal will
make sure that next on start a known good value will be used.
2014-07-25 14:45:52 +02:00
Holger Hans Peter Freyther bac0ff7f6d sysmobts: Free the message on older firmware releases
Seen while implementing a new functionality in the code.
2014-07-25 13:23:00 +02:00
Holger Hans Peter Freyther 94a63851b7 sysmobts: Include the model and master/slave in the unitid
Make it more easy to find the right BTS model and know what is
the master/slave.
2014-07-25 10:48:14 +02:00
Holger Hans Peter Freyther 3674645e20 amr: Avoid toggling the CMR from none and a set one
For LCR and other systems without out-of-band information we need
to indicate the CMR. Not every air message will include the mode
and we sent a stream that had the CMR set and not-set. This lead
to the AudioCodes MGW only playing every second frame.

Remember the last used mode and initialize it to _NONE when we
receive the multirate config. In case of a real error we will
still use AMR_CMR_NONE.

The initial patch is from Harald. I have added the initialization
and moving of the defines to amr.h.

Manually verified by enabling AMR5.9 and looking at two RTP
packages in sequence. In both cases the CMR was 2. I have looked
at "amr.nb.cmr != 2" in wireshark and only found the MGCP dummy
packet.
2014-07-25 09:22:29 +02:00
Holger Hans Peter Freyther a2b806c375 sysmobts: Fix typo in the comment 2014-06-22 16:23:59 +02:00
Holger Hans Peter Freyther a7f9b58e44 sysmobts: Fix the initialization of the BTS manager code
The code should only run for the sysmoBTS 2050 and TRX 0.
If the device is not marked as 2050 the code would attempt
to open /dev/ttyS0 and block forever.
2014-05-30 15:29:01 +02:00
Holger Hans Peter Freyther 0e2b624418 sysmobts: Revert all sysmobts-mgr related changes
Harald is right and that the code is generally not ready
for inclusion. I fell victim of trying to finish it while
the code is not ready at all. It is better to re-introduce
the patches in a smaller and more tested way.

The right way would have been a branch were ready things
are split-off the main/wip commit until everything is ready.

Revert "sysmobts: Have a common prefix for the enum"
This reverts commit 44980347f3.

Revert "utils: Used the enum manuf_type_id in the parameter of add_manufacturer_id_label"
This reverts commit 7d36e5ed46.

Revert "utils: Classify the OML message using the return type"
This reverts commit afee0b7929.

Revert "sysmobts: Do not access out of bound string"
This reverts commit f5f41e8051.

Revert "sysmobts: Separate IPA and OML check into two methods"
This reverts commit 13a224063d.

Revert "screenrc: osmobts-mgr now needs a config file"
This reverts commit 0a1699ff8a.

Revert "make sure osmobts-mgr.cfg file is included in tarballs"
This reverts commit 14c60b425f.

Revert "sysmobts-mgr: Add VTY support for configuring it"
This reverts commit c5fedd24c9.

Revert "sysmobts: Add beginnings of an OML router and create Failure Messages in the sysmobts-manager"
This reverts commit c6ab90b270.
2014-05-25 13:48:33 +02:00
Holger Hans Peter Freyther 7996134d2a common: Ignore "si.valid" outside of _MAX_SYSINFO_TYPE
Limit the range from 0 to (_MAX_SYSINFO_TYPE - 1) instead of
0 to 31. This way we will never access the lchan->si.buf[] out
of bounds. This is only a theoretical issue though as the code
filling the lchan->si.buf for the SACCH will not have valid
>= _MAX_SYSINFO_TYPE. Add a small regression test to check we
still schedule all SIs.

Fixes: CID 1040765
2014-05-22 21:17:49 +02:00
Holger Hans Peter Freyther ac26607fe4 common: Remove unused gsm_time parameter from lchan_sacch_get 2014-05-22 20:42:33 +02:00
Holger Hans Peter Freyther 9d8aeab0b6 sysmobts: Avoid memleak when multiple -c arguments are passed
Rely on optarg pointing to an address that will be valid for
the run of the entire application.

Fixes: CID 1206578
2014-05-22 19:50:39 +02:00
Holger Hans Peter Freyther 44980347f3 sysmobts: Have a common prefix for the enum
Make the manuf_type_id enum have a common prefix for the
symbols.
2014-05-20 09:47:02 +02:00
Álvaro Neira Ayuso 7d36e5ed46 utils: Used the enum manuf_type_id in the parameter of add_manufacturer_id_label
Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-20 09:47:02 +02:00
Álvaro Neira Ayuso afee0b7929 utils: Classify the OML message using the return type
Classify the OML message and return the manufacturer type
or an error. Currently ETSI, ip.access and Osmocom are known.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-20 09:45:36 +02:00
Álvaro Neira Ayuso f5f41e8051 sysmobts: Do not access out of bound string
One can either use "strlen(str) + 1" but not add one to the
result of the sizeof.
2014-05-20 09:43:38 +02:00
Álvaro Neira Ayuso 13a224063d sysmobts: Separate IPA and OML check into two methods
I have split the function check_oml_msg, in two functions. One for
checking if the ipa header is well-formed and in check_oml_msg,

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-20 09:37:30 +02:00
Harald Welte b4280963c0 Revert "sysmobts: Add support for changing the transmit power in sbts2050"
This reverts commit c64d425738.

There are unfrtunately still too many problems with this patch to be
merged at this point.
2014-05-19 11:22:38 +02:00
Harald Welte 76c309e9f7 sysmoBTS TCH: Set CMR in AMR RTP frames
Enable the previously commented-out logic to set the CMR (Codec Mode
Request) in AMR RTP frames based on the CMI (CMR Index) of the AMR
speech frame on the Um interface.

This is of course anyway the right thing to do, but also required for an
AMR receiver which doesn't have out-of-band information on the codec
mode, and which also doesn't determine the AMR codec mode based on the
size of the AMR frame (such as lcr as of current master).

We also move the entire CMR generation into the #ifdef section
which is only compiled-in if we do _not_ use the RTP mode of L1.
2014-05-18 22:31:45 +02:00
Álvaro Neira Ayuso c64d425738 sysmobts: Add support for changing the transmit power in sbts2050
Make the sysmobts-mgr send a manufacturer O&M message with the power
reduction we want the sysmobts to apply. The sysmobts will handle
this message and set the new tx output power. An ACK/NACK will be
send as a response to the power reduction.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-18 09:42:49 +02:00
Álvaro Neira Ayuso c5fedd24c9 sysmobts-mgr: Add VTY support for configuring it
This patch allows to configure the warning temperature threshold,
the severe temperature threshold of the board and the PA and the
actions like the relative value power that we want to reduce the
transmit power to and the part that we want to switch off or not.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-18 09:42:08 +02:00
Álvaro Neira Ayuso c6ab90b270 sysmobts: Add beginnings of an OML router and create Failure Messages in the sysmobts-manager
Make the sysmobts listen for OML messages on a Unix Domain Socket.
Messages passing a sanity check will be forwarded to the BSC.

In case the sysmobts-mgr detects a temperature above or below
temperature threshold an OML failure message will be sent
to the BTS.

[moved confinfo into the #ifdef BUILD_SBTS2050]

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-18 09:41:29 +02:00
Harald Welte 73d9d3af6c sysmobts: Support DSP API >= 3.8.1 (u8MaxCellSize) 2014-05-17 10:04:44 +02:00
Holger Hans Peter Freyther d75c648871 abis: Separate initialization from connect for Abis
Initialize the libosmo-abis VTY nodes more early so we can parse
the config file that was created by "write". Introduce abis_init
to initialize the libosmo-abis and modify abis_open to re-use an
existing line. Update the comments. This has only been tried with
the sysmobts-remote on x86. A TCP connection is opened toward the
configured BSC.

Fixes: SYS#285
2014-05-15 14:18:26 +02:00
Álvaro Neira Ayuso 8b5b993d29 sysmobts: Fix compiler warning about missing declaration
Include utils.h to have a declaration of sysmobts_get_nominal_power,

l1_if.c: In function 'l1if_activate_rf':
l1_if.c:1144:6: warning: implicit declaration of function
'sysmobts_get_nominal_power' [-Wimplicit-function-declaration]

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-05-15 10:21:43 +02:00
Álvaro Neira Ayuso 9ed6b95c90 osmo-bts-sysmo/utils.c: Added a function for calculate the power transmitter
Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-04-29 12:08:28 +02:00
Holger Hans Peter Freyther 3e5b6db2d2 handover: Call the right function and avoid recursion
Fix a brown paper bag bug and call the right method. The above was
an infinite recursion. The stack didn't overflow as the compiler
optimized the tail-recursion and coverity didn't complain either.

The issue was introduced in the last minutes before the merge
when I renamed "reset_handover" to "handover_reset" to follow
the object_verb approach throughout the handover.c code. While
doing that I sadly replaced reset_handover with handover_frame
and not handover_reset.
2014-04-19 19:22:22 +02:00
Holger Hans Peter Freyther d59bbd16a7 sysmobts: Add log message in case the channel activation fails 2014-04-07 20:33:04 +02:00
Holger Hans Peter Freyther f547bee878 rsl: Use unique values for the call to rsl_tx_chan_act_nack
This way we can easily find the place in the code that is responsible
for the NACK.
2014-04-07 20:30:12 +02:00
Jacob Erlbeck 57a4d121c4 oml: Pass all valid state change requests to the model
Currently ADM state change request that tries to set the
administrative state to the current value are immediately ACK'ed.
Beside the caching problem, this could lead the protocol
inconsistencies if two such requests are sent one after the other and
the second arrives before the procedure of the first has finished.

This patch removes the shortcut in oml_rx_chg_adm_state() which
immediately called oml_mo_statechg_ack(mo).

Ticket: OW#1132
Sponsored-by: On-Waves ehf
2014-04-03 12:46:03 +02:00
Holger Hans Peter Freyther 0859795878 sysmobts: Fix build for the v1 of the sysmobts 2014-03-29 19:27:54 +01:00
Holger Hans Peter Freyther 14ff925555 agch/pcu: Fix crash for AGCH commands queued by the PCU
The dequeue code assumed that msg->l3h is a valid pointer but in
the case of the PCU socket it was a null pointer. This lead to
memcpy copying a lot more than 23 bytes which ultimately lead to
a crash. The issue was introduced in the git commits
37c332e5bf and the commit
d290ee029a.

use msg->l3h = msgb_put(msg, len) to make sure that there is a
valid L3 pointer for the message.

 (gdb) bt
 #0  0x419d6384 in memcpy () from /tmp/ow/lib/libc.so.6
 #1  0x0001894c in bts_ccch_copy_msg (bts=0x62248, out_buf=0x62248 "p\025\003", gt=0x1,
    is_ag_res=100684) at bts.c:572
 #2  0x0000c958 in handle_ph_readytosend_ind (rts_ind=<optimized out>, fl1=0x62e78)
     at l1_if.c:515
 #3  l1if_handle_ind (fl1=0x62e78, msg=0x8bb08) at l1_if.c:920
 #4  0x000147e8 in read_dispatch_one (queue=<optimized out>, msg=0x8bb08, fl1h=<optimized out>)
    at l1_transp_hw.c:190
 #5  l1if_fd_cb (ofd=0x62f04, what=<optimized out>) at l1_transp_hw.c:224
 #6  0x41b9d028 in osmo_select_main (polling=<optimized out>) at select.c:158
 #7  0x0000b204 in main (argc=<optimized out>, argv=<optimized out>) at main.c:384

(gdb) p *msg
$12 = {list = {next = 0x100100, prev = 0x200200}, {dst = 0x0, trx = 0x0}, lchan = 0x0,
  l1h = 0x0, l2h = 0x0, l3h = 0x0, l4h = 0x0, cb = {0, 0, 0, 0, 0}, data_len = 23, len = 23,
  head = 0x8572c "-\006?\020\r\340*q\224#", tail = 0x85743 "",
  data = 0x8572c "-\006?\020\r\340*q\224#", _data = 0x8572c "-\006?\020\r\340*q\224#"}
2014-03-27 09:19:24 +01:00
Holger Hans Peter Freyther 64a4327c34 sysmobts: Apply the potentially new max_power_red on the TRX
In case the max power reduction has been changed through OML,
let us call the l1if_set_txpower routine to update the nominal
power. This has been manually verified with both BTS #1 and #57.

./bsc_control.py -d localhost -p 4249 -s bts.0.trx.0.max-power-reduction 0

The above command and GNUradio have been used to determine if
the power level has changed at all.

Fixes: SYS#268
2014-03-26 18:05:41 +01:00
Holger Hans Peter Freyther a276b98236 oml: Indicate the kind of object passed as the void*
These routines do not pass the gsm_abis_mo and parsing the FOM
header of the msg does not seem to be a good idea either. Pass
in the OML object so that the model code can determine what the
void pointer is.
2014-03-26 18:01:55 +01:00
Holger Hans Peter Freyther 71d98050f3 sysmobts: Honor power reduction on older sysmoBTSv2 hardware
Older hardware didn't have the external attentuator that was used
to control the wanted output power. So starting from the git commit
3c8ff3c70b older hardware was always
transmitting with 23 dBm regardless of the power reduction.

Remember the hardware revision returned by the SystemInformation
primitive, postpone the call to l1if_activate_rf until we know
the board revision.

Manually verified on BTS #1 and #57. On BTS#1 the external
attenuator has not been configured and on BTS#57 it was.
2014-03-26 17:49:06 +01:00
Holger Hans Peter Freyther ae2473c2ca systemd: Do not restart with a broken config file or such
Only restart in case of a crash or the exit(42) when the OML/RSL
link is going down.
2014-03-21 18:10:12 +01:00
Holger Hans Peter Freyther fb067905d5 sysmobts: Add a magic number to the hLayer2 to differentiate it
The DSP/FPGA appears to report bogus PhDataInd with hlayer2 == 0.
Currently this would match the TRX==0,TS==0 and SS=0 and then we
report bad measurement reports. Add a magic number to the lower
eight bit of the hLayer2 to differentiate valid numbers.

Addresses:
<0004> measurement.c:97 (bts=0,trx=0,ts=0,ss=0) measurement during state: NONE
<0004> measurement.c:102 (bts=0,trx=0,ts=0,ss=0) no space for uplink measurement
2014-03-16 14:23:37 +01:00
Holger Hans Peter Freyther 3e317ea4f0 sysmobts: Change the order to follow the RX handling code 2014-03-16 14:21:41 +01:00
Holger Hans Peter Freyther b45c8a6b6c sysmobts: Improve the log message and print the hLayer2 we don't know 2014-03-16 14:21:41 +01:00
Álvaro Neira Ayuso 2dca8f37e5 misc/sysmobts_misc: function for switching off/on and requesting status power
I have extended the principal function that we use for requesting
information to the microcontroller for switching off/on the board
and the PA. And I have extended it for requesting the power status
information of the board and the PA.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-03-16 14:21:41 +01:00
Álvaro Neira Ayuso 4b614a0246 misc/sysmobts_mgr: Added new header created in the configure
Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-03-12 21:38:18 +01:00
Holger Hans Peter Freyther 06387d89e8 misc: Fix the build breakage now that we have btsconfig.h
Include the btsconfig.h for the PACKAGE_VERSION variable.
2014-03-12 16:40:07 +01:00
Álvaro Neira Ayuso e030dfd443 misc/sysmobts_misc.c: Read temperature from microcontroller
Add function for requesting the temperature information to the
microcontroller. I have added a function that we can extend
for requesting more information but in this case we only need to
know the temperature.
I have added to a microcontroller temperature handling function
in the manager for monitoring this information.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-03-12 16:27:38 +01:00
Jacob Erlbeck 21104720f7 agch: Remove obsolete comment
Use of configuration variables has already been implemented here, so
the TODO comment is removed.

Sponsored-by: On-Waves ehf
2014-03-10 14:04:29 +01:00
Holger Hans Peter Freyther b26b8fc776 sysmobts: Do a RF mute at initialization when the RC is locked
Currently a locked cell is actively broadcasting when it is being
bootstrapped after the lock.

This patch adds an initial update of the RF mute state when the TRX
is initialized.

Ticket: OW#1131
Sponsored-by: On-Waves ehf
2014-03-10 14:00:21 +01:00
Holger Hans Peter Freyther 9c4a524444 handover,sysmobts: Handle handover in the sysmobts code
When the lchan was activated for handover configure it to wait
for a RACH burst. On release make sure to always release the
RACH SAPI (in case it has been allocated). On the first frame
inform handover.c about it and forward the received access burst
to the handover layer.

Using an E71 it was possible to make a handover for SDCCH and
TCH/F from a nanoBTS but also from itself to itself. The vty
commands of OpenBSC and the silent-call have been used for that.
I didn't verify audio handling so far.
2014-03-10 13:38:07 +01:00
Holger Hans Peter Freyther bb76d816da handover,sysmobts: Handle idle needed for preparation of rach handling 2014-03-10 13:38:07 +01:00