Commit Graph

406 Commits

Author SHA1 Message Date
Jacob Erlbeck 35a8144e41 agch: Add simple counters
Counters are added for the following events (use VTY show to query):

  - Dropped IMMEDIATE ASSIGN REJECT messages
  - Merged IMMEDIATE ASSIGN REJECT messages
  - Rejected AGCH messages
  - Use of PCH (non-reserved) for AGCH messages
  - Use of AGCH (reserved) for AGCH messages

Sponsored-by: On-Waves ehf
2014-03-10 08:55:02 +01:00
Jacob Erlbeck 4fbe06b3f2 agch: Recalculate length limit of AGCH queue
This patch adds a function bts_update_agch_max_queue_length()
to compute a limit of the AGCH queue. This is based on the idea,
that the AGCH queue has a limited drain rate and that CHANNEL
REQUESTs must be answered within a certain time frame, given
by the minimum value of T3126 (see GSM 04.08). When the AGCH queue
reaches that limit, the last message would be delivered in time if
there were no other delays involved (which is not the case).

The calculation is based on the ratio of the number RACH slots and
CCCH blocks per time:
  Lmax = (T + 2*S) / R_RACH * R_CCCH
where
  T3126_min = (T + 2*S) / R_RACH
  R_RACH is the RACH slot rate (e.g. RACHs per multiframe)
  R_CCCH is the CCCH block rate (same time base like R_RACH)

The value depends control_channel_desc.ccch_conf and
rach_control.tx_integer (both from SYSINFO_TYPE_3) and should
therefore by called at least each time after one of these is changed.
For this reason, a signal callback is registered under
SS_GLOBAL/S_NEW_SYSINFO which invokes bts_update_agch_max_queue_length().

Sponsored-by: On-Waves ehf
Based-On: "bts: Calculate length of agch queue" by Ivan Kluchnikov
  <kluchnikovi@gmail.com>
2014-03-10 08:54:54 +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
Holger Hans Peter Freyther 5030972316 pcu: Avoid crash when closing the PCU socket
When closing the PCU socket all channels will be closed. In that case
the LAPDm structures might not have been allocated. Mark the channel
as LCHAN_REL_ACT_PCU to avoid going through the RSL code for sending
the message. This avoids a crash when "gprs none" is selected but one
still configures a PDCH and then connects/disconnects the pcu.

 #0  llist_del (entry=0x0) at ../include/osmocom/core/linuxlist.h:119
 #1  msgb_dequeue (queue=0x400bbc58) at msgb.c:102
 #2  0x40110d28 in lapd_dl_flush_tx (dl=0x400bbba0) at lapd_core.c:173
 #3  0x40112cb4 in lapd_dl_reset (dl=0x400bbba0) at lapd_core.c:307
 #4  0x40112d00 in lapd_dl_exit (dl=0x400bbba0) at lapd_core.c:321
 #5  0x40115d80 in lapdm_entity_exit (le=<optimized out>) at lapdm.c:169
 #6  0x40115d9c in lapdm_channel_exit (lc=0x400bbb94) at lapdm.c:180
 #7  0x0001a334 in rsl_tx_rf_rel_ack (lchan=0x400bbb00) at rsl.c:505
 #8  0x0000e908 in lchan_deactivate_sapis (lchan=0x400bbb00) at oml.c:1427
 #9  sapi_queue_exeute (lchan=0x400bbb00) at oml.c:547
 #10 0x0000ead0 in sapi_queue_send (lchan=<optimized out>) at oml.c:571
 #11 queue_sapi_command (lchan=<optimized out>, cmd=<optimized out>) at oml.c:609
 #12 queue_sapi_command (lchan=0x400bbb00, cmd=<optimized out>) at oml.c:601
 #13 0x0000faf0 in enqueue_rel_marker (lchan=0x400bbb00) at oml.c:1440
 #14 lchan_deactivate (lchan=0x400bbb00) at oml.c:1447
 #15 0x0001004c in bts_model_rsl_chan_rel (lchan=<optimized out>) at oml.c:1647
 #16 0x0001de30 in pcu_sock_close (state=0x62788) at pcu_sock.c:654
 #17 0x0001e150 in pcu_sock_read (bfd=0x627a8) at pcu_sock.c:698
 #18 pcu_sock_cb (bfd=0x627a8, flags=1) at pcu_sock.c:755
2014-02-24 13:51:30 +01:00
Holger Hans Peter Freyther fcd4026e7b Revert "bts/vty: Use new vty_install_default() function, adjust prompts"
This reverts commit bbfd21a36c.
2014-02-24 13:03:33 +01:00
Jacob Erlbeck f550a6a574 agch: Log error if BS_AG_BLKS_RES is != 1 in SI3
Currently, the DSP is always configured with u8NbrOfAgch = 1 before
SYSINFO type 3 is received. Thus using a different value for
BS_AG_BLKS_RES may lead to inconsistencies and MS failing to receive
paging messages properly.

This patch adds a warning and error logging and should be reverted
when initialisation is done in proper order.

Sponsored-by: On-Waves ehf
2014-02-24 12:55:38 +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 d242ec2ed9 agch: Keep track of AGCH queue length
This patch adds and updates btsb->agch_queue_length to keep track of
the queue length.

Sponsored-by: On-Waves ehf
2014-02-22 08:44:29 +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
Jacob Erlbeck bbfd21a36c bts/vty: Use new vty_install_default() function, adjust prompts
This patch removes the local 'end' and 'exit' implementations (which
aren't used anyway) and uses the generic ones provided by libosmocore
instead, which are enabled automatically when vty_install_default()
is used.

The prompt strings are modified to match those in
libosmocore/openbsc.

Ticket: OW#952
Sponsored-by: On-Waves ehf
2014-02-22 08:40:48 +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 2755f6e5b4 rsl: Do not allow IPA CRCX on non traffic channels
Use 0x52 as error cause as the nanoBTS is doing the same under the
situation. This has been spotted while testing handover using the
VTY command for handover.
2014-02-19 18:09:35 +01:00
Jacob Erlbeck 572ed461b6 rsl/si: Fix resetting bits in bts->si_valid
Use  'var &= ~(1 << x)' to reset bits instead of 'var &= (1 << x)'.

Sponsored-by: On-Waves ehf
2014-02-19 18:07:43 +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 bc48e26fc9 common/rsl.c: Allow bts_model_rsl_chan_act() to return negative cause
If the channel couldn't be activated, the function can simply return
a negated RSL_ERR_* constant which will then be propagated towards
the BSC in an CHAN_ACT_NACK RSL message.
2014-01-21 23:38:59 +01:00
Harald Welte 8196de46ad common/oml.c: Send OML NACK if bts_model_check_oml() returns negative
This way, bts_model_check_oml() can return a negated NM_NACK_* constant
which will then be sent as cause value in the corresponding
SET_ATTR_NACK back to the BSC.
2014-01-21 23:38:59 +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 19e87d332f measurement: Speculative performance change
Most timeslots do not have eight lchan. Use the subslots_per_lchan
map to reduce the number of iterations. Looking at the ARM assembly
showed that no loop-unrolling was done so this could be a speed up.
2013-12-28 09:37:59 +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 2800b347e9 bts: Fix crash of receiving data during the release process
Release/Free the lapdm resources _after_ the channel has
been fully released. Do not forward data unless the lchan
is in the active state.

Reading this code again, there is probably a memory leak for
everytime the PCU will re-connect to the BTS.

 (gdb) p lchan->state
 $4 = LCHAN_S_REL_REQ
 (gdb) bt
 #0  lapd_dl_flush_hist (dl=0x40454894) at lapd_core.c:164
 #1  0x44873b54 in lapd_rx_u (lctx=0xbe9bd5a8, msg=0x92f90) at lapd_core.c:1040
 #2  lapd_ph_data_ind (msg=0x92f90, lctx=0xbe9bd5a8) at lapd_core.c:1644
 #3  0x44876d50 in l2_ph_data_ind (link_id=<optimized out>, chan_nr=<optimized out>,
     le=<optimized out>, msg=0x92f90) at lapdm.c:637
 #4  lapdm_phsap_up (oph=<optimized out>, le=<optimized out>) at lapdm.c:707
 #5  0x0000c504 in handle_ph_data_ind (l1p_msg=0x97358, data_ind=0x97420, fl1=<optimized out>)
     at l1_if.c:774
 #6  l1if_handle_ind (fl1=<optimized out>, msg=0x97358) at l1_if.c:892
2013-11-27 14:29:50 +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
Holger Hans Peter Freyther a82cc5321e rsl: Rename abis_rsl_sendmsg to avoid symbol clash with libosmo-abis
Nicolas ended up with linker issues due abis_rsl_sendmsg being
defined twice. Rename our version of the function and update the
code.

Patched with:
 @i@
 expression E;
 @@

 - abis_rsl_sendmsg(E)
 + abis_bts_rsl_sendmsg(E)
2013-11-14 10:41:18 +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