Commit Graph

691 Commits

Author SHA1 Message Date
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 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 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 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 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 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 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
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 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 d0866fe477 add nominal transmit power for upcoming sysmoBTS 1020 and 1100 2014-08-25 08:48:37 +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
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
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 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 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
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 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
Á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
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
Holger Hans Peter Freyther cfce4d65f2 handover,sysmobts: Refactor the parsing/handling of the access delay 2014-03-10 13:38:07 +01:00
Andreas Eversberg 00b4e064ff handover: Add generic handling for handover
The BTS layer needs to inform the handover code when an access
burst has been received. In turn the handover layer will ask the
bts to modify the channel, it will schedule the physical information
inform the BSC with the HANDOVER DETECTION and waits for the BTS
layer to inform it about the first received frame to stop a timer.
2014-03-10 13:38:07 +01:00
Álvaro Neira Ayuso 20f5422803 src/misc/sysmobts_misc: Fixed wrong TEMP_PATH
Before, this patch the program tried to read the info
of the temperature sensor from a wrong location.

Signed-off-by: Alvaro Neira Ayuso <anayuso@sysmocom.de>
2014-03-05 15:03:05 +01:00
Holger Hans Peter Freyther e5bda88c9d sysmobts: Do not generate RF Conn failure for CCCH and PDCH
This could lead to a BSC attempting to release the BCCH or a
PDCH. In the case of the BCCH this lead to a funny crash.

Log:
<0000> rsl.c:605 (bts=0,trx=0,ts=0,ss=4) Sending Connection Failure: cause = 0x01
<0000> rsl.c:1720 (bts=0,trx=0,ts=0,ss=0) Rx RSL DEACTIVATE_SACCH

Backtrace:
 Program received signal SIGSEGV, Segmentation fault.
msgb_dequeue (queue=0x4007d2d8) at msgb.c:102
102        llist_del(lh);
(gdb) bt
 #0  msgb_dequeue (queue=0x4007d2d8) at msgb.c:102
 #1  0x4002ed28 in lapd_dl_flush_tx (dl=0x4007d220) at lapd_core.c:173
 #2  0x40030cb4 in lapd_dl_reset (dl=0x4007d220) at lapd_core.c:307
 #3  0x40030d00 in lapd_dl_exit (dl=0x4007d220) at lapd_core.c:321
 #4  0x40033d80 in lapdm_entity_exit (le=<optimized out>) at lapdm.c:169
 #5  0x40033d9c in lapdm_channel_exit (lc=0x4007d214) at lapdm.c:180
 #6  0x0001a334 in rsl_tx_rf_rel_ack (lchan=0x4007d180) at rsl.c:505
 #7  0x0000e908 in lchan_deactivate_sapis (lchan=0x4007d180) at oml.c:1427
 #8  sapi_queue_exeute (lchan=0x4007d180) at oml.c:547
 #9  0x0000ead0 in sapi_queue_send (lchan=<optimized out>) at oml.c:571
 #10 queue_sapi_command (lchan=<optimized out>, cmd=<optimized out>)
    at oml.c:609
 #11 queue_sapi_command (lchan=0x4007d180, cmd=<optimized out>) at oml.c:601
 #12 0x0000faf0 in enqueue_rel_marker (lchan=0x4007d180) at oml.c:1440
 #13 lchan_deactivate (lchan=0x4007d180) at oml.c:1447
 #14 0x0001004c in bts_model_rsl_chan_rel (lchan=<optimized out>) at oml.c:1647
 #15 0x0001b948 in rsl_rx_rf_chan_rel (lchan=0x4007d180) at rsl.c:844
 #16 rsl_rx_dchan (msg=0x75a88, trx=0x4007b038) at rsl.c:1727
 #17 down_rsl (trx=0x4007b038, msg=0x75a88) at rsl.c:1853
 #18 0x000154d4 in sign_link_cb (msg=<optimized out>) at abis.c:132
 #19 0x400701c0 in ?? () from /usr/lib/libosmoabis.so.2
 #20 0x400701c0 in ?? () from /usr/lib/libosmoabis.so.2
 Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Fixes: OW#1133
2014-03-03 16:28:53 +01:00
Jacob Erlbeck d290ee029a agch/pch: Put CCCH message generation into common
This patch adds a common function bts_ccch_copy_msg() that provides
and schedules AGCH and PCH messages. It is basically a frontend to
paging_gen_msg() and bts_agch_dequeue() and contains refactored code
from l1_if.c.

Sponsored-by: On-Waves ehf
2014-02-22 08:45:56 +01:00
Jacob Erlbeck 37c332e5bf agch/rsl: Fix msgb handling for IMMEDIATE ASSIGN
Currently, the msg->data pointer is just set to the IMMEDIATE ASSIGN
message and the len is adjusted accordingly. Unfortunately, this
leaves l2h (pointing to the RSL header) and l3h (pointing to the
FULL_IMM_ASS_INFO IE) in an undefined state (outside of [data, tail]).
The code in bts.c accesses the message via msg->data.

This patch sets l3h and l2h correctly.  msgb_l3() will point to the
start of the IMM ASS message and should be used instead of msg->data.

Sponsored-by: On-Waves ehf
2014-02-22 08:41:02 +01:00
Holger Hans Peter Freyther 4160e3d0f8 sysmobts: Remove debug left over from the SACCH fixes we made 2014-02-20 10:48:35 +01:00
Holger Hans Peter Freyther f91799eecf l1fwd-proxy: Bind to the bts VTY port to block another process
Today we had the problem that multiple l1fwd-proxy instances ran
at the same time and not everything working all the time (some
packets were sent to a different host).

Another approach is to use flock on the message queues. This appears
to work fine as well.
2014-01-28 16:36:34 +01:00
Holger Hans Peter Freyther 023739fc94 sysmobts: Add the requested TA to the field ACCH header
Write the requested timing advance into the header. We are currently
using the u8AutoTA mode so the value will be overwritten by the DSP
before the bursts are sent to the MS.
2014-01-27 14:46:58 +01:00
Holger Hans Peter Freyther 1817447c24 sysmobts: Correct sending of LAPDm frames on the SACCH
When a frame is sent on the SACCH the LAPDm code will already
prepend two bytes for the tx_power and the ta. In the BTS we want
to use the values that were set by the BSC though. They currently
come from the RSL CHAN ACT but could also be set through the
RSL MS power control command. Update the comment as the space is
not empty.

At the 30C3 we had a NITB crash because of a RLL timeout on a
TCH/F. Jacob analyzed the problem and tracked it down to the
mismatch of LAPDm and the l1 interface to the DSP.
2014-01-27 14:46:52 +01:00
Harald Welte 2e93a8683c bts_model_rsl_chan_act(): Handle tp==NULL case gracefully
The PCU may call this function without a valid 'tp' (tlv parsed)
pointer, we need to make sure we take this into consideration...
2014-01-23 17:09:10 +01:00
Harald Welte bc7d6fbdbb sysmoBTS OML: Don't permit TSC != BSIC
The sysmoBTS L1 has the TSC as a global value, we cannot have individual
per-timestamp or even per-lchan TSC, as the GSM specification would
suggest (and other BTSs support).

Rather than fail silently, write an error message to the log and
return NM_NACK_PARAM_RANGE or RSL_ERR_SERV_OPT_UNIMPL back to the BSC.
2014-01-21 23:39:00 +01:00
Harald Welte 3c8ff3c70b sysmobts: Specify TRX nominal maximum tx power as fMaxTxPower
In the MPH ACTIVATE-RF.req, we need to specify the nominal maximum
transmit power, i.e. >= what we later request during MPH-INIT.req.

This field was first introduced in API version 2.2, but we never used
it so far.  It may help fixing a bug related to excessive power
consumption of the sysmoBTS 2050.
2014-01-21 23:38:47 +01:00
Holger Hans Peter Freyther d76211dc3b sysmobts-mgr: Check the return value of the sendto
Fixes: Coverity CID 1157379
2014-01-17 17:59:12 +01:00
Holger Hans Peter Freyther 5899b2d346 sysmobts-mgr: Respond to ipaccess-find broadcast messages
Bind to port 3006 and listen to incoming IPA requests. Currently
we unconditionally respond with the MAC and IP Address of the unit.
To determine the IP Address the kernel is asked for thesource
address of the route for the destination. In contrast to a nanoBTS
we will reply to the port the initial request came from.
2014-01-17 09:32:05 +01:00
Holger Hans Peter Freyther 1881e46cb9 sysmobts-mgr: Parse the daemonize option
Parse the daemonize option and daemonize after the full
set-up of the code.
2014-01-17 09:30:19 +01:00
Holger Hans Peter Freyther 810fbff380 sysmobts-mgr: Parse logging related commands, re-order init function 2014-01-17 09:30:03 +01:00
Holger Hans Peter Freyther 19224b4b9b sysmobts-mgr: Make it possible to not write to the EEPROM
For testing/trial it is better to not write to the EEPROM
but it is still good to see how the logic is working.
2014-01-16 13:49:50 +01:00
Holger Hans Peter Freyther a4ffc44eac sysmobts: Specify the parameters that can be read from the EEPROM
When using the utility it is not clear which parameters can be
read or written. Make that more obvious.
2014-01-03 12:07:15 +01:00
Holger Hans Peter Freyther c28a5b0b25 sysmobts: Specify the constant as a float and not a double 2013-12-29 10:14:20 +01:00
Holger Hans Peter Freyther 623d97a0d3 tch: Do not log every single RTP packet and air frame
The sysmoBTS takes quite a bit of CPU time for the vfprintf that
is used by osmo_hexdump. Do not dump every single frame to improve
the performance a bit.
2013-12-28 17:25:23 +01:00
Holger Hans Peter Freyther 9c279945a1 misc: Avoid using double numbers on our ARM
In the perf the ARM EABI ddiv operation showed up in the most
of expensive symbols. It doesn't really make much sense as the
calls should only be done on configuration.
2013-12-28 11:11:17 +01:00
Holger Hans Peter Freyther 540f608c2c sysmobts: Fix compiler warning by including utils.h
calib_file.c: In function 'next_calib_file_idx':
calib_file.c:126:3: warning: implicit declaration of function 'band_femto2osmo' [-Wimplicit-function-declaration]
2013-12-12 17:34:20 +01:00
Holger Hans Peter Freyther 0a51e1a337 sysmobts: Change the ARRAY_SIZE to a constant number
The parameter "uint8_t mute_state[8]" is actually a "uint8_t *mute_state"
so the ARRAY_SIZE is not what we think it is.

Fixes: Coverity CID 1125885
2013-12-12 17:31:02 +01:00
Holger Hans Peter Freyther ef852ae86e sysmobts: Fix resource leak in the error condition
Fixes: Coverity CID 1047336
2013-12-12 17:28:52 +01:00
Holger Hans Peter Freyther 96264b6dd9 sysmobts: Remove stray semicolon from the PCU band filtering code.
The information from band_mask has never been used as the return
was executed unconditionally.

Fixes: Coverity CID 1113473
2013-12-12 17:26:15 +01:00
Holger Hans Peter Freyther f56d56c439 sysmobts: Activate the BCCH silently have have state set to active
Use the lchan->rel_act_kind field for the BCCH activatiob by OML.
The lchan's should be marked as active but no event should be sent to
the BSC. This is mostly like the PCU. We can now remove the secnd
argument from lchan_activate.
2013-11-27 14:26:39 +01:00
Holger Hans Peter Freyther ed9d643036 sysmobts: Make the eeprom/nominal power reading backward compatible
There are existing deployments where the EEPROM either contains a
wrong value and/or the kernel can not be updated to support the
different EEPROM of revD. Revert to the old behavior that if no
nominal can be derived from the model_nr we assume that it is 23.
2013-11-27 13:28:59 +01:00
Holger Hans Peter Freyther e14ddaf204 sysmobts: Print the model number that is not supported.
When using an old kernel on revD hardware we will read garabge
from the EEPROM and it is nice for debugging to see which model
number has been picked.
2013-11-27 11:46:45 +01:00
Holger Hans Peter Freyther e968c4224d bts: Fix typos in the log messages 2013-11-27 10:43:01 +01:00
Holger Hans Peter Freyther 082e21dbb5 bts: Fix a typo in the log message 2013-11-27 10:40:31 +01:00
Jacob Erlbeck 897f97f632 sysmobts: Notify the BSC about all muted lchans
Currently it takes some time (around 30s) until it is detected that
the radio link is down after mute. Not till then the BSC is informed
and the call terminated.

This patch modifies this behaviour by sending a RSL_MT_CONN_FAIL
message with cause RSL_ERR_RADIO_LINK_FAIL for each muted and active
lchan immediately after the corresponding Change Administrative State
Request has been acknowledged.

Ticket: OW#976
Sponsored-by: On-Waves ehf
2013-11-05 16:11:07 +01:00
Jacob Erlbeck 5eef61414a sysmobts: Only set RC state to LOCK if all channels are muted
Currently only mute_state[0] (refers to ts[0]) is inspected to
determine, whether the Radio Carrier's state is set to LOCK.

This patch changes this by looking at all channels and using LOCK
if (and only if) all channels have been muted successfully.

Sponsored-by: On-Waves ehf
2013-11-05 15:51:19 +01:00
Jacob Erlbeck 5b69ec3e72 sysmobts: Use status flags instead of direct LED access
Currently the LEDs are being accessed directly from within the
l1_if.c file. So the handling of rf mute and activate/deactivate both
access LED_RF_ACTIVE directly. This may lead to an inconsistent LED
status.

This patch replaces these calls to sysmobts_led_set() by an abstract
equivalent bts_update_status(), that uses a set of independant status
ids. The associated values can than be combined into a visible LED
status. Currently LED_RF_ACTIVE is on iff BTS_STATUS_RF_ACTIVE is set
and BTS_STATUS_RF_MUTE is not set.

Sponsored-by: On-Waves ehf
2013-11-05 15:51:19 +01:00
Jacob Erlbeck 08571b1588 sysmobts: Do a RF mute when Radio Carrier is locked
Currently a Change Administrative State Request is just applied
unconditionally to the object's state object and then acknowledged.

This patch implements the special handling of setting the Radio
Carriers state to LOCK or UNLOCK. This is done by passing the
appropriate mute command to the L1 layer. Always all radio channels
are affected, it is not possible to lock single radio channels.
On success, an ACK is sent back to the bsc with the new state (based
on the state passed in the callback by the L1 layer). If something
went wrong or the firmware doesn't support RF mute, a NACK
(REQ_NOT_GRANTED) is sent instead.

Note that a NACK for such a request hasn't been sent by the BTS to
the BSC yet, so (albeit it's spec conformant to do so) the BSC must
be prepared to handle this correctly.

Ticket: OW#976
Sponsored-by: On-Waves ehf
2013-11-05 15:46:30 +01:00
Jacob Erlbeck 9ef742f5e7 sysmobts: Add L1 support for the new RF mute request
This adds a new function

  l1if_mute_rf(femtol1_hdl, ch_mute[8])

to set the mute state for each radio channel. On completion and iff
l1if_mute_rf() returned 0 the callback

  oml_mo_rf_lock_chg(mo, ch_mute_state[8], success)

is invoked when the response from the superfemto DSP is received.

Ticket: OW#976
Sponsored-by: On-Waves ehf
2013-11-05 15:46:22 +01:00
Jacob Erlbeck f3108fafab sysmobts: Add mappings for MuteRfReq/MuteRfCnf
This add the mappings for SuperFemto_PrimId_MuteRfReq and
SuperFemto_PrimId_MuteRfCnf to the arrays femtobts_sysprim_type,
femtobts_sysprim_names, and femtobts_sysprim_req2conf.

Sponsored-by: On-Waves ehf
2013-11-05 15:39:05 +01:00
Jacob Erlbeck 0133ff3866 sysmobts: Add L1P_T_INVALID to l1prim_type
Currently uninitialized elements of the femtobts_sysprim_type array
are mistaken as L1P_T_REQ (which is accidently the first element and
thus 0).

This patch adds a new element to the enum that has the value 0 to
detect uninitialized elements of the femtobts_sysprim_type array.
Those will then show up in the log as 'SYS Prim XXX is not a
Request!'.

This patch also adds missing definitions of the CalibTbl messages
in the femtobts_sysprim_type mapping so that the requests can still
be identified as such.

Sponsored-by: On-Waves ehf
2013-11-05 15:38:57 +01:00
Harald Welte 99fb43f41a sysmobts calibration: Load further tables even if one fails
Even if one calibration table cannot be loaded, continue to try to
load the other tables, instead of aborting very early.
2013-10-28 10:15:48 +01:00
Harald Welte b8687024ea sysmobts calibration: skip bands not supported by L1
If L1 tells us that a certain band is not supported, then there is no
point in even trying to read+load calibration tables from EEPROM or
files.
2013-10-28 10:15:47 +01:00
Harald Welte 501673fcf3 sysmbts calibration: print error if we fail to read from EEPROM 2013-10-28 10:15:47 +01:00
Holger Hans Peter Freyther e851e13413 lchan: Print the name of the channel already in release request 2013-10-25 16:57:02 +02:00
Holger Hans Peter Freyther ac3fc27257 sysmobts: Attempt to fix the compilation for the v1 hardware 2013-10-10 21:12:39 +02:00
Harald Welte b2a8a642d6 sysmobts: Permit local override of transmit power above 23 dBm
This is used in the sysmoBTS 2050, where the maximum power is 40 dBm

We might want to add a safeguard of some kind to prevent people from
overdriving their transmitters.
2013-10-09 23:05:38 +02:00
Harald Welte 5c0e7b1f2c sysmobts: don't call sysmobts_get_nominal_power() twice
... no need for that
2013-10-09 22:35:46 +02:00
Harald Welte e843f80832 sysmobts: make L1 power configurable
The TRX nominal output power (as seen by OML) is the aggregate power
of any gain internal to the sysmoBTS (and managed by L1) and any
external PA.  This is what is used in trx->nominal_power;

fl1h->l1_power is the transmit power to which we configure the sysmoBTS
L1.  This is 23 dBm (200mW) by default in the sysmoBTS 1002, and 40 dBm
(5W) in the sysmoBTS 2050.  However, if sysmoBTS 2050 is used in
single-TRX configuration, it may be used with higher power, which we can
now configure in the config file / vty.

TODO: A separate, additional field that keeps track of any gain added by
an external PA, e.g. if the sysmoBTS 1002 is used with a sysmoAMP.
2013-10-09 22:35:27 +02:00
Harald Welte cfa54328e2 sysmobts: Don't use the clock calibration value on external clocks
If the clock is provided by an external (like GPS) clock, we should not
use the calibration value.  The latter is only used in context of the
OCXO or VCTCXO.
2013-10-09 16:06:41 +02:00
Harald Welte 50e63fa9e7 sysmobts: Set nominal transmit power depending on sysmoBTS model
This enables the use of up to 5W for each TRX in a sysmoBTS 2050.
2013-10-09 15:38:33 +02:00
Harald Welte 19009f2d7a Do not attempt to initialize L1 with a band unsupported by hardware
If the EEPROM tells us that a given unit doesn't support a given band,
we shouldn't try to use it, even if the BSC tells us to use an ARFCN in
such an unsupported band.

The reason is simple:  The given BTS unit might have band specific
filter / duplexer / PA.
2013-10-09 15:38:33 +02:00
Harald Welte de0ca823f1 sysmobts: Read supported bands from EEPROM
...rather than assuming that any v2 hardware supports all bands.
2013-10-09 15:38:32 +02:00
Harald Welte d92774b4ac abis: delay l1if_reset() until OML link is established 2013-10-06 15:50:36 +02:00
Harald Welte 6d5dc060ea migrate away from our own abis.c code to libosmoabis
libosmoabis has a BTS-side implementation of the IPA protocol for years,
and osmo-bts should have used that all the time.  Unfortunately it had
its own local hack, this patch is migrating to the libosmocore
implementation.
2013-10-06 15:50:36 +02:00
Harald Welte b469e73148 Use GPS as default clock source on sysmoBTS 2050 2013-10-04 19:58:14 +02:00
Harald Welte 33fe4ca97b add sysmobts-util command-line utility to read/write EEPROM parameters 2013-10-04 18:29:54 +02:00
Harald Welte 870f1f1f84 sysmobts_par: add value_string definitions for parameters 2013-10-04 18:29:25 +02:00
Harald Welte 7410bc3020 sysmobts_par: Implement new EEPROM parameters (trx_nr, model_nr, model_flags) 2013-10-04 18:28:46 +02:00
Harald Welte ff41a47c65 sysmobts_par: support for negative parameters
by splitting the rerutn code/status from the actual value, we support
negative values to be stored in the EEPROM
2013-10-04 18:27:16 +02:00
Harald Welte ad89cd978a EEPROM: add model_nr, model_flags and trx_nr to EEPROM 2013-10-04 18:24:34 +02:00
Nicolas J. Bouliane ad10f0f533 sysmobts: Set the clock calibration to the value read from the eeprom
By default read the clock calibration from the EEPROM. It is
still possible to set it using the cli.

Signed-off-by: Nicolas J. Bouliane <nicolas.bouliane@nutaq.com>
2013-07-16 19:13:46 +02:00
Holger Hans Peter Freyther fbf97e35eb calib: The call to fscanf can fail and we should check the return value
Coverity wants us to check that fscanf has scanned the amount of
variables we want to have. Initialize the scan result to 0/0.0f
and warn if the scan has failed.

Fixes: Coverity CID 1040774, CID 1040773
2013-07-16 18:36:44 +02:00
Holger Hans Peter Freyther 91d204e2db eeprom: Check the return value of the fseek in all calls
Coverity insists that we should check the return value of the
calls to fseek. In general this is a good idea.

Fixes: Coverity CID 1040770, CID 1040771, CID 1040772
2013-07-16 18:36:44 +02:00
Holger Hans Peter Freyther f333387748 eeprom: After eeprom_write g_file could point to a closed file
Calling eeprom_write would either re-use g_file or newly open the
file and set g_file but it will close the file as well. This will
lead to other code using fseek/fread on a closed file.

On top of that the general rule for the eeprom code now is that
read and write may not be mixed (due caching and other bits).
2013-07-16 18:36:44 +02:00
Holger Hans Peter Freyther ed966f0428 sysmobts: The code allowed a out of bounds access to temp_type_str
The array has three elements but check was for > _NUM_TEMP_TYPES (3)
so an access at array[3] was possible. It is unlikely to have
happened due the usage of enums. Use ARRAY_SIZE and >= on the real
array to avoid this problem.

Fixes: Coverity CID 1040760
2013-07-09 15:46:50 +02:00
Holger Hans Peter Freyther 481f14d87f sysmobts: Cache the eeprom_Cfg_t for reading tx/rx calib data
The current code has 26 fseek/fread. Only the minority really results
in a call to read. Nevertheless the time for reading during the bootstrap
can take up to 7.82 seconds. Caching the header (which is already done
by fopen/fread) will result in one call to fseek/fread and only
consumes 0.784 seconds.
2013-07-04 17:38:15 +02:00
Holger Hans Peter Freyther 89582f7e77 sysmobts: Add a method to free cached epprom resources
Close the cached file descriptor once the calibration data is
loaded and applied.
2013-07-04 17:38:15 +02:00
Holger Hans Peter Freyther 270cf418fc sysmobts: Read the mac and determine fixup only once during start 2013-07-04 17:38:15 +02:00
Holger Hans Peter Freyther eebdfb8e6f sysmobts: Fix a typo that broke the ciphering with A5/0 > 0
Commit 5643130664 by Daniel changed
the ciphering to go through the command queue. In this commit the
direction for the ciphering got turned around and was not spotted
by review. It worked in testing due the usage of A5/0 and in that
case the direction did not matter.
2013-07-04 17:37:39 +02:00
Holger Hans Peter Freyther 2523cdbc7f misc: Fix various warnings in the code
sysmobts_vty.c: In function 'activate_lchan':
sysmobts_vty.c:373:3: warning: implicit declaration of function 'lchan_activate' [-Wimplicit-function-declaration]
sysmobts_vty.c:375:3: warning: implicit declaration of function 'lchan_deactivate' [-Wimplicit-function-declaration]

eeprom.c: In function 'eeprom_ReadEthAddr':
eeprom.c:305:5: warning: pointer targets in passing argument 3 of 'eeprom_read' differ in signedness [-Wpointer-sign]
eeprom.c:260:12: note: expected 'char *' but argument is of type 'uint8_t *'
2013-07-01 09:30:02 +02:00
Holger Hans Peter Freyther 123caa3c83 calib: Attempt to fix the build for v2.7 of the api headers
This should fix:
calib_file.c: In function 'calib_eeprom_read':
calib_file.c:262: error: 'SuperFemto_SetRxCalibTblReq_t' undeclared (first use in this function)
calib_file.c:262: error: (Each undeclared identifier is reported only once
calib_file.c:262: error: for each function it appears in.)
2013-06-24 11:18:54 +02:00
Holger Hans Peter Freyther 593080ebab calib: Attempt to fix the build for v2.7 of the api headers
This should fix:
calib_file.c: In function 'calib_fixup_rx':
calib_file.c:148: error: 'SuperFemto_SetRxCalibTblReq_t' undeclared (first use in this function)
calib_file.c:148: error: (Each undeclared identifier is reported only once
2013-06-24 11:11:16 +02:00
Holger Hans Peter Freyther f169a75fc4 sysmobts: Introduce an auto-band config to ease DCS/DCS, PCS/PCS changes
During development one switches from GSM900 to GSM1800 and GSM850 to
GSM1900. This commit attempts to make this switch more easy.

GSM1800 and GSM1900 have overlapping ARFCNs. This means that the
mapping from bands to arfcn is not injective. Because of that I
removed the code to deduce the band from the ARFCN. This was done
in commit 8c3d807b3f. The auto-band
option allows to move between GSM900/GSM1800 and GSM850/GSM1900.

Add a simple testcase with these auto-band configurations.
2013-06-24 08:17:12 +02:00
Holger Hans Peter Freyther 266af543e3 sysmobts: Make sure we receive every SACCH frame to count S properly
In case there is no transmitter the S counter might never be decreased.
This means that no radio link timeout will not be sent and the lchan will
remain open forever. There are several ways to resolve this.

The first would be to use the MphTimeInd and after each multiframe check
if there has been a SACCH message for the open lchan's. This could be
similar to the trx_meas_check_compute.

I decided to change fBFILevel to always receive SACCH frames and move
the code down to the PDTCH/PACCH handling and update the comment.
2013-06-24 08:17:05 +02:00
Holger Hans Peter Freyther 718cc9dcac sysmobts: Read multiple primitives at once but only up to 3
In most cases there are multiple messages ready to be read from
the queue and it is more efficient to read them in one go instead
of going through the select again.
2013-06-24 08:02:34 +02:00
Holger Hans Peter Freyther 44eec601bc sysmobts: Use writev for the outgoing data of the write queue
Attempt to write multiple primitives at the same time instead of
the select/write, select/write that is currently done. The queue
size is big enough to hold several entries at the same time and it
is unlikely we get the -EAGAIN from the kernel driver.

The writev code works by assuming that each element in the queue
has the same size. This is not verified by the code and if this
assumption breaks at some point the code will drop primitives or
send some twice.
2013-06-24 08:02:34 +02:00
Holger Hans Peter Freyther 25346fe0d7 sysmobts: Fix potential memory leaks in the prim callback handling
Make sure the l1msg is always freed in the callback. There were
several error conditions were the msgb would not have been freed,
in the case of the calib data and the system information the message
was not freed even in normal condition.

I will modify this code to __use a msgb. This allows to re-use
the allocated msgb across read operations.
2013-06-24 08:02:34 +02:00
Harald Welte ee43f46cb0 calib: Fix for new EEPROM Mode; better log msgs 2013-06-22 19:30:59 +02:00
Harald Welte 40ca16766d calib: Add fixup for incompatible calib data / firmware version
For certain sysmoBTS units, a fixup to the calibration table is needed,
if the firmware is >= 3.3.0.
2013-06-22 19:30:55 +02:00
Harald Welte 2563267757 calib: Read calibration data from EEPROM, not just files
On v2D (and later) hardware, the calibration data can be read directly
from the EEPROM and doesn't have to be read from files.

If there is no trx-calib-path set in the VTY, we will read from EEPROM.
2013-06-22 19:27:13 +02:00
Harald Welte a899146aea eeprom: wrap DISP_ERROR #ifdef/endif in PERROR() macro
This has the advantage that an user application might simply re-define
the PERROR() macro rather than patching the code all over the place.
2013-06-22 19:22:45 +02:00
Harald Welte 6002d17c24 eeprom: cache the file descriptor instead of fopen/fclose all the time 2013-06-22 19:22:45 +02:00
Harald Welte d675de9c23 initial import of EEPROM calibration read routines 2013-06-22 19:22:45 +02:00
Holger Hans Peter Freyther 6ebabb560e sysmobts: Do not write "trx-calibration-path (null)" in the config file
When not specifying a config path, then saving the running config
it would end up as "(null)" and then leads to an error like this:

 <0006> calib_file.c:147 Failed to open '(null)/calib_rxu_850.cfg' for calibration data.

Add a NULL check to avoid this issue when writing the config file.
2013-06-20 18:17:34 +02:00
Holger Hans Peter Freyther 19cefb0097 sysmobts: Fix a crash when the DSP2ARM queue runs full
When not reading quick enough from the queue we will get a bogus
response which will lead to marking the lchan as broken and to
clear the sapi queue. The sapi_queue_dispatch was checking if the
queue was empty before calling the callback but not taking into
account that it might have been flushed.

Stop processing if the queue was empty before calling the callback
or if it is empty after the callback.

Backtrace:
 #0  0x4eb1f1cc in raise () from /lib/libc.so.6
 #1  0x4eb22f48 in abort () from /lib/libc.so.6
 #2  0x4ecc2cb8 in talloc_abort (reason=<optimized out>) at talloc.c:167
 #3  0x4ecbc854 in talloc_abort_unknown_value () at talloc.c:180
 #4  0x4ecc6bc8 in talloc_chunk_from_ptr (ptr=0x4ec2d494) at talloc.c:192
 #5  _talloc_free (ptr=0x4ec2d494) at talloc.c:517
 #6  talloc_free (ptr=0x4ec2d494) at talloc.c:990
 #7  0x0000f294 in sapi_queue_exeute (lchan=0x402414a0) at oml.c:528
 #8  0x0000f2d4 in sapi_queue_send (lchan=0x402414a0) at oml.c:542
 #9  0x0000f3e0 in sapi_queue_dispatch (lchan=0x402414a0, status=-4) at oml.c:565
 #10 0x000114d0 in lchan_deact_compl_cb (trx=0x4021e038, l1_msg=0x7e690) at oml.c:1269
 #11 0x0000d70c in l1if_handle_l1prim (wq=1, fl1h=0x607c8, msg=0x7e690) at l1_if.c:938
2013-06-20 13:50:44 +02:00
Alexander Huemer d07ee75fc6 Makefile.am: Use AM_CPPFLAGS
Since automake 1.13 INCLUDES is depricates and causes a warning
2013-06-12 08:01:00 +02:00
Holger Hans Peter Freyther c03fe5af31 sysmobts: Allow to enable realtime priority for the BTS process
The latency to respond to a PH-READY_TO_SEND.ind may not be higher
than 18ms. Currently we are using nice to increase our priority but
for a heavily loaded cell this is not enough. Add an option to enable
realtime scheduling and use it in the screenrc.

Linux offers two realtime scheduling classes these are SCHED_FIFO
and SCHED_RR. For SCHED_FIFO the process is running as long as possible
(potentially taking all the CPU and never yielding it), for SCHED_RR
the process can still be pre-empted at the end of the timeslice.

Using SCHED_RR appears to be the more safe option as a run-a-way
sysmobts process will not be able to take all the CPU time.

For a very loaded cell we also require to use readv/writev to allow
writing multiple primitives in one syscall.
2013-05-11 08:34:36 +02:00
Holger Hans Peter Freyther 0d194268fb sysmobts: Use msgb_free instead of talloc_free to free the message
Currently msgb_free is calling talloc_free but we might introduce
a msgb pool in the future. So make sure to use the designated free
method for the msgb.
2013-05-01 19:03:43 +02:00
Holger Hans Peter Freyther bd3250a456 sysmobts: Print the lchan name for the S counter. 2013-05-01 19:03:30 +02:00
Nicolas J. Bouliane 6a4c8a8596 osmo-bts: fix linking order in Makefile.am
On some system (e.g. ubuntu) libosmovty must precede libosmocore
otherwise we get undefined reference errors while linking.

Signed-off-by: Nicolas J. Bouliane <nicolas.bouliane@nutaq.com>
2013-04-18 20:32:23 +02:00
Holger Hans Peter Freyther 0809ae6941 sysmobts: Do not re-configure the channel on non-active channels
In case the channel is not active we can omit the external requests
to modify it. For the channel modification the higher level is already
acking it and for the ciphering it is probably too late to do anything.
2013-03-24 09:05:05 +01:00
Holger Hans Peter Freyther 4c4fd284ae oml: Use the queue for the release handling of a channel
There are three new commands. There are two markers and a deactivate
command. The markers are used to wait until all previous commands are
executed and then to decide if the SAPI needs to be released at all.

When asked to release the SACCH the marker will be queued, then on
execution of the marker the SACCH in Up-/Downlink will be released.

For the RF Channel Release we use another marker, when the marker is
executed we check all the SAPIs we want to release. It is possible that
the queue looks like this:
   (SACCH_REL_MARKER is done) REL_MARKER, SACCH DEACT, SACCH DEACT

This could happen if a BSC sends SACCH Deactivate and RF Channel Release
at the same time. We deal with issue by changing the SAPI state to the
REL_REQ state and check_sapi_release will not ask for another release. So
after the execution the queue will look like this:

  SACCH DEACT, FACCH DEACT, TCHF DEACT..

This code does not check that all allocated SAPIs are released. The
lchan_deactivate_sapis could be changed to go through all sapis_dl
and sapis_ul to fix that.

The normal flow should now be:
1.)  lchan_deactivate
2.)  Check if the queue is empty then go to 4
3.)  REL_MARKER is executed and lchan_deactivate_sapis is called
4.)  For all SAPIs to be released, check if they are allocated and
     then schedule a CMD_DEACTIVATE. If there is an error remember
     something went wrong but continue.
5.)  Once all commands are executed send the channel release ack.

For the release markers we need to be careful as they might not schedule
any work. E.g. if the BSC sends two SACCH DEACTIVATE the second marker
will not generate any release requests and we should proceed with the
next command. Make sapi_queue_command return 1 in case the command has
been directly executed. So a queue like SACCH_REL_MARKER, LOGCH will
result in LOGCH, SACCH DEACT Rx, SACCH DEACT Tx but a 0 will be returned
and the sapi_queue_next will then call sapi_queue_exeute again.

NITB has been modified to trigger these corner cases more easily.
* Do not send IMM.ASSIGNMENT for some timeslots to go through the
error path
* Issue multile SACCH deactivates in the normal release mode
* Send rsl_chan_mode_modify_req before the SACCH DEACT and also when
the RLL is being released.
2013-03-24 09:05:05 +01:00
Daniel Willmann 42cc93efb6 oml: Print out power setting in txpower completion callback 2013-03-24 09:05:05 +01:00
Daniel Willmann 4e46cb8961 oml: Use sapi command queue for setting the logical channel params 2013-03-24 09:05:05 +01:00
Daniel Willmann 5643130664 oml: Enqueue ciphering message through sapi cmd queue as well 2013-03-24 09:05:05 +01:00
Daniel Willmann 376183fcf0 oml: Introduce a SAPI queue for activation and deactivation of SAPIs
Put all SAPI requests into a queue and handle them one after another.
Begin with the channel activation. Once the queue is empty the channel
activate will be sent. For the BCCH activation we do not want to send
a channel activation message and this is why we set the lchan->state
to NONE.

One change is that we do not attempt to call the ciphering routines on
the BCCH anymore.

This change is necessary to fix issues with LCHANs staying open and being
marked as broken by the BSC and will help in implementing handover support
as this requires a re-configuration of the lchan on the fly.
2013-03-24 09:05:04 +01:00
Holger Hans Peter Freyther 9d91c60875 sysmobts: Prepare to address the documented limitation of this code 2013-03-24 09:05:04 +01:00
Andreas Eversberg 118eb43ba5 fixup e2cde1f48379657402332b5a95d4ce242d63069a 2013-03-18 18:05:24 +01:00
Andreas Eversberg cdc5a4dc38 Add VTY option to define minimum C/I level for RACH and normal burst 2013-03-17 17:43:02 +01:00
Andreas Eversberg 5cbc7e9167 Get RSSI from received uplink data and send to PCU
This bumps the PCU API version and thus requires a new version of the
code on the sysmoBTS side!
2013-03-17 17:43:02 +01:00
Andreas Eversberg 54dd949e62 Fix: Stop RADIO LINK TIMEOUT couter S from counting, if it has reached 0
In case that the counter S reached 0, it will stay 0. Subsequent received
good and bad SACCH frames must not cause to trigger radio link failure
again. Once the BSC has been indicated about link failure, it will release
channel.

The counting of S has been moved to a seperate function.

This patch will ensure that the link failure is indicated only once. But
even if the link failure would be sent multiple times, the BSC should
ignore it. The BSC releases the channel and may only reuse it after confirm
from BTS. (There cannot be any link failure indications after confirm of
channel release.)

The allowed timeout value range is 4..64, as defined in TS 05.08, so if the
BSC sends an attribute with value out of range or other failure criterion,
the Set BTS Attributes message is NACKed.
2013-03-15 21:41:27 +01:00
Andreas Eversberg 294fd1b650 Added radio link timeout procedure according to TS 05.08 Chapter 5.2
Chapter 5.2 applies to MS procedure, but 5.3 (BSS procedure) defines no
exact criterion, so I decided to use the procedure equivalent to MS.

The criterion is based on a counter S, which is initialized to a preset
RADIO_LINK_TIMEOUT, which can be configured via VTY. Whenever a received
SACCH block is bad, S is counted down by one. If SACCH block is
successfully decoded, S is counted up by two, but never above initial
RADIO_LINK_TIMEOUT value. If S reaches 0, an RSL Connection Failure
Indication with cause RF Radio Link Failure is sent to BSC, which then
aborts channel.

Use link timeout value from BSC via OML attribute.

How to test:
- Set "debug" for "meas" logging.
- Start silent call to an attached mobile.
- Remove battery from mobile or shield mobile.
- Watch S count down.
2013-03-11 11:47:41 +01:00
Harald Welte 19f212951a l1_if: if ul_power_target==0, hard-code MS power to what RSL says
RSL CHAN ACT contains a MS_POWER IE which is intended to be used as the
initial power level for the MS, before the UL power control loop is
starting.

In our case, if ul_power_target != 0, then the DSP takes care of power
control.  If ul_power_target == 0, then we instruct the phone to
constantly use the value specified by the BSC in the MS_POWER IE.

FIXME: Actually implement a proper power control algoritihm inside
osmo-bts so we don't have to rely on the DSP implementation.
2013-03-07 10:07:18 +00:00
Harald Welte cf4e3501a1 gsmtap: Put the RxLevel and RxQual in uplink GSMTAP 2013-03-06 19:58:26 +00:00
Holger Hans Peter Freyther b7eb9865df calib: Use 2.4.0 as cut-off for the firmware, log errors
In case opening a calibration file is failing an error will will be
logged, the caller and implementation were inconsistent about the API
version that is supported for the calibration data, attempt to make
the cut-off at 2.4.0.
2013-02-27 11:10:33 +01:00
Holger Hans Peter Freyther faba73a812 sysmobts: Improve the shutdown of the DSP on exit
Issue the RfDeactivate.REQ before sending the MphClose.REQ. Ideally
we would issue MphClose.REQ after the RfDeactivate.CNF but this is
not possible right now.

The current approach makes the following warning of the DSP go away
on shutdown. This was tested with my E71 and an active silent-call
using a SDCCH.

DSP Warning:
[ERROR] : DeviceMng_ValidateL1Handle() => Invalid layer 1 handle
2013-02-27 10:44:01 +01:00
Holger Hans Peter Freyther 5e46e4b488 sysmobts: Fix a memory leak when no callback is set
The TxPower handled used to call the requestion function without
a callback. In that case the msgb is leaked. The code still allows
the callback to be NULL so we will just delete the message in that
case.
2013-02-27 09:07:18 +01:00
Holger Hans Peter Freyther 3d383c22c7 sysmobts: Remove the is_system_primitive from l1if_req_compl
All users (but the gsm_compl) of the l1if_req_compl use it with
is_system_primitive=1. We can now remove this parameter from the
method. Introduce _l1if_req_compl that will insert the item into
the queue for us.
2013-02-27 09:07:18 +01:00
Holger Hans Peter Freyther 654fe73b78 sysmobts: We can now pass the trx to the callback change the signatures 2013-02-27 09:07:18 +01:00
Holger Hans Peter Freyther 6142f9262a sysmobts: Remove the trx parameter from the signature
l1if_gsm_req_compl everyone is passing the trx as data pointer right
now, remove it from the request procedure right now as it can be
deducted from the femtol1_hdl.
2013-02-27 09:07:17 +01:00
Holger Hans Peter Freyther 64c5e3a19c sysmobts: Embed the calib state in the femtol1_hdl and use hdl->priv 2013-02-27 09:07:17 +01:00
Holger Hans Peter Freyther b6942ffeb9 sysmobts: Use the hdl->priv in l1if_req_compl for all callers 2013-02-27 09:07:17 +01:00
Holger Hans Peter Freyther ff4f789249 sysmobts: Remove the data parameter from the l1if_gsm_req_compl
Pass in the trx argument at the lower level as everyone is using
the fl1h->priv now.
2013-02-27 09:07:17 +01:00
Holger Hans Peter Freyther 0890e274b1 sysmobts: Use the fl1h->priv and get the ts back from the response 2013-02-27 09:07:17 +01:00
Holger Hans Peter Freyther 60b090ac53 sysmobts: Use the fl1h->priv to get the trx instead of using the lchan
I am working toward killing the last argument of the l1if_gsm_req_compl
and just have the trx inside the callback signature.
2013-02-27 09:07:17 +01:00
Harald Welte 6a2d89f48d Make sure SACCH fill frame is correctly aligned for L1 header
When we send a fill frame on SACCH, we need to have two bytes for the L1
header at the beginning (inserted by the DSP).

Thanks for Andreas Eversberg for pointing it out.
2013-02-04 22:16:23 +01:00
Daniel Willmann bcd50d3219 oml: Create mph_send_activate_req for sending the activation request
Move the channel activation out of the loop into a dedicated function.
This is done in preparation of separating the decision to activate
something and sending the request.
2013-01-24 12:15:10 +01:00
Holger Hans Peter Freyther f0c5a424af sysmobts: Send GSM requests using the l1if_gsm_req_compl method
Prepare to change the queue and callback handling. For the TX power
VTY command it is still possible that it will conflict with other
callbacks and the easiest way is to beging with sending these requests
through another method that allows us a more strict test.
2013-01-23 18:23:58 +01:00
Holger Hans Peter Freyther 76a1bf6136 sysmobts: Help in calling the right callback for l1if_req_compl
The wait list code has a limitation that for two requests of the
same kind it does not know where the confirmation belongs to. This
limitation is triggered when two lchan's get activated/deactivated
at the same time and is noticed once we start to count the SAPIs.

Set the hLayer3 to the lchan identifier, use the trx as closure for
the callback and resolve the lchan in the callback using these two
bits of information.
2013-01-23 18:23:58 +01:00
Holger Hans Peter Freyther e210f1a864 sysmobts: Rename the hLayer2<->lchan to hLayer<->lchan
We are using this conversion for both hLayer2 and hLayer3. Make the
function name more generic to indicate that this function can be used
with the hLayer3.

The functions that call the methods were updated using spatch and
@rule1@
expression E;
expression F;
@@
- l1if_hLayer2_to_lchan(E, F)
+ l1if_hLayer_to_lchan(E, F)
@rule2@
expression E;
expression F;
@@
- l1if_lchan_to_hLayer2(E)
+ l1if_lchan_to_hLayer(E)
2013-01-23 18:23:58 +01:00
Holger Hans Peter Freyther 61e739912f sysmobts: Ignore too short messages on the FACCH (but also the SDCCH)
During call testing using an E71 and dialing a number of an expired (lac
set to 0) subscribe the CC Release and other messages are sent after or
during the channel modification. This appears to lead to some reception
issues in the DSP code and giving use empty (u8size == 0) FACCH frames.
The real issue might be inside the MNCC code of NITB and the lack of a
size check inside the LAPDm code (our msgb has enough data though).
Passing the empty FACCH frame into the LAPDm code lead to the generation
of RSL ERROR INDICATION with cause FRAME_UNIMPL as some bits were zero.

Add a check for 0 into the FACCH code. As the code path is shared with
SDCCH it is also discarding zero sized SDCCH frames. These have not been
observed during my testing. The lacking size check in LAPDm will be
addressed separately.

During call testing the IPA CRCX was also failing due the BTS trying
to bind to an unassigned IP address.
2013-01-23 18:22:11 +01:00
Holger Hans Peter Freyther 4a303c7c38 oml: Fix memory leak in the callback 2013-01-23 18:22:11 +01:00
Harald Welte 8597a278d6 l1_if: don't print measurements a second time in case of error 2013-01-23 17:42:17 +01:00
Holger Hans Peter Freyther 6ddd632adf sysmobts: Use a newline at the end of the SACCH u8Size < 2 message
The other message in this method is using a \n as well and the line
is generally now followed with a LOGPC.

It looked like this:
<0006> l1_if.c:672 SACCH with size 0<2 !?!<0006> tch.c:540 (bts=0,trx=0,ts=2,ss=0) Rx Payload size 0
2013-01-17 21:14:40 +01:00
Holger Hans Peter Freyther 3177f2b42f sysmobts: Fix the comment referring to the value of the timeout
Right now it is 30 seconds and not 10.
2013-01-03 16:39:41 +01:00
Holger Hans Peter Freyther 222a6a5e23 l1_if: Fix typo... call it femtobts 2012-12-29 12:23:09 +01:00
Holger Hans Peter Freyther 0670138ffc tch: Do not print that there is no audio data on a TCH/H
When only signalling is used on the TCH/H it is normal that there
is no TCH data. Save CPU time by not printing the message. This
needs to be moved to be edge triggered.
2012-12-26 19:50:10 +01:00
Holger Hans Peter Freyther 19cf0e81b3 ciphering: Handle ciphering support for A5/3 correctly
This was found and debugged by Sylvain. The BTS will always support
A5/0 so we do not keep track of that, the first bit of the flags is
used for A5/1, second for A5/2... but for RSL there is an offset to
go from RSL to A5(x). Add a testcase and change the code.
2012-12-26 18:55:54 +01:00
Holger Hans Peter Freyther 3bcf3a5fd0 sysmobts: Add all header files to the EXTRA_DIST to fix make distcheck 2012-12-22 15:03:19 +01:00
Holger Hans Peter Freyther ce7559fbec misc: Fix compilation on debian stable with GCC 4.4.5
l1_transp_hw.c:89: error: redefinition of typedef 'dummyprim'
l1_transp_hw.c:88: note: previous declaration of 'dummyprim' was here
2012-12-22 14:37:30 +01:00
Holger Hans Peter Freyther bcae2abff8 openbsc: Prepare to allow to have the OpenBSC directory somewhere else
Right now osmo-bts requires access to one OpenBSC header file and
this requires that openbsc and osmo-bts git are in the same directory.
Begin with making the location of the OpenBSC sourcecode configurable.

This approach will allow to build osmo-bts on our Jenkins installation
but now has the risk of more code including the openbsc/*.h header files.
2012-12-20 19:02:37 +01:00
Holger Hans Peter Freyther d1ffab96ca misc: Forward declare calib_load to address a compiler warning 2012-12-20 19:01:27 +01:00
Holger Hans Peter Freyther 61a1f99680 misc: Forward declare l1if_set_ciphering to avoid a compiler warning 2012-12-20 19:01:27 +01:00
Holger Hans Peter Freyther 6ae49691af sysmobts: Transmit the UI idle frame as a LAPDm Command
When transmitting an idle frame the BTS should transmit it as a
command and not a response. This is unbreaking the mobile application
of osmocomBB.
2012-11-26 01:33:52 +01:00
Harald Welte 36e73dd7ed Ensure osmo-bts builds agsainst sysmobts-v1 headers (again) 2012-11-18 10:38:32 +01:00
Harald Welte ce826f3fc4 VTY: make target uplink Rx level VTY-configurable
We used to have -75 dBm as the target value for the uplink receive
level.  Now this is configurable.

The parameter is used as input into the power control loop that adjusts
the MS transmit power in order to achieve the target rx value on the
BTS Rx input.
2012-11-10 18:15:53 +01:00
Harald Welte 7350736054 l1_if: Dump measurement data in case we receive SACCH without data
On the uplink SACCH, we should at least receive the two bytes SACCH
uplink header from the phone.  But sometimes we don't.  Log this more
verbosely.
2012-11-10 18:06:02 +01:00
Harald Welte fffbfd9890 l1_if: add 'log level' to dump_meas_res() function 2012-11-10 18:04:54 +01:00
Harald Welte a066e334dd Measurement: Correctly report L1 SACCH uplink header in RSL
For whatever reason, the order of fields in the L1 SACCH header is
different from 04.04 (Um) and 08.58 (A-bis).  Please note that it's not
just a different bit order, but actually logically re-ordering the
fields within the byte, while keeping the bit-order/-endian.

We now correctly report the L1 transmit power up the stack.
2012-11-10 18:02:13 +01:00
Harald Welte d1335d878b sysmobts: Add support for reading calibration tables
'trx-calibration-path' is the new VTY command indicating the path
name where the calibration files can be found.

Calibration is only implemented for SUPERFEMTO API version 2.4.0 or
later.
2012-10-28 10:58:41 +01:00
Harald Welte 98a4404279 l1_transp_fw: don't use printf() and dont print things twice 2012-10-28 10:17:42 +01:00
Harald Welte 5705cfaebc properly display the header file versions 2012-10-28 10:01:21 +01:00
Harald Welte c3646a80a7 sysmobts: Add code to read calibration files
... and convert them to L1 primitives.  The code is not yet used.
2012-10-27 21:44:18 +02:00
Harald Welte 8debeeeeea make it build against sysmobts v2 APO 0.1, 0.2, 1.0, 2.0, 2.1, 2.2, 2.4 and 3.0 2012-10-27 18:06:03 +02:00
Andreas Eversberg 255343db4b Fix: Remove Bad frame Indicator from PDCH blocks before sending via GSMTAP 2012-10-22 10:34:08 +02:00
Andreas Eversberg 0efca9a1f9 Set correct GSMTAP channel type for PDTCH/PACCH 2012-09-29 20:31:15 +02:00
Harald Welte f91924bb18 sysmobts VTY: update to new libosmocore
libosmocore 40832fcfb58c8c97c66e098c5705352ac5beea8e and later contain
the vty_cmd_string_from_valstr() function, so we shouldn't have
a local / deprecated copy anymore.
2012-08-17 12:40:52 +02:00
Holger Hans Peter Freyther 8c3d807b3f sysmobts: Do not ignore the band configuration of the BTS.
The band was derived from the ARFCN but this does not work for
PCS1900/DCS1800 due overlapping ARFCNs. Use the already existing
band configuration to select the band for the MphInitReq. The
dsp firmware will complain if the band/arfcn do not match.
2012-08-09 12:15:41 +02:00
Andreas Eversberg 7daa093df7 PCU: Removed -P option, so GPRS support is always enabled 2012-07-26 21:14:02 +02:00
Holger Hans Peter Freyther b86bf060d3 sysmobts: Support older firmware on the RevB hardware
For the firmware used on RevB the GsmL1_Prim_t was bigger than
the femtobts control structure. Solve it by introducing a macro
that will select the biggest size and use this macro. This is a
follow up fix for 08fce19cfc.
2012-07-26 20:18:53 +02:00
Holger Hans Peter Freyther e5a04ea35d vty: Document the gsmtap SAPI and the dsp trace flags parameters
Introduce femtobts_tracef_docs with some more information about
the traceflags, add parameters to the vty_cmd_string_from_valstr
for specifying the separator, the suffix and if the name should
be lowered.
2012-07-25 13:18:28 +02:00
Harald Welte 7c2427c020 l1_if: indicate against which api header files we were compiled 2012-07-22 22:47:06 +02:00
Harald Welte 678321d013 determine (and use) the API version as indicated in the header files
From our header files v2.4 onwards, we include some macros that allow us
to do compile-time checks for the API header version.  As older headers
don't have those macros, we have to fall back to assume it will be v2.2
2012-07-22 22:42:36 +02:00
Andreas Eversberg 1ddb183736 Enable direct access to PDTCH queue of DSP by PCU
Use "-P -M" to enable PCU and direct access.
2012-07-21 13:18:45 +02:00
Holger Hans Peter Freyther c2d3e45571 sysmobts: The array size for the clocksources has increased to 10. 2012-07-20 15:30:06 +02:00
Andreas Eversberg d40d4d6071 Allow L1 forward proxy to provide all 4 queues to seperate applications
Different applications can now connect to L1 forward proxy or access DSP
directly, if they use different message queues.
2012-07-19 20:33:37 +02:00
Andreas Eversberg 08fce19cfc Allocate correct message size for L1 primitives
This is required for using firmware v2.4
2012-07-19 20:29:56 +02:00
Andreas Eversberg 5a53eff4cb sysmobts L1: fix memory leaks for GPRS
we have to hand off the PH-RTS.ind to the PCU interface _before_
we allocate a response msgb/primitive.
2012-07-16 18:48:55 +02:00
Harald Welte 38420fb951 add new sysmobst-mgr daemon
This daemon is taking care of counting the number of hours in operation
and to watch the system temperature as determined by internal
temperature sensors.

Later, it will export an external interface for firmware reload, as well
as a way to raise OML ALARMs in case of temperature issues or other
problems.
2012-07-11 01:32:42 +02:00
Harald Welte 438a28714d l1_if: skip processing of measurement results on PDTCH
In case of PDTCH, the PCU has to process measurements, not the BTS.
2012-07-09 15:51:42 +02:00
Andreas Eversberg 744f745d7a PCU: Add PCU socket interface to BTS.
A special command line option "-P" is used to enable socket interface
and signal available GPRS MO object to BSC.
2012-07-08 20:50:02 +02:00
Andreas Eversberg 343cae60b6 lchan: Activate PTCCH/PRACH/PDTCH/PACCH when activating PDCH 2012-07-08 18:48:58 +02:00
Andreas Eversberg ea15101896 Fixed check for RACH (random access) delay 2012-07-08 18:44:40 +02:00
Andreas Eversberg b57e17394b Fixes for handling of GPRS NSE/NSVC/CELL MO 2012-07-08 18:03:04 +02:00
Harald Welte 71b216d995 l1_if: don't enable any GSMTAP by default
the user has to explicitly enable it in the VTY
2012-07-05 15:31:06 +02:00
Harald Welte d53ae2d0f1 sysmobts_vty: Fix setting GSMTAP sapi, as well as save/restore in cfg 2012-07-05 15:31:05 +02:00
Harald Welte 5f8a3149fe sysmobts: avoid sending duplicate RSL CHAN ACT ACK
This is just an intermediary hack, until we get proper lchan manager
threads...
2012-07-05 15:31:05 +02:00
Harald Welte 13e92be8bf Implement NM_ATT_MAX_TA in sysmobts backend 2012-06-15 14:54:33 +08:00
Harald Welte 821bf067e4 RSL: Add CCCH LOAD INDICATION for RACH
We now count the total number of RACH slots, the number with rx level
above the busy threshold, and the number of valid access bursts.

This data is used to generate RSL CCCH LOAD INDICATION for the RACH.
2012-06-15 11:07:03 +08:00
Holger Hans Peter Freyther ad3e31dc4b sysmobts: The meaning of the clock value changed from v1 to v2
In v2 the calibration value is the clock error in ppb that needs
to be compensated. Create a V2 specific implementation. Write the
clock value unconditionally as it is initialized to 0 by default
and not 0xffff.
2012-06-05 09:34:33 +02:00
Holger Hans Peter Freyther 1c069cd0a0 sysmobts-v1: Fix compilation by using the right define 2012-06-05 09:17:26 +02:00
Harald Welte 0455e51cd5 Use git-generated PACKAGE_VERSION in IPA IDTAG_SWVERSION
We previously used to send the bogus string "0815" which was a hack
from early development time, but is obviously not a generally useful
idea.
2012-06-03 11:47:42 +02:00
Harald Welte 799ea59c2f sysmobts: set the RF ACTIVE LED when we bring RF up
Once we get RF-ACTIVATE.conf from L1, we now enable the corresponding
LED.  We also switch it off on RF-DEACTIVATE.conf.  We do _not_ switch
it off when osmo-bts crashes or terminates before RF-DEACTIVATE.conf.

The latter is intentional, as RF may very well still be active at that
point.  The re-spawning script will re-set the DSP and therby turn off
the RF and then disable the LED.

A better solution might be to do all this in the kernel driver for the
DSP.
2012-06-01 00:06:58 +02:00
Harald Welte 700c645478 add /var/lock/bts_rf_lock and /var/run/osmo-bts.pid for rf control
an external application can create /var/lock/bts_rf_lock and then kill
the pid in /var/run/osmo-bts.pid in order to shut down the BTS.  Any
re-spawning scripts will trigger, but osmo-bts will refuse to start up
until /var/lock/bts_rf_lock is removed again.
2012-05-31 21:02:18 +02:00
Harald Welte 346e531222 sysmobts: fix double-free if msgq cannot be opened 2012-05-31 20:58:57 +02:00
Harald Welte 268c7f02fd sysmobts l1: make sure to read messages of arbitrary size
... and warn if the size is not what we expect.

This is required to work with sysmobts-v2 firmware >= v2.1, as the
SuperFemto_Prim_t is now larger than the GsmL1_Prim_t.
2012-05-13 15:25:27 +02:00
Harald Welte 388b9d0a35 Adapt to L1 firmware/API version 2.1 2012-05-13 14:16:28 +02:00
Holger Hans Peter Freyther 9de1e9f914 sysmobts: Document the values of the clock-source in the vty command
We need to have a documentation for each possible value, add some simple
ones for the available clock sources.
2012-05-12 08:49:35 +02:00
Holger Hans Peter Freyther 7fe0838588 sysmobts: Save the clock-source to the config file
Make the clock names lower case to match with the vty command.
2012-05-12 08:49:35 +02:00
Holger Hans Peter Freyther 3af5426d71 sysmobts: Add Network Listen as clock source for the bts 2012-05-12 08:49:35 +02:00
Holger Hans Peter Freyther f7fd2e4798 sysmo-bts: Use HW_SYSMOBTS_V1 to select the development hardware 2012-04-28 17:05:03 +02:00
Holger Hans Peter Freyther 36a3b0d85b sysmo-bts: Move the payload setting into a new method
Make this code a bit easier to read by moving the payload setting
into a new method.
2012-04-28 17:04:56 +02:00
Harald Welte 227c57728a fix the idle filling to comply with 04.06 5.4.2.3 (UI frame 0 byte len)
We used to send some crap before, which most phones happily accepted but
some (particularly the Wavecom Q2686) didn't really like at all.
2012-04-26 21:00:18 +02:00
Holger Hans Peter Freyther baa88d542c lchan: I forgot to handle TchH in my recent lchan fixes, add it to another place
Harald fixed the issue for the activation by adding TchH, but this
needs to be added for de-activation as well.
2012-04-20 10:44:43 +02:00
Harald Welte d28b9940b9 sach_deact -> sacch_deact (follow spelling fix in openbsc) 2012-04-19 23:51:50 +02:00
Harald Welte 2b7aace0b5 add vty-configurable loopback mode
this allows the BTS to loop-back any incoming data on a TCH
2012-04-19 22:29:07 +02:00
Harald Welte b1644b22d0 Fix TCH/H channel activation after zecke's recent lchan fixes 2012-04-19 22:27:55 +02:00
Harald Welte bcd08888f9 add VTY command to manually alter transmit power
this allows for quick manual tx power changes from the VTY, particularly
useful in type approval or other measurements.
2012-04-19 20:19:21 +02:00
Harald Welte 9aa6d9496b l1_if: allow for l1prim or sysprim without a completion callback 2012-04-19 20:18:53 +02:00
Harald Welte ff9e904926 fix VTY help strings related to TRX 2012-04-19 19:47:55 +02:00
Harald Welte f19ee66096 add a VTY command for activating PDCH channels (in EGPRS mode)
This allows us to do RF measurements (EDGE EVM and the like) even
without having any PCU/RLC/MAC code as of now.

To use it, configure PDCH type timeslots (e.g. TS 7) in the BSC and then
use "trx 0 7 activate 0" to manually activate the PDTCH lchan on top
of that timeslot.  The BTS will now happily transmit EDGE/8PSK data.
2012-04-19 19:22:53 +02:00
Harald Welte f5a0a439e9 ciphering: Make sure to initialize lchan to no ciphering when activating
The ciphering parameters in L1 are persistent accross MPH
deactivate/activate, so we need to make sure to always initialize them
cleanly at RSL CHAN ACT time.  This has the added benefit that we can
also activate channels that have encryption enabled from the very
beginning (required for encrypted handover).
2012-04-19 10:06:00 +02:00
Harald Welte bf91f06eca Improve logging of L1 MPH request by printing the direction
where previously we would only see
<0006> oml.c:931 (bts=0,trx=0,ts=1,ss=0) MPH-DEACTIVATE.req (FACCH/F)
we now get
<0006> oml.c:931 (bts=0,trx=0,ts=1,ss=0) MPH-DEACTIVATE.req (FACCH/F RxUL)

to notice it is modifying the receive path in the uplink direction.
2012-04-19 09:50:02 +02:00
Holger Hans Peter Freyther d7718280c9 lchan: Send the ACT ACK/NACK after the Layer1 has handled act/deact
Send the RSL ACT ACK/NACK after the Layer1 firmware has acked the
activation/deactivation. In case the channel can not be activated
we will send a NACK. In case the channel can not be deactivated we
will send an ACK and the next time the channel is activated we will
send a NACK. The release ack will be sent once the TxDownlink of the
TCH/SDCCH is closed.

Change the rsl_tx_chan_nack method to create a new msgb to be used
by the hardware layer, change the return value to ask the caller to
delete the msgb.
2012-04-19 09:39:54 +02:00
Holger Hans Peter Freyther 1e2b3259b9 lchan: Separate the Uplink/Downlink in activate/deactivate 2012-04-19 09:39:53 +02:00
Holger Hans Peter Freyther 29e1fdd994 lchan: Deactivate the SACCH only once, use the sach_deact flag for that
Use the deact_sach (renamed to deact_sacch in master) to remember if the
SACCH has been disabled. This should fix the case of lchan errors due releasing
the lchan twice.
2012-04-19 09:39:52 +02:00
Holger Hans Peter Freyther eac221b4ea lchan: Fix the state transition in the deactivate handler
If the deactivation is failing the channel needs to be moved into
and error state, if the deactivation completed the channel needs to
be set to the none state and set the state to release reqeust on
the deactivation.
2012-04-19 09:39:51 +02:00
Holger Hans Peter Freyther f4f69ee6fc lchan: Similar to OpenBSC use a set method to change the state
By making all modifications through lchan_set_state we can easily
add code to verify the state transition.
2012-04-19 09:39:15 +02:00
Holger Hans Peter Freyther f1052b812d sysmobts: Add an option to query the hardware version. 2012-04-19 09:38:30 +02:00
Holger Hans Peter Freyther 0be33e3add common: Add the copyright text to the vty_app_info
This will make app -V print the copyright information like the other
applications of our universe. An BTS integration that want to list
additionaly copyright holders needs to access the vty_app_info and create
a new copyright string.
2012-04-19 09:38:30 +02:00
Harald Welte b03f8ae4f0 ciphering: Better state tracking and HACK around L1 race condition
We now check if the received message is an LAPDm I frame in order to
determine if we have received the first valid encrypted message on the
radio link.  This relates to the fact that we often see 'old' UI frames
coming up from L1, even after it has confirmed decryption has been
enabled.
2012-04-19 09:35:03 +02:00
Harald Welte d9ab45d1aa Support for ciphering
When the RR CIPH MODE CMD is transmitted to the MS, we need to tell the
L1 to enable decryption on RX.  After the first received frame has been
decrypted successfully, we will enable encryption also on transmit.

This has been tested with A5/1 so far, but A5/2 and A5/3 should work
exactly identical.
2012-04-19 08:22:29 +02:00
Harald Welte 51f9693ba6 make HR channels work for voice, not only signalling
without this, we would set a FR_V1 codec on a TCH/H channel, which
the L1 is obviously not happy with.
2012-04-19 08:21:41 +02:00
Harald Welte b34faf6f8c TCH: Add support for the L1 RTP mode
In L1 RTP mode, the L1 already does all the bit-shifting and re-ordering
required for the RTP formats (which have different bit/nibble order than
the ETSI/3GPP encodings, for some odd reason).

We don't enable it by default yet, as only HR/FR/EFR work with it, but
AMR has some yet to be debugged problem.

Enabling USE_L1_RTP_MODE would save some CPU cycles on the ARM side.
2012-04-18 20:03:18 +02:00
Holger Hans Peter Freyther bc74b7f432 femtobts: The separate pdch/tch queues are not available in the old firmware
The old firmware does not expose separate queues for PDCH and TCH. The change
appears to be too intrusive and I will try to find a more elegant solution.
2012-04-14 14:56:58 +02:00
Holger Hans Peter Freyther f4a5bd2dd2 sysmobts: Handle options before allocating the bts
This way -h/--version will always work, even when the underlying
hardware is not available.
2012-04-14 14:36:23 +02:00
Holger Hans Peter Freyther 58f419c7ce misc: Use sizeof(uint32_t) instead of simply using 32 bit
This code would break in case we shrink the bitmap, use sizeof instead.
2012-04-14 01:03:28 +02:00
Holger Hans Peter Freyther 11a787df24 femtobts: Use HW_FEMTOBTS instead of HW_VERSION_1 to select femtobts
Our header files use HW_FEMTOBTS guards to select the older femtobts
design. Use the same macro in the bts code.
2012-04-14 00:54:40 +02:00
Holger Hans Peter Freyther caaa7e9d7b misc: Address a compiler warning and add an assert to a branch
The compiler can not know that the "int priv_nr" will hold the
enum values of the write queue, add a default branch and add a
warning and an assert there.

l1_transp_hw.c:108:1: warning: control reaches end of non-void function [-Wreturn-type]
2012-04-12 22:31:06 +02:00
Holger Hans Peter Freyther 76aa95453f misc: Fix compiler warning of the femtobts_clksrc_names
femtobts.c:249:2: warning: excess elements in array initializer [enabled by default]
femtobts.c:249:2: warning: (near initialization for ‘femtobts_clksrc_names’) [enabled by default]
2012-04-12 21:52:22 +02:00
Harald Welte a0970249bf osmo-bts-sysmo: Add gsmtap for uplink 2012-04-05 00:41:35 +02:00
Harald Welte f4d14b3f2e set the default log mask for the L1 a bit more reasonable 2012-03-18 23:27:27 +01:00
Harald Welte d25b6a752b osmo-bts-sysmo: Add GSMTAP support for transmit (DL) path
there are VTY commands that can be used to filter which particular
L1 sapis (channel types) should be sent in GSMTAP.
2012-03-18 23:24:12 +01:00
Harald Welte 3cf942792a correctly print SAPI in log file on MPH-ACTIVATE.req 2012-03-18 21:46:44 +01:00
Harald Welte 21724bbaed Fix debug print of MPH-CONFIG.req 2012-03-18 21:35:15 +01:00
Harald Welte 12b95405ff print human-readable SAPI name on MPH-[DE]ACT.{req,conf} 2012-03-18 21:34:05 +01:00
Harald Welte 452112e823 Ensure that ADM_STATE IE is presnent when sending NM_MT_CHG_ADM_STATE_ACK 2012-03-18 21:25:45 +01:00
Harald Welte d0e6749327 Issue MPH-CLOSE.req during shutdown
If we don't do this on recent L1, the L1 will refuse the open after
re-starting osmo-bts.

There still is an issue in case osmo-bts crashes.  We should have a
respawn loop that re-loads the DSP firmware before re-starting osmo-bts,
just to make sure...
2012-03-17 14:25:34 +01:00
Harald Welte b81c5d4699 introduce a command that permits setting the clock source via vty
the default source is the OCXO
2012-03-17 14:08:51 +01:00
Harald Welte 3525f2c038 we currently run the board alwasy in clock master mode 2012-03-15 23:39:37 +01:00
Harald Welte 20d73555a2 update to new "superfemto.h" header file naming 2012-03-15 21:27:21 +01:00
Harald Welte 47589f10a4 Introduce a HW_VERSION_1 #define
This #define helps us to distinguish the subtle API differences between
the earlier v1 (2011) hardware and the later v2 (2012) model.
2012-03-07 18:05:57 +01:00
Harald Welte f1cbd81984 prepare for splitting L1 queue into signalling/tch/pdtch
We don't use multiple queues yet, but we very well might end up using
them soon.
2012-03-07 18:05:18 +01:00
Holger Hans Peter Freyther 6dd7c4fb57 misc: Check return value of msgb _alloc functions
Attempt to catch all functions that allocate a msgb and didn't
check the return value of the allocation.
2012-01-23 10:22:09 +01:00
Holger Hans Peter Freyther 2e677958d2 efr: Add efr to the femtobts_tch_pl_names array
Parts of the code check if GsmL1_TchPlType_Efr is defined, others
parts don't. Follow the easy route and assume it is defined.
2012-01-14 21:47:59 +01:00
Holger Hans Peter Freyther 62579c7a34 oml: Mention the SAPI that is activated in the log message
I was wondering why the channel was activated twice but it needs
to be activated for each SAPI.
2012-01-14 21:47:41 +01:00
Holger Hans Peter Freyther eab71534ef sysmo: handle_ph_data_ind has paths rc is not initialized
rc might not be initialized when going through the default
statement but also hitting a break inside the switch case
statement for GsmL1_Sapi_Sacch.

l1_if.c:530:2: warning: Undefined or garbage value returned to caller
        return rc;
2012-01-14 21:47:19 +01:00
Holger Hans Peter Freyther 6aa2a574fb sysmo-bts: The code is not used (and built), remove it.
The BTS is using the LAPDm code in polling mode, there will be no
callbacks (e.g. a BTS does not transmit RACH bursts). Remove the code.
2012-01-11 19:27:54 +01:00
Holger Hans Peter Freyther 79da6f3283 misc: Move the cmr_index into the #if 0 block as it is only used there 2011-11-29 21:55:12 +01:00
Harald Welte fe4893e625 RSL: Actually check if BSC-requested cipher is supported 2011-11-24 17:46:22 +01:00
Holger Hans Peter Freyther 2660812084 audio: Make bts_model_rtp_rx_cb compatible with the prototype 2011-11-07 14:26:48 +01:00
Holger Hans Peter Freyther 5cdcf8a837 sysmo-bts: Include bts.h for bts_shutdown, remove unused variable 2011-11-07 14:13:29 +01:00
Holger Hans Peter Freyther 477f35e78c sysmo-bts: Use the z modifier to print the result of sizeof 2011-11-07 14:08:46 +01:00
Holger Hans Peter Freyther 187871e2ca sysmobts-vty: Fix compiler warnings about the clock value
The first one just sets the val to 0xffff, the second converted
the value to integer twice.

sysmobts_vty.c: In function ‘cfg_trx_clkcal_def’:
sysmobts_vty.c:109:15: warning: unused variable ‘clkcal’ [-Wunused-variable]
sysmobts_vty.c: In function ‘cfg_trx_clkcal’:
sysmobts_vty.c:122:15: warning: unused variable ‘clkcal’ [-Wunused-variable]
2011-11-07 14:02:02 +01:00
Harald Welte 9582883235 add VTY based way to set clock calibration of sysmobts L1 2011-10-12 13:36:22 +02:00
Harald Welte c373448e03 fix various compiler warnings across the code
this deals with unused cocde, unused variables and undeclared symbols in
various places.
2011-09-19 20:46:51 +02:00
Harald Welte 7899dc5fcf sysmobts: fix initial codec mode computation
There is no off-by-one between osmocom and L1 definitions...
2011-09-09 23:55:39 +02:00
Harald Welte 215d9eecdd sysmobts: channel activation changes for v2.4 L1 DSP firmware
We now have to explicitly indicate the tchPlType at channel activation
type, so L1 knows which channel decoder to use (FR, EFR, AMR, ...)

Also, we properly implement the initial codec mode selection as per TS
05.09
2011-09-09 23:30:46 +02:00
Harald Welte a4a3574b1d update osmo-bts to conform to L1 v2.4 API changes 2011-09-09 15:12:52 +02:00