aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc/chan_alloc.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-09Fix TCH/F_PDCH: no need to check ts subslots for PDCHNeels Hofmeyr1-0/+7
For TCH/F_PDCH in PDCH mode, directly return the lchan to use, in order to switch it to TCH/F. To check the pchan type in chan_alloc.c, make ts_pchan() public in gsm_data_shared.h. Commit c3f72f63afde926dfc46827d6880055597515fb6 broke TCH/F_PDCH, as a fallout of setting the GSM_PCHAN_PDCH subslots number to 0. This is sane and correct, but the chan_alloc code failed to see a ts as available if it has no subslots. Explanation: _lc_find_trx() checks each timeslot. For normal, static TCH timeslots we determine the number of logical subslots contained and check whether one of them is free. For dynamic TS, we can do the same when in TCH mode, but when in PDCH mode, we already know that it is available for immediate switchover for voice and hence can return it right away. TCH/F_TCH/H_PDCH already has a special check for that. TCH/F_PDCH doesn't, but this worked for TCH/F_PDCH as long as ts_subslots() returned 1 for PDCH: the for-loop at the bottom of _lc_find_trx() checked one subslot, which succeeded on an lchan in PDCH mode, since PDCH lchans are always marked type == NONE and state == NONE. Now we more accurately acknowledge that a PDCH timeslot has zero subslots and that a dynamic timeslot in PDCH mode can always be switched to voice immediately, without checking lchan type or state. So, above mentioned commit set PDCH to zero subslots, and the for-loop to check the (zero) subslots never ran and hence never returned the lchan. This fix adds a special condition for TCH/F_PDCH in PDCH mode, same as TCH/F_TCH/H_PDCH. (Todo: ts_pchan() can probably be used in other places as well to remove some code dup. Leaving that for another patch.) Fixes: OS#1868 Change-Id: I5d555d018a5bcb8d948e54059d32ec4c9b3070d0
2016-12-09cosmetic: chan_alloc: use switch instead of if-cascadeNeels Hofmeyr1-9/+12
Preparing cosmetically for a subsequent commit which will add another pchan kind to be checked, rather use a "switch (pchan) {}". Also reverse one if() branch to "early-exit" style. Change-Id: Ie5eb0fa859c4f225616095dc56d52ce0f2dc8bdc
2016-12-02reinvent connection_for_subscr() and move to libmscNeels Hofmeyr1-33/+0
Implement connection_for_subscr() from a completely different angle: instead of looking up lchans in bts structs, look up the subscriber in the global list of gsm_subscriber_connection. static lchan_find() is thus obsoleted. All callers of connection_for_subscr() live in libmsc, so move to libmsc. The move and edit are done in a single commit since the old and new implementation have nothing in common. Future: osmo-cscn will use this, without bts being present. Remove implementation of connection_for_subscr() from channel_test.c -- it is possible that the abort() in there was intended for a regression test, but actually it seems the implementation was merely added for linking reasons, and the abort() added to guard against the NULL return value: no comment nor the commit log indicate that the abort() is test critical; the addition was the only change in channel_test.c for that commit; at the same time a connection_for_subscr() call was added in libmsc. Change-Id: I5e0ba0ecf1726ebd540800f4e98fdfc937c904ff
2016-10-14fix mistypes, spaces and tabsAlexander Couzens1-1/+1
Change-Id: I651473f638365bbd333c4c80d223cdd023dd2c51
2016-09-28Revert "bts: extend bts_chan_load to allow counting tch only"Neels Hofmeyr1-26/+3
This reverts commit 308cb0719dca3ba8eed1eff2a2124d44f34d9a28. Problems in this commit: openbsc/src/libbsc/chan_alloc.c:523: case GSM_PCHAN_TCH_F_PDCH: This is actually wrong, GSM_PCHAN_TCH_F_PDCH use ts->flags, not ts->dyn below (due to historical reasons and could be unified). 560: if (only_count_tch && !chan_is_tch(ts)) This has exactly one effect: it excludes GSM_PCHAN_TCH_F_PDCH when in PDCH mode, because for all other PDCH (plain PDCH and TCH/F_TCH/H_PDCH in PDCH mode) below ts_subslots() returns 0 and skips the for() loop. I consider this a bug in TCH/F_PDCH, to be fixed in an upcoming commit. I don't see why we need the only_count_tch argument, because this should normally only count TCH, weren't it for the TCH/F_PDCH bug. If dyn TS should be counted differently, we should do this in a different way. Change-Id: I34dbbaf53a800115e3d03bd44028cad675f3b525
2016-09-23bts: extend bts_chan_load to allow counting tch onlyAlexander Couzens1-3/+26
Change-Id: I86f1d502649747b6b9aefcb39081b14110e8f494
2016-08-27move ts_sublots() to gsm_data_shared.c, it will be used by osmo-btsNeels Hofmeyr1-25/+0
Change-Id: I8ba06d7dd6e0ceab3d8d18bb565354d6ed461f7e
2016-08-27chan_alloc.c: use ts_subslots() instead of subslots_per_pchan[]Neels Hofmeyr1-2/+2
The array will move to gsm_data_shared.c; to prepare, use the function instead. Change-Id: Icbea7dbd78abf6144e5291f531a97f96507d8cbf
2016-08-27dyn TS: bts_chan_load: use correct nr of subslots for dyn tsNeels Hofmeyr1-1/+3
For TCH/F_TCH/H_PDCH dynamic timeslots, the ts->pchan does not lead to a meaningful value from the subslots_per_pchan[] array. Use the ts_subslots() function instead, which checks for dyn pchan. Change-Id: I659acebca82dfb3e305433471be64e9d27439af8
2016-07-28dyn TS: OS#1778 workaround: disable TCH/F on dyn TS for nitbNeels Hofmeyr1-1/+2
To avoid two phones picking mismatching TCH pchans, never pick TCH/F on dynamic TS in osmo-nitb. Add gsm_network flag dyn_ts_allow_tch_f, set to true by default in gsm_network_init(). Set this flag to false in osmo-nitb's main(). See http://osmocom.org/issues/1778 Reasoning about ways to solve this: * a compile time switch doesn't work because libbsc is first compiled and then linked to both osmo-nitb and osmo-bsc. * we could test net->bsc_api == msc_bsc_api(), but I have the so-called MSC split waiting on branch sysmocom/cscn, which will result in msc_bsc_api() not being linked in the osmo-bsc binary. * have a function am_i_nitb() with different implementations in osmo-nitb and osmo-bsc, but then we'd need to add implementations to all tests and other binaries linking lchan_alloc(). * have a flag in struct bsc_api, but so far there are only function pointers there. Having a "global" flag in gsm_network allows to add a VTY command in case we decide to keep this feature (#1781), has no linking implications and is nicely explicit. Tested that osmo-bsc still picks TCH/F on dyn TS indirectly, since I have no standalone MSC available: when compiling osmo-nitb with the line that sets dyn_ts_allow_tch_f = false commented out, TCH/F is picked as described in OS#1778; and by printf-verifying that dyn_ts_allow_tch_f == true in osmo-bsc main(), only osmo-nitb should have TCH/F disabled. Related: OS#1778, OS#1781 Change-Id: If7e4797a72815fc6e2bbef27756ea5df69f4bde7
2016-07-28dyn TS: implement pchan switchover logicNeels Hofmeyr1-0/+9
In struct gsm_lchan, add dyn.rqd_ref and dyn.rqd_ta. These save the Channel Requested details across the PDCH deactivation dance. abis_rsl.c: add static functions: * dyn_ts_switchover*() for the various stages of switchover between pchans. * pchan_for_lchant() to derive the desired pchan from the lchan type that was set during lchan_alloc(). * rsl_chan_activate_lchan_as_pdch() to compose the simpler RSL CHAN ACT message without introducing numerous special cases to the normal RSL CHAN ACT code. In rsl_chan_activate_lchan(), detect and initiate required pchan switchovers if requested pchan on a dyn TS differs. In rsl_rx_rf_chan_rel_ack(), initiate or continue pchan switchovers after a channel was released. In rsl_rx_chan_act_ack(), notice that a switchover is complete. In chan_alloc.c, add ts_subslots(): abis_rsl.c will need to know the number of subslots per pchan, to verify that all lchans are free before dyn TS switchover. The subslots_per_pchan[] array is static to lchan_alloc.c, and since we need a non-trivial check for dyn TS anyway, add public ts_subslots() to lchan_alloc.c, which also checks the current dyn pchan type. Change-Id: I5c6bce13092a10204113d84678c587c65e35e4fd
2016-07-28dyn TS: enhance channel allocator for dynamic TSNeels Hofmeyr1-7/+120
Change _lc_find_bts() to _lc_dyn_find_bts() with added dyn_as_pchan arg to pass exactly as which pchan we'd like to allocate on a dynamic TS. Add _lc_find_bts() as wrapper so non-dynamic-TS callers remain unchanged. Also add dyn_as_pchan arg to _lc_find_trx() (not renaming to dyn and wrapping because there is only one caller). Implement dynamic allocator logic in _lc_find_trx() and lchan_alloc(). A returned dynamic channel still needs to be switched to the proper mode, which will follow in another commit. Replace a fixme comment with a normal comment in subslots_per_pchan[], because handling of dynamic TS is now defined. Change-Id: I18da7679300c43220d9baa6a304e8df74d366249
2016-07-25log lchan_alloc() resultNeels Hofmeyr1-0/+8
It is particularly interesting to see whether a given lchan type is allocated on a dynamic timeslot. Change-Id: I8a0bca6d9cd583a0988e5ee8f4e6f74f218f4185
2016-07-25comments: clarify some dynamic TS commentsNeels Hofmeyr1-4/+7
A new type of dynamic channel will be introduced soon, so prepare some comments to name the dynamic TS kind more specifically. Change-Id: I51fa8c2ebba507299e55a5cb7e67e48a6c8471f7
2016-06-16dyn PDCH: set lchan->state after PDCH DEACT / before PDCH ACTNeels Hofmeyr1-0/+7
Do the PDCH DE/ACT before we set the lchan->state to De-/Activation Requested. It makes more sense semantically to change PDCH mode while the lchan is still in NONE status. Thus slightly move some invocations: PDCH ACT: Free the lchan before PDCH activation. Hence remove the lchan_free() call from the rsl_rx_pdch_act_ack() code path; it used to do the PDCH activation first and call lchan_free() in the callback. PDCH DEACT: Set the (TCH) Activation Requested state only within rsl_chan_activate_lchan(), after the PDCH deact is complete. Channel allocator: don't pick channels that have a PDCH PENDING flag set, to avoid using channels that are still in PDCH switchover (despite their state being NONE). The lchan_may_change_pdch() sanity checks are becoming a lot simpler. Change-Id: I4206dd4808e21c3e59393ea7f5ab4f438afff066
2016-06-12dyn PDCH: allow allocating TCH/F on TCH/F_PDCH slotsNeels Hofmeyr1-9/+29
Remove check for dyn PDCH in _lc_find_trx(), instead call _lc_find_trx() via _lc_find_bts() several times, so that pure TCH/F is preferred to TCH/F_PDCH. Add this logic next to the other channel match decisions in chan_alloc(). BTW, the removed check in _lc_find_trx() whether PDCH is active is not necessary, as described in the added comment for lchan_alloc(). Original patch idea by jolly, but split in two and implemented differently by nhofmeyr. Change-Id: I0c728b922656be03588b775638b610a93f8187d5
2016-06-12dyn PDCH: Fix free slot search for chan_alloc_reverse == trueAndreas Eversberg1-2/+14
For chan_alloc_reverse, _lc_find_trx() should return the last free slot instead of the first. Original patch by jolly, but split in two by nhofmeyr. Change-Id: Iff980242b9b5cb39345aaad0350ee368537677cd
2016-06-07lchan_alloc(): on alloc failure, report original typeNeels Hofmeyr1-4/+8
In lchan_alloc(), there are several decisions to fall back to another type of channel, followed by setting the channel type to the fall back type. So far, this was set regardless of allocation success or failure. If such fall back type is not available, do not modify the local type variable and thus report an S_CHALLOC_ALLOC_FAIL on the type originally requested (report is at the end of lchan_alloc()). Change-Id: Ie3d4cb74f91db0b8c4f5e595a963099de339ad1a
2015-09-22Add full AMR multirate IE support with VTY config for MS and BTS sideAndreas Eversberg1-2/+2
2015-01-02lchan: Remember why a channel is broken using static stringsHolger Hans Peter Freyther1-0/+2
Remember why a channel is being marked as broken. So we can maybe understand what happend.
2015-01-01chan_alloc: remove ts_alloc() and ts_free()Harald Welte1-106/+1
The idea of ts_alloc()/ts_free() dates back to the very early days of OpenBSC, where we didn't yet have a fixed PCHAN type assigned for every lchan in a BTS. However, ever since, PCHAN types (channel combinations) are configured by OML in a certain way, and we only allocate LCHANs inside PCHANs of a matching type. There should be no PCHANs with type GSM_PCHAN_NONE, unless those that you don't want to use for administraive reasons or the like.
2015-01-01chan_alloc: Fix missing break statementHarald Welte1-0/+1
Fixes: Coverity CID 1261354
2015-01-01chan_alloc.c: Don't remove SDCCH/8 without CBCHHarald Welte1-0/+1
In commit 30f1f376383df3ae8d85e96542bf14d174c25d89 we wanted to add support for SDCCH/8+CBCH, not replace the existing SDCCH/8 with the new CBCH-enabled configuration.
2014-12-30Add basic support for CBCH / SMS-CB (Cell Brroadcast)Harald Welte1-4/+19
We can now configure the pyisical channel types for CBCH either in the CCCH+SDCCH4 or in the SDCCH8 chanel combination. Depending on whether a CBCH exists on the BTS, we also generate the SI4 with matching CBCH channel description to notify the phones of the existance of the CBCH. There is now a VTY command how a SMS-CB message can be sent to a given BTS. We do not yet have any logic at all for actual scheduling of multiple CBCH RSL messages towards one or multiple BTSs yet, though.
2014-12-05msc: Add and use gsm_subscriber_groupJacob Erlbeck1-1/+1
Currently every subcriber object directly refers to the gsm_network which contains a flag shared by every related subscriber (keep_subscr). This adds a dependency on gsm_network even if only the function defined in gsm_subscriber_base.c are used. This patch adds a new struct gsm_subscriber_group which contains the keep_subscr flag and a back reference to the network object. The latter is not dereferenced in gsm_subscriber_base.c, so it can safely be set to NULL when only that part of the gsm_subscriber API is being used. It also changes that API to use gsm_subscriber_group instead of gsm_network parameters. Since there are some places where a pointer to the gsm_network is needed but where only a gsm_subscriber is available, a 'net' back pointer is added to the group struct, too. Nevertheless subscr group and network could be separated completely, but this is not the topic of this commit. Sponsored-by: On-Waves ehf
2014-05-19chan_alloc: Fall-back to TCH/H, if we cannot find a TCH/FHarald Welte1-0/+5
I'm not entirely sure if this is the best approach. However, there are phones that send a RACH request for TCH/F on MO calls, even though they actually do support TCH/H channels.
2012-12-29libbsc: With the new SAPI states we don't need sacch_deact anymoreDaniel Willmann1-1/+0
2012-12-26gsm: Do not attempt to release SAPI=0 if it was never allocatedHolger Hans Peter Freyther1-0/+2
In case of handover (but probably on RACH) we would send a RLL for SAPI=0 even if this SAPI was never established. After we have released all SAPI>0 locally check that SAPI=0 is established and if not release the rf channel directly.
2012-12-23lchan: Introduce T3109 handling for the release procedureHolger Hans Peter Freyther1-3/+9
T3109 is started when the SACCH is deactivated. It is stopped when the phones sends the DISC/UA/UM on LAPDm for the main signalling link. In case of timeout the abnormal release procedure will be initiated. Make sure to not issue the SACCH Deactivate twice to avoid confusing the equipment. This is still not fully spec compliant. In case of a timeout the abnormal release handling will be started which involves starting T3111+2. The error handling should be split out of the rf channel release method, e.g. lchan_release should be called and check if the channel release was already initiated.
2012-12-23lchan: Release the lchan more quickly, align with GSM 04.08Holger Hans Peter Freyther1-47/+14
* Release all channels with SAPI > 0 with the "local end release" (as of NOTE 1 of GSM 04.08). * No need to wait for all SAPIs to be torn down and the normal REL_IND/REL_CONF will call rsl_handle_release and the channel should be released. * Update the documentation
2012-12-23lchan: Release all higher sapis on the local end.Holger Hans Peter Freyther1-1/+1
According to GSM 04.08 3.4.13.1.1 RR connection release in NOTE 1 one should release all non main signaling links using the local end link release.
2012-12-23rsl: Rename the reason to release_mode and use the enum valueHolger Hans Peter Freyther1-2/+2
The API with 0 and 1 as legal values is hard to understand. Use the recently introduced enum values instead.
2012-04-18lchan: Fix the name of the SACCH in the variable namesHolger Hans Peter Freyther1-4/+4
Call the channel by the right name.
2012-01-17lchan: Close a possible still open RTP SocketHolger Hans Peter Freyther1-0/+12
In case of a reset (loss of the BTS) close down all remaining RTP Proxy sockets. In case of a lchan_free shout if the rtp proxy is still open. I would prefer if the proxy code sits inside the gsm subscriber connection.
2012-01-15lchan: Rename release_reason to release_modeHolger Hans Peter Freyther1-5/+5
Use the name of GSM 08.58 for the release mode.
2012-01-15Revert "libbsc: Log if a channel is freed with lchan->state != LCHAN_S_NONE"Holger Hans Peter Freyther1-4/+0
In case of a failed channel we still want the channel to not be re-allocated right away but keep it closed/unused for (T3109 + T311). rsl_rx_rf_chan_rel_ack has a check to not set the channel to S_NONE in case the channel is in the error state. Add the camp Harald added a timer to set the channel back to the none state in case the RF Channel Release is not acked. This reverts commit fc462dd59ee4772f06c9f2477b36b3f166a8e74b.
2011-08-11libbsc: Log if a channel is freed with lchan->state != LCHAN_S_NONEDaniel Willmann1-0/+4
I'm not sure if that is an abnormal condition or not, but it seems that lchan state and type have to be none for the lchan to be considered idle.
2011-06-03gsm_data_shared: introduce 'struct gsm_abis_mo'Harald Welte1-6/+6
... as a common wrapper around nm_attr and nm_state
2011-05-06src: use namespace prefix osmo_signal*Pablo Neira Ayuso1-3/+3
Summary of changes: s/signal_cbfn/osmo_signal_cbfn/g s/register_signal_handler/osmo_signal_register_handler/g s/unregister_signal_handler/osmo_signal_unregister_handler/g s/dispatch_signal/osmo_signal_dispatch/g
2011-05-06src: use namespace prefix osmo_timer* for timer functionsPablo Neira Ayuso1-4/+4
Summary of changes: s/struct timer_list/struct osmo_timer_list/g s/bsc_add_timer/osmo_timer_add/g s/bsc_schedule_timer/osmo_timer_schedule/g s/bsc_del_timer/osmo_timer_del/g s/bsc_timer_pending/osmo_timer_pending/g s/bsc_nearest_timer/osmo_timers_nearest/g s/bsc_prepare_timers/osmo_timers_prepare/g s/bsc_update_timers/osmo_timers_update/g s/bsc_timer_check/osmo_timers_check/g
2011-04-18misc: Move from u_int to uint types of stdint.hHolger Hans Peter Freyther1-3/+3
This was done with sed on the files.
2011-03-23src: use new library libosmogsm and new path to headers in libosmocorePablo Neira Ayuso1-1/+1
libosmogsm is a new library that is distributed in the libosmocore. Now, openbsc depends on it. This patch gets openbsc with this change. This patch also rewrites all include path to the new osmocom/[gsm|core] Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-03-04prefix sub-directories containing libraries with 'lib'Harald Welte1-0/+507
... and make sure tests work again after restructuring