2010-03-29 06:47:44 +00:00
|
|
|
/* GSM Radio Signalling Link messages on the A-bis interface
|
2008-12-23 20:25:15 +00:00
|
|
|
* 3GPP TS 08.58 version 8.6.0 Release 1999 / ETSI TS 100 596 V8.6.0 */
|
|
|
|
|
2010-03-04 09:33:10 +00:00
|
|
|
/* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org>
|
2011-12-27 21:24:17 +00:00
|
|
|
* (C) 2012 by Holger Hans Peter Freyther
|
2008-12-25 23:28:35 +00:00
|
|
|
*
|
2008-12-23 20:25:15 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-12-23 20:25:15 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2008-12-23 20:25:15 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-12-23 20:25:15 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2008-12-25 23:28:35 +00:00
|
|
|
#include <stdlib.h>
|
2008-12-23 20:25:15 +00:00
|
|
|
#include <errno.h>
|
2009-02-16 21:12:08 +00:00
|
|
|
#include <netinet/in.h>
|
2009-02-17 14:35:45 +00:00
|
|
|
#include <arpa/inet.h>
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/gsm_04_08.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/gsm/gsm_utils.h>
|
2008-12-25 23:28:35 +00:00
|
|
|
#include <openbsc/abis_rsl.h>
|
|
|
|
#include <openbsc/chan_alloc.h>
|
2009-08-09 11:47:35 +00:00
|
|
|
#include <openbsc/bsc_rll.h>
|
2008-12-25 23:28:35 +00:00
|
|
|
#include <openbsc/debug.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/gsm/tlv.h>
|
2016-05-11 10:45:13 +00:00
|
|
|
#include <osmocom/gsm/protocol/gsm_04_08.h>
|
|
|
|
#include <osmocom/gsm/protocol/gsm_08_58.h>
|
2009-02-10 00:06:19 +00:00
|
|
|
#include <openbsc/paging.h>
|
2009-02-17 14:35:45 +00:00
|
|
|
#include <openbsc/signal.h>
|
2009-11-29 18:07:28 +00:00
|
|
|
#include <openbsc/meas_rep.h>
|
2009-12-20 14:42:44 +00:00
|
|
|
#include <openbsc/rtp_proxy.h>
|
src: port openBSC over libosmo-abis
This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.
The main changes are:
- The directory libabis/ has been removed as it now lives in
libosmo-abis.
- new configuration file format for nanoBTS and HSL femto, we
need to define the virtual e1_line and attach it to the OML
link.
- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
BS11 and rbs2000) now use the new libosmo-abis framework.
- use r232 input driver available in libosmo-abis for bs11_config.
- use ipa_msg_recv instead of old ipaccess_read_msg function.
- delete definition of gsm_e1_subslot and input_signal_data.
These structures now lives in libosmo-abis.
Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.
This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:
- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node
This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
2011-08-17 20:44:07 +00:00
|
|
|
#include <osmocom/abis/e1_input.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/gsm/rsl.h>
|
|
|
|
#include <osmocom/core/talloc.h>
|
2010-06-22 04:11:59 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
#define RSL_ALLOC_SIZE 1024
|
|
|
|
#define RSL_ALLOC_HEADROOM 128
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2011-12-28 15:21:05 +00:00
|
|
|
enum sacch_deact {
|
|
|
|
SACCH_NONE,
|
|
|
|
SACCH_DEACTIVATE,
|
|
|
|
};
|
|
|
|
|
2010-06-22 04:11:59 +00:00
|
|
|
static int rsl_send_imm_assignment(struct gsm_lchan *lchan);
|
2014-04-06 10:21:05 +00:00
|
|
|
static void error_timeout_cb(void *data);
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
static int dyn_ts_switchover_continue(struct gsm_bts_trx_ts *ts);
|
|
|
|
static int dyn_ts_switchover_failed(struct gsm_bts_trx_ts *ts, int rc);
|
2016-07-23 17:45:15 +00:00
|
|
|
static void dyn_ts_switchover_complete(struct gsm_lchan *lchan);
|
2010-06-22 04:11:59 +00:00
|
|
|
|
2010-12-27 12:28:20 +00:00
|
|
|
static void send_lchan_signal(int sig_no, struct gsm_lchan *lchan,
|
|
|
|
struct gsm_meas_rep *resp)
|
|
|
|
{
|
|
|
|
struct lchan_signal_data sig;
|
|
|
|
sig.lchan = lchan;
|
|
|
|
sig.mr = resp;
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_dispatch(SS_LCHAN, sig_no, &sig);
|
2010-12-27 12:28:20 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 18:09:58 +00:00
|
|
|
static void do_lchan_free(struct gsm_lchan *lchan)
|
|
|
|
{
|
2014-04-06 10:21:05 +00:00
|
|
|
/* We start the error timer to make the channel available again */
|
|
|
|
if (lchan->state == LCHAN_S_REL_ERR) {
|
|
|
|
lchan->error_timer.data = lchan;
|
|
|
|
lchan->error_timer.cb = error_timeout_cb;
|
|
|
|
osmo_timer_schedule(&lchan->error_timer,
|
|
|
|
lchan->ts->trx->bts->network->T3111 + 2, 0);
|
|
|
|
} else {
|
2012-12-06 18:09:58 +00:00
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_NONE);
|
2014-04-06 10:21:05 +00:00
|
|
|
}
|
2012-12-06 18:09:58 +00:00
|
|
|
lchan_free(lchan);
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static uint8_t mdisc_by_msgtype(uint8_t msg_type)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
/* mask off the transparent bit ? */
|
|
|
|
msg_type &= 0xfe;
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
if ((msg_type & 0xf0) == 0x00)
|
2008-12-23 20:25:15 +00:00
|
|
|
return ABIS_RSL_MDISC_RLL;
|
2008-12-25 23:28:35 +00:00
|
|
|
if ((msg_type & 0xf0) == 0x10) {
|
2008-12-23 20:25:15 +00:00
|
|
|
if (msg_type >= 0x19 && msg_type <= 0x22)
|
|
|
|
return ABIS_RSL_MDISC_TRX;
|
|
|
|
else
|
|
|
|
return ABIS_RSL_MDISC_COM_CHAN;
|
|
|
|
}
|
2008-12-27 19:46:06 +00:00
|
|
|
if ((msg_type & 0xe0) == 0x20)
|
2008-12-23 20:25:15 +00:00
|
|
|
return ABIS_RSL_MDISC_DED_CHAN;
|
|
|
|
|
|
|
|
return ABIS_RSL_MDISC_LOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void init_dchan_hdr(struct abis_rsl_dchan_hdr *dh,
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t msg_type)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
dh->c.msg_discr = mdisc_by_msgtype(msg_type);
|
|
|
|
dh->c.msg_type = msg_type;
|
|
|
|
dh->ie_chan = RSL_IE_CHAN_NR;
|
|
|
|
}
|
|
|
|
|
2016-07-23 15:38:22 +00:00
|
|
|
/* call rsl_lchan_lookup and set the log context */
|
2016-08-22 23:22:58 +00:00
|
|
|
static struct gsm_lchan *lchan_lookup(struct gsm_bts_trx *trx, uint8_t chan_nr,
|
|
|
|
const char *log_name)
|
2008-12-25 23:28:35 +00:00
|
|
|
{
|
2016-07-23 15:38:22 +00:00
|
|
|
int rc;
|
|
|
|
struct gsm_lchan *lchan = rsl_lchan_lookup(trx, chan_nr, &rc);
|
|
|
|
|
|
|
|
if (!lchan) {
|
2016-08-22 23:22:58 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%sunknown chan_nr=0x%02x\n",
|
|
|
|
log_name, chan_nr);
|
2008-12-25 23:28:35 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-07-23 15:38:22 +00:00
|
|
|
if (rc < 0)
|
2016-08-22 23:22:58 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s %smismatching chan_nr=0x%02x\n",
|
|
|
|
gsm_ts_and_pchan_name(lchan->ts), log_name, chan_nr);
|
2016-07-23 15:38:22 +00:00
|
|
|
|
2010-03-26 13:28:59 +00:00
|
|
|
log_set_context(BSC_CTX_LCHAN, lchan);
|
2010-06-28 07:47:12 +00:00
|
|
|
if (lchan->conn)
|
|
|
|
log_set_context(BSC_CTX_SUBSCR, lchan->conn->subscr);
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return lchan;
|
|
|
|
}
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* As per TS 03.03 Section 2.2, the IMSI has 'not more than 15 digits' */
|
2011-04-18 15:04:00 +00:00
|
|
|
uint64_t str_to_imsi(const char *imsi_str)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
2011-04-18 15:04:00 +00:00
|
|
|
uint64_t ret;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
ret = strtoull(imsi_str, NULL, 10);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
static struct msgb *rsl_msgb_alloc(void)
|
|
|
|
{
|
2009-06-26 17:39:35 +00:00
|
|
|
return msgb_alloc_headroom(RSL_ALLOC_SIZE, RSL_ALLOC_HEADROOM,
|
|
|
|
"RSL");
|
2008-12-25 23:28:35 +00:00
|
|
|
}
|
|
|
|
|
2009-02-15 14:36:38 +00:00
|
|
|
#define MACBLOCK_SIZE 23
|
2011-04-18 15:04:00 +00:00
|
|
|
static void pad_macblock(uint8_t *out, const uint8_t *in, int len)
|
2009-02-15 14:36:38 +00:00
|
|
|
{
|
|
|
|
memcpy(out, in, len);
|
|
|
|
|
|
|
|
if (len < MACBLOCK_SIZE)
|
|
|
|
memset(out+len, 0x2b, MACBLOCK_SIZE-len);
|
|
|
|
}
|
|
|
|
|
2009-08-30 06:37:11 +00:00
|
|
|
/* Chapter 9.3.7: Encryption Information */
|
2011-04-18 15:04:00 +00:00
|
|
|
static int build_encr_info(uint8_t *out, struct gsm_lchan *lchan)
|
2009-08-30 06:37:11 +00:00
|
|
|
{
|
|
|
|
*out++ = lchan->encr.alg_id & 0xff;
|
|
|
|
if (lchan->encr.key_len)
|
|
|
|
memcpy(out, lchan->encr.key, lchan->encr.key_len);
|
|
|
|
return lchan->encr.key_len + 1;
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static void print_rsl_cause(int lvl, const uint8_t *cause_v, uint8_t cause_len)
|
2009-07-28 15:58:09 +00:00
|
|
|
{
|
|
|
|
int i;
|
2009-02-23 00:02:59 +00:00
|
|
|
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGPC(DRSL, lvl, "CAUSE=0x%02x(%s) ",
|
2009-07-28 15:58:09 +00:00
|
|
|
cause_v[0], rsl_err_name(cause_v[0]));
|
2010-03-29 06:47:44 +00:00
|
|
|
for (i = 1; i < cause_len-1; i++)
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGPC(DRSL, lvl, "%02x ", cause_v[i]);
|
2009-02-23 00:02:59 +00:00
|
|
|
}
|
|
|
|
|
2011-08-10 21:26:33 +00:00
|
|
|
static void lchan_act_tmr_cb(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
|
2014-12-28 11:08:28 +00:00
|
|
|
rsl_lchan_mark_broken(lchan, "activation timeout");
|
2011-08-11 02:44:12 +00:00
|
|
|
lchan_free(lchan);
|
2011-08-10 21:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void lchan_deact_tmr_cb(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
|
2014-12-28 11:08:28 +00:00
|
|
|
rsl_lchan_mark_broken(lchan, "de-activation timeout");
|
2013-05-01 16:44:04 +00:00
|
|
|
lchan_free(lchan);
|
2011-08-10 21:26:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* Send a BCCH_INFO message as per Chapter 8.5.1 */
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_bcch_info(struct gsm_bts_trx *trx, uint8_t type,
|
|
|
|
const uint8_t *data, int len)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2008-12-25 23:28:35 +00:00
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof*dh);
|
|
|
|
init_dchan_hdr(dh, RSL_MT_BCCH_INFO);
|
|
|
|
dh->chan_nr = RSL_CHAN_BCCH;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
|
|
|
|
msgb_tlv_put(msg, RSL_IE_FULL_BCCH_INFO, len, data);
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = trx->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_sacch_filling(struct gsm_bts_trx *trx, uint8_t type,
|
|
|
|
const uint8_t *data, int len)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_common_hdr *ch;
|
2008-12-25 23:28:35 +00:00
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
ch = (struct abis_rsl_common_hdr *) msgb_put(msg, sizeof(*ch));
|
|
|
|
ch->msg_discr = ABIS_RSL_MDISC_TRX;
|
|
|
|
ch->msg_type = RSL_MT_SACCH_FILL;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
|
2008-12-26 20:25:35 +00:00
|
|
|
msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = trx->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_sacch_info_modify(struct gsm_lchan *lchan, uint8_t type,
|
|
|
|
const uint8_t *data, int len)
|
2011-01-13 22:16:03 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
2011-06-25 08:02:33 +00:00
|
|
|
uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
|
2011-01-13 22:16:03 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_SACCH_INFO_MODIFY);
|
|
|
|
dh->chan_nr = chan_nr;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_SYSINFO_TYPE, type);
|
|
|
|
msgb_tl16v_put(msg, RSL_IE_L3_INFO, len, data);
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2011-01-13 22:16:03 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-06-20 16:15:19 +00:00
|
|
|
int rsl_chan_bs_power_ctrl(struct gsm_lchan *lchan, unsigned int fpc, int db)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2009-06-27 01:09:08 +00:00
|
|
|
struct msgb *msg;
|
2011-06-25 08:02:33 +00:00
|
|
|
uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-06-20 16:15:19 +00:00
|
|
|
|
|
|
|
db = abs(db);
|
|
|
|
if (db > 30)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2009-06-27 01:09:08 +00:00
|
|
|
msg = rsl_msgb_alloc();
|
|
|
|
|
2009-06-20 16:15:19 +00:00
|
|
|
lchan->bs_power = db/2;
|
|
|
|
if (fpc)
|
|
|
|
lchan->bs_power |= 0x10;
|
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_BS_POWER_CONTROL);
|
|
|
|
dh->chan_nr = chan_nr;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_BS_POWER, lchan->bs_power);
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-06-20 16:15:19 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rsl_chan_ms_power_ctrl(struct gsm_lchan *lchan, unsigned int fpc, int dbm)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2009-06-27 01:09:08 +00:00
|
|
|
struct msgb *msg;
|
2011-06-25 08:02:33 +00:00
|
|
|
uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-06-20 16:15:19 +00:00
|
|
|
int ctl_lvl;
|
|
|
|
|
2009-08-09 12:45:18 +00:00
|
|
|
ctl_lvl = ms_pwr_ctl_lvl(lchan->ts->trx->bts->band, dbm);
|
2009-06-20 16:15:19 +00:00
|
|
|
if (ctl_lvl < 0)
|
|
|
|
return ctl_lvl;
|
|
|
|
|
2009-06-27 01:09:08 +00:00
|
|
|
msg = rsl_msgb_alloc();
|
|
|
|
|
2009-06-20 16:15:19 +00:00
|
|
|
lchan->ms_power = ctl_lvl;
|
|
|
|
|
|
|
|
if (fpc)
|
|
|
|
lchan->ms_power |= 0x20;
|
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_MS_POWER_CONTROL);
|
|
|
|
dh->chan_nr = chan_nr;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_MS_POWER, lchan->ms_power);
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-06-20 16:15:19 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-07-29 13:41:29 +00:00
|
|
|
static int channel_mode_from_lchan(struct rsl_ie_chan_mode *cm,
|
|
|
|
struct gsm_lchan *lchan)
|
|
|
|
{
|
2013-03-09 16:50:10 +00:00
|
|
|
memset(cm, 0, sizeof(*cm));
|
2009-07-29 13:41:29 +00:00
|
|
|
|
|
|
|
/* FIXME: what to do with data calls ? */
|
2016-05-11 10:45:13 +00:00
|
|
|
cm->dtx_dtu = 0;
|
|
|
|
if (lchan->ts->trx->bts->dtxu != GSM48_DTX_SHALL_NOT_BE_USED)
|
|
|
|
cm->dtx_dtu |= RSL_CMOD_DTXu;
|
|
|
|
if (lchan->ts->trx->bts->dtxd)
|
|
|
|
cm->dtx_dtu |= RSL_CMOD_DTXd;
|
2009-07-29 13:41:29 +00:00
|
|
|
|
|
|
|
/* set TCH Speech/Data */
|
|
|
|
cm->spd_ind = lchan->rsl_cmode;
|
|
|
|
|
2009-11-27 07:55:16 +00:00
|
|
|
if (lchan->rsl_cmode == RSL_CMOD_SPD_SIGN &&
|
|
|
|
lchan->tch_mode != GSM48_CMODE_SIGN)
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "unsupported: rsl_mode == signalling, "
|
2009-11-27 07:55:16 +00:00
|
|
|
"but tch_mode != signalling\n");
|
|
|
|
|
2009-07-29 13:41:29 +00:00
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_SDCCH:
|
|
|
|
cm->chan_rt = RSL_CMOD_CRT_SDCCH;
|
|
|
|
break;
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
cm->chan_rt = RSL_CMOD_CRT_TCH_Bm;
|
|
|
|
break;
|
|
|
|
case GSM_LCHAN_TCH_H:
|
|
|
|
cm->chan_rt = RSL_CMOD_CRT_TCH_Lm;
|
|
|
|
break;
|
|
|
|
case GSM_LCHAN_NONE:
|
|
|
|
case GSM_LCHAN_UNKNOWN:
|
|
|
|
default:
|
2016-07-18 21:47:24 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"unsupported activation lchan->type %u %s\n",
|
|
|
|
lchan->type, gsm_lchant_name(lchan->type));
|
2009-07-29 13:41:29 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (lchan->tch_mode) {
|
|
|
|
case GSM48_CMODE_SIGN:
|
|
|
|
cm->chan_rate = 0;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_SPEECH_V1:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_GSM1;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_SPEECH_EFR:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_GSM2;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_SPEECH_AMR:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_GSM3;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_DATA_14k5:
|
|
|
|
case GSM48_CMODE_DATA_12k0:
|
|
|
|
case GSM48_CMODE_DATA_6k0:
|
2012-08-24 13:33:56 +00:00
|
|
|
switch (lchan->csd_mode) {
|
|
|
|
case LCHAN_CSD_M_NT:
|
|
|
|
/* non-transparent CSD with RLP */
|
|
|
|
switch (lchan->tch_mode) {
|
|
|
|
case GSM48_CMODE_DATA_14k5:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_NT_14k5;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_DATA_12k0:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_NT_12k0;
|
|
|
|
break;
|
|
|
|
case GSM48_CMODE_DATA_6k0:
|
|
|
|
cm->chan_rate = RSL_CMOD_SP_NT_6k0;
|
|
|
|
break;
|
|
|
|
default:
|
2016-07-18 21:47:24 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"unsupported lchan->tch_mode %u\n",
|
|
|
|
lchan->tch_mode);
|
2012-08-24 13:33:56 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* transparent data services below */
|
|
|
|
case LCHAN_CSD_M_T_1200_75:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_1200_75;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_600:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_600;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_1200:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_1200;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_2400:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_2400;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_9600:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_9600;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_14400:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_14400;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_29000:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_29000;
|
|
|
|
break;
|
|
|
|
case LCHAN_CSD_M_T_32000:
|
|
|
|
cm->chan_rate = RSL_CMOD_CSD_T_32000;
|
|
|
|
break;
|
|
|
|
default:
|
2016-07-18 21:47:24 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"unsupported lchan->csd_mode %u\n",
|
|
|
|
lchan->csd_mode);
|
2012-08-24 13:33:56 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-07-29 13:41:29 +00:00
|
|
|
default:
|
2016-07-18 21:47:24 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"unsupported lchan->tch_mode %u\n",
|
|
|
|
lchan->tch_mode);
|
2009-07-29 13:41:29 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-08-20 17:32:46 +00:00
|
|
|
static void mr_config_for_bts(struct gsm_lchan *lchan, struct msgb *msg)
|
|
|
|
{
|
|
|
|
if (lchan->tch_mode == GSM48_CMODE_SPEECH_AMR)
|
|
|
|
msgb_tlv_put(msg, RSL_IE_MR_CONFIG, lchan->mr_bts_lv[0],
|
|
|
|
lchan->mr_bts_lv + 1);
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
static enum gsm_phys_chan_config pchan_for_lchant(enum gsm_chan_t type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return GSM_PCHAN_TCH_F;
|
|
|
|
case GSM_LCHAN_TCH_H:
|
|
|
|
return GSM_PCHAN_TCH_H;
|
|
|
|
case GSM_LCHAN_NONE:
|
|
|
|
case GSM_LCHAN_PDTCH:
|
|
|
|
/* TODO: so far lchan->type is NONE in PDCH mode. PDTCH is only
|
|
|
|
* used in osmo-bts. Maybe set PDTCH and drop the NONE case
|
|
|
|
* here. */
|
|
|
|
return GSM_PCHAN_PDCH;
|
|
|
|
default:
|
|
|
|
return GSM_PCHAN_UNKNOWN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Tx simplified channel activation message for non-standard PDCH type. */
|
|
|
|
static int rsl_chan_activate_lchan_as_pdch(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct msgb *msg;
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
|
|
|
|
/* This might be called after release of the second lchan of a TCH/H,
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
* but PDCH activation must always happen on the first lchan. Make sure
|
|
|
|
* the calling code passes the correct lchan. */
|
|
|
|
OSMO_ASSERT(lchan == lchan->ts->lchan);
|
2016-07-23 17:45:15 +00:00
|
|
|
|
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_ACT_REQ);
|
|
|
|
|
|
|
|
msg = rsl_msgb_alloc();
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_CHAN_ACTIV);
|
|
|
|
dh->chan_nr = gsm_lchan_as_pchan2chan_nr(lchan, GSM_PCHAN_PDCH);
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_ACT_TYPE, RSL_ACT_OSMO_PDCH);
|
|
|
|
|
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* Chapter 8.4.1 */
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_chan_activate_lchan(struct gsm_lchan *lchan, uint8_t act_type,
|
2013-10-11 10:55:35 +00:00
|
|
|
uint8_t ho_ref)
|
2008-12-27 01:55:51 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2009-06-27 01:09:08 +00:00
|
|
|
struct msgb *msg;
|
2009-07-29 13:41:29 +00:00
|
|
|
int rc;
|
2010-06-29 15:53:45 +00:00
|
|
|
uint8_t *len;
|
2013-10-11 10:55:35 +00:00
|
|
|
uint8_t ta;
|
2008-12-27 01:55:51 +00:00
|
|
|
|
|
|
|
struct rsl_ie_chan_mode cm;
|
2010-06-20 19:38:19 +00:00
|
|
|
struct gsm48_chan_desc cd;
|
2008-12-27 01:55:51 +00:00
|
|
|
|
2016-07-14 00:51:13 +00:00
|
|
|
/* If a TCH_F/PDCH TS is in PDCH mode, deactivate PDCH first. */
|
2013-10-11 11:32:30 +00:00
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH
|
2016-06-14 12:08:35 +00:00
|
|
|
&& (lchan->ts->flags & TS_F_PDCH_ACTIVE)) {
|
2013-10-11 11:32:30 +00:00
|
|
|
/* store activation type and handover reference */
|
2016-07-23 19:00:51 +00:00
|
|
|
lchan->dyn.act_type = act_type;
|
|
|
|
lchan->dyn.ho_ref = ho_ref;
|
2013-10-11 11:32:30 +00:00
|
|
|
return rsl_ipacc_pdch_activate(lchan->ts, 0);
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
/*
|
|
|
|
* If necessary, release PDCH on dynamic TS. Note that sending a
|
|
|
|
* release here is only necessary when in PDCH mode; for TCH types, an
|
|
|
|
* RSL RF Chan Release is initiated by the BTS when a voice call ends,
|
|
|
|
* so when we reach this, it will already be released. If a dyn TS is
|
|
|
|
* in PDCH mode, it is still active and we need to initiate a release
|
|
|
|
* from the BSC side here.
|
|
|
|
*
|
|
|
|
* If pchan_is != pchan_want, the PDCH has already been taken down and
|
|
|
|
* the switchover now needs to enable the TCH lchan.
|
|
|
|
*
|
|
|
|
* To switch a dyn TS between TCH/H and TCH/F, it is sufficient to send
|
|
|
|
* a chan activ with the new lchan type, because it will already be
|
|
|
|
* released.
|
|
|
|
*/
|
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH
|
|
|
|
&& lchan->ts->dyn.pchan_is == GSM_PCHAN_PDCH
|
|
|
|
&& lchan->ts->dyn.pchan_is == lchan->ts->dyn.pchan_want) {
|
|
|
|
enum gsm_phys_chan_config pchan_want;
|
|
|
|
pchan_want = pchan_for_lchant(lchan->type);
|
|
|
|
if (lchan->ts->dyn.pchan_is != pchan_want) {
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
/*
|
|
|
|
* Make sure to record on lchan[0] so that we'll find
|
|
|
|
* it after the PDCH release.
|
|
|
|
*/
|
|
|
|
struct gsm_lchan *lchan0 = lchan->ts->lchan;
|
|
|
|
lchan0->dyn.act_type = act_type,
|
|
|
|
lchan0->dyn.ho_ref = ho_ref;
|
|
|
|
lchan0->dyn.rqd_ref = lchan->rqd_ref;
|
|
|
|
lchan0->dyn.rqd_ta = lchan->rqd_ta;
|
2016-07-23 17:45:15 +00:00
|
|
|
lchan->rqd_ref = NULL;
|
|
|
|
lchan->rqd_ta = 0;
|
|
|
|
DEBUGP(DRSL, "%s saved rqd_ref=%p ta=%u\n",
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
gsm_lchan_name(lchan0), lchan0->rqd_ref,
|
|
|
|
lchan0->rqd_ta);
|
|
|
|
return dyn_ts_switchover_start(lchan->ts, pchan_want);
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEBUGP(DRSL, "%s Tx RSL Channel Activate with act_type=%s\n",
|
|
|
|
gsm_ts_and_pchan_name(lchan->ts),
|
|
|
|
rsl_act_type_name(act_type));
|
|
|
|
|
|
|
|
if (act_type == RSL_ACT_OSMO_PDCH) {
|
|
|
|
if (lchan->ts->pchan != GSM_PCHAN_TCH_F_TCH_H_PDCH) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s PDCH channel activation only allowed on %s\n",
|
|
|
|
gsm_ts_and_pchan_name(lchan->ts),
|
|
|
|
gsm_pchan_name(GSM_PCHAN_TCH_F_TCH_H_PDCH));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
return rsl_chan_activate_lchan_as_pdch(lchan);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH
|
|
|
|
&& lchan->ts->dyn.pchan_want == GSM_PCHAN_PDCH) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Expected PDCH activation kind\n",
|
|
|
|
gsm_ts_and_pchan_name(lchan->ts));
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2016-07-23 17:49:58 +00:00
|
|
|
rc = channel_mode_from_lchan(&cm, lchan);
|
|
|
|
if (rc < 0) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Cannot find channel mode from lchan type\n",
|
|
|
|
gsm_ts_and_pchan_name(lchan->ts));
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2016-06-14 11:12:00 +00:00
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_ACT_REQ);
|
|
|
|
|
2013-10-11 10:55:35 +00:00
|
|
|
ta = lchan->rqd_ta;
|
|
|
|
|
|
|
|
/* BS11 requires TA shifted by 2 bits */
|
|
|
|
if (lchan->ts->trx->bts->type == GSM_BTS_TYPE_BS11)
|
|
|
|
ta <<= 2;
|
|
|
|
|
2010-06-30 03:56:43 +00:00
|
|
|
memset(&cd, 0, sizeof(cd));
|
2010-06-20 19:38:19 +00:00
|
|
|
gsm48_lchan2chan_desc(&cd, lchan);
|
2008-12-27 01:55:51 +00:00
|
|
|
|
2009-06-27 01:09:08 +00:00
|
|
|
msg = rsl_msgb_alloc();
|
2008-12-27 01:55:51 +00:00
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_CHAN_ACTIV);
|
2016-07-23 17:51:09 +00:00
|
|
|
|
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)
|
|
|
|
dh->chan_nr = gsm_lchan_as_pchan2chan_nr(
|
|
|
|
lchan, lchan->ts->dyn.pchan_want);
|
|
|
|
else
|
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2008-12-27 01:55:51 +00:00
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_ACT_TYPE, act_type);
|
|
|
|
msgb_tlv_put(msg, RSL_IE_CHAN_MODE, sizeof(cm),
|
2011-04-18 15:04:00 +00:00
|
|
|
(uint8_t *) &cm);
|
2010-06-30 03:56:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The Channel Identification is needed for Phase1 phones
|
|
|
|
* and it contains the GSM48 Channel Description and the
|
|
|
|
* Mobile Allocation. The GSM 08.58 asks for the Mobile
|
|
|
|
* Allocation to have a length of zero. We are using the
|
|
|
|
* msgb_l3len to calculate the length of both messages.
|
|
|
|
*/
|
2010-06-20 19:38:19 +00:00
|
|
|
msgb_v_put(msg, RSL_IE_CHAN_IDENT);
|
2010-06-29 15:53:45 +00:00
|
|
|
len = msgb_put(msg, 1);
|
2011-07-27 21:40:33 +00:00
|
|
|
msgb_tv_fixed_put(msg, GSM48_IE_CHANDESC_2, sizeof(cd), (const uint8_t *) &cd);
|
2010-06-30 04:06:20 +00:00
|
|
|
|
|
|
|
if (lchan->ts->hopping.enabled)
|
|
|
|
msgb_tlv_put(msg, GSM48_IE_MA_AFTER, lchan->ts->hopping.ma_len,
|
|
|
|
lchan->ts->hopping.ma_data);
|
|
|
|
else
|
|
|
|
msgb_tlv_put(msg, GSM48_IE_MA_AFTER, 0, NULL);
|
2010-06-30 03:56:43 +00:00
|
|
|
|
|
|
|
/* update the calculated size */
|
|
|
|
msg->l3h = len + 1;
|
|
|
|
*len = msgb_l3len(msg);
|
|
|
|
|
2009-08-30 06:37:11 +00:00
|
|
|
if (lchan->encr.alg_id > RSL_ENC_ALG_A5(0)) {
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t encr_info[MAX_A5_KEY_LEN+2];
|
2009-08-30 06:37:11 +00:00
|
|
|
rc = build_encr_info(encr_info, lchan);
|
|
|
|
if (rc > 0)
|
|
|
|
msgb_tlv_put(msg, RSL_IE_ENCR_INFO, rc, encr_info);
|
|
|
|
}
|
|
|
|
|
2009-12-16 23:31:10 +00:00
|
|
|
switch (act_type) {
|
|
|
|
case RSL_ACT_INTER_ASYNC:
|
|
|
|
case RSL_ACT_INTER_SYNC:
|
|
|
|
msgb_tv_put(msg, RSL_IE_HANDO_REF, ho_ref);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-15 16:56:18 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_BS_POWER, lchan->bs_power);
|
|
|
|
msgb_tv_put(msg, RSL_IE_MS_POWER, lchan->ms_power);
|
2008-12-27 01:55:51 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_TIMING_ADVANCE, ta);
|
2015-08-20 17:32:46 +00:00
|
|
|
mr_config_for_bts(lchan, msg);
|
2010-01-28 03:45:05 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-02-07 00:48:17 +00:00
|
|
|
|
2008-12-27 01:55:51 +00:00
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-07-29 09:38:15 +00:00
|
|
|
/* Chapter 8.4.9: Modify channel mode on BTS side */
|
2009-02-18 03:29:53 +00:00
|
|
|
int rsl_chan_mode_modify_req(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2009-06-27 01:09:08 +00:00
|
|
|
struct msgb *msg;
|
2009-07-29 13:41:29 +00:00
|
|
|
int rc;
|
2009-02-18 03:29:53 +00:00
|
|
|
|
2011-06-25 08:02:33 +00:00
|
|
|
uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-02-18 03:29:53 +00:00
|
|
|
struct rsl_ie_chan_mode cm;
|
|
|
|
|
2009-07-29 13:41:29 +00:00
|
|
|
rc = channel_mode_from_lchan(&cm, lchan);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2009-02-18 03:29:53 +00:00
|
|
|
|
2009-06-27 01:09:08 +00:00
|
|
|
msg = rsl_msgb_alloc();
|
2009-02-18 03:29:53 +00:00
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_MODE_MODIFY_REQ);
|
|
|
|
dh->chan_nr = chan_nr;
|
|
|
|
|
|
|
|
msgb_tlv_put(msg, RSL_IE_CHAN_MODE, sizeof(cm),
|
2011-04-18 15:04:00 +00:00
|
|
|
(uint8_t *) &cm);
|
2009-08-30 06:37:11 +00:00
|
|
|
|
|
|
|
if (lchan->encr.alg_id > RSL_ENC_ALG_A5(0)) {
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t encr_info[MAX_A5_KEY_LEN+2];
|
2009-08-30 06:37:11 +00:00
|
|
|
rc = build_encr_info(encr_info, lchan);
|
|
|
|
if (rc > 0)
|
|
|
|
msgb_tlv_put(msg, RSL_IE_ENCR_INFO, rc, encr_info);
|
|
|
|
}
|
|
|
|
|
2015-08-20 17:32:46 +00:00
|
|
|
mr_config_for_bts(lchan, msg);
|
2009-11-18 21:57:02 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-08-30 06:37:11 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chapter 8.4.6: Send the encryption command with given L3 info */
|
|
|
|
int rsl_encryption_cmd(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
struct gsm_lchan *lchan = msg->lchan;
|
2011-06-25 08:02:33 +00:00
|
|
|
uint8_t chan_nr = gsm_lchan2chan_nr(lchan);
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t encr_info[MAX_A5_KEY_LEN+2];
|
|
|
|
uint8_t l3_len = msg->len;
|
2009-08-30 06:37:11 +00:00
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* First push the L3 IE tag and length */
|
|
|
|
msgb_tv16_push(msg, RSL_IE_L3_INFO, l3_len);
|
|
|
|
|
|
|
|
/* then the link identifier (SAPI0, main sign link) */
|
|
|
|
msgb_tv_push(msg, RSL_IE_LINK_IDENT, 0);
|
|
|
|
|
|
|
|
/* then encryption information */
|
|
|
|
rc = build_encr_info(encr_info, lchan);
|
|
|
|
if (rc <= 0)
|
|
|
|
return rc;
|
|
|
|
msgb_tlv_push(msg, RSL_IE_ENCR_INFO, rc, encr_info);
|
|
|
|
|
|
|
|
/* and finally the DCHAN header */
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_push(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_ENCR_CMD);
|
|
|
|
dh->chan_nr = chan_nr;
|
2009-02-18 03:29:53 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-02-18 03:29:53 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-08-10 09:43:22 +00:00
|
|
|
/* Chapter 8.4.5 / 4.6: Deactivate the SACCH after 04.08 RR CHAN RELEASE */
|
2009-07-19 16:36:49 +00:00
|
|
|
int rsl_deact_sacch(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_DEACTIVATE_SACCH);
|
2011-06-25 08:02:33 +00:00
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-07-19 16:36:49 +00:00
|
|
|
|
|
|
|
msg->lchan = lchan;
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-07-19 16:36:49 +00:00
|
|
|
|
2009-12-27 17:16:36 +00:00
|
|
|
DEBUGP(DRSL, "%s DEACTivate SACCH CMD\n", gsm_lchan_name(lchan));
|
2009-07-19 16:36:49 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2016-08-24 12:44:11 +00:00
|
|
|
static bool dyn_ts_should_switch_to_pdch(struct gsm_bts_trx_ts *ts)
|
|
|
|
{
|
|
|
|
int ss;
|
|
|
|
|
|
|
|
if (ts->pchan != GSM_PCHAN_TCH_F_TCH_H_PDCH)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (ts->trx->bts->gprs.mode == BTS_GPRS_NONE)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* Already in PDCH mode? */
|
|
|
|
if (ts->dyn.pchan_is == GSM_PCHAN_PDCH)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
/* See if all lchans are released. */
|
|
|
|
for (ss = 0; ss < ts_subslots(ts); ss++) {
|
|
|
|
struct gsm_lchan *lc = &ts->lchan[ss];
|
|
|
|
if (lc->state != LCHAN_S_NONE) {
|
2016-08-24 12:48:39 +00:00
|
|
|
DEBUGP(DRSL, "%s lchan %u still in use"
|
|
|
|
" (type=%s,state=%s)\n",
|
|
|
|
gsm_ts_and_pchan_name(ts), lc->nr,
|
|
|
|
gsm_lchant_name(lc->type),
|
|
|
|
gsm_lchans_name(lc->state));
|
2016-08-24 12:44:11 +00:00
|
|
|
/* An lchan is still used. */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All channels are released, go to PDCH mode. */
|
|
|
|
DEBUGP(DRSL, "%s back to PDCH\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-05-31 13:38:24 +00:00
|
|
|
static void error_timeout_cb(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
if (lchan->state != LCHAN_S_REL_ERR) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s error timeout but not in error state: %d\n",
|
|
|
|
gsm_lchan_name(lchan), lchan->state);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* go back to the none state */
|
2012-11-13 03:26:22 +00:00
|
|
|
LOGP(DRSL, LOGL_INFO, "%s is back in operation.\n", gsm_lchan_name(lchan));
|
2010-06-08 03:53:33 +00:00
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_NONE);
|
2016-06-21 18:55:14 +00:00
|
|
|
|
2016-07-06 12:39:04 +00:00
|
|
|
/* Put PDCH channel back into PDCH mode, if GPRS is enabled */
|
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_PDCH
|
|
|
|
&& lchan->ts->trx->bts->gprs.mode != BTS_GPRS_NONE)
|
2016-06-21 18:55:14 +00:00
|
|
|
rsl_ipacc_pdch_activate(lchan->ts, 1);
|
dyn TS: fix error recovery: switch to PDCH after lchan error state
Tested by hacking a CHAN ACT ACK delay of a couple of seconds into osmo-bts'
rsl.c for the first TCH_H lchan:
[[[
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..4bfd27a 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -559,6 +559,22 @@ static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
return abis_bts_rsl_sendmsg(msg);
}
+struct osmo_timer_list xxx_timer;
+
+static void xxx_timer_cb(void *data)
+{
+ rsl_tx_chan_act_ack(data);
+}
+
+static int rsl_tx_chan_act_ack_later(struct gsm_lchan *lchan)
+{
+ xxx_timer.cb = xxx_timer_cb;
+ xxx_timer.data = lchan;
+ osmo_timer_schedule(&xxx_timer, 10, 0);
+ return 0;
+}
+
+
/* 8.4.7 sending HANDOver DETection */
int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay)
{
@@ -614,6 +630,18 @@ int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause)
if (cause)
return rsl_tx_chan_act_nack(lchan, cause);
+
+ static int xxx = 0;
+
+ DEBUGP(DRSL, "%s XXXXXXXXXXXXXXXXXXXXX %d %s\n",
+ gsm_lchan_name(lchan), xxx, gsm_lchant_name(lchan->type));
+
+ if (lchan->type == GSM_LCHAN_TCH_H) {
+ if (!xxx) {
+ xxx ++;
+ return rsl_tx_chan_act_ack_later(lchan);
+ }
+ }
return rsl_tx_chan_act_ack(lchan);
}
]]]
Change-Id: Ie82dec9c9fefc476fdf5b5afdad2246b9d6fe304
2016-08-24 12:45:44 +00:00
|
|
|
|
|
|
|
if (dyn_ts_should_switch_to_pdch(lchan->ts))
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
dyn_ts_switchover_start(lchan->ts, GSM_PCHAN_PDCH);
|
2010-05-31 13:38:24 +00:00
|
|
|
}
|
|
|
|
|
2011-03-04 12:41:31 +00:00
|
|
|
static int rsl_rx_rf_chan_rel_ack(struct gsm_lchan *lchan);
|
|
|
|
|
2009-08-10 09:43:22 +00:00
|
|
|
/* Chapter 8.4.14 / 4.7: Tell BTS to release the radio channel */
|
2011-12-28 15:21:05 +00:00
|
|
|
static int rsl_rf_chan_release(struct gsm_lchan *lchan, int error,
|
|
|
|
enum sacch_deact deact_sacch)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2010-05-31 13:38:24 +00:00
|
|
|
struct msgb *msg;
|
2011-03-04 12:41:31 +00:00
|
|
|
int rc;
|
2010-05-31 13:38:24 +00:00
|
|
|
|
2011-12-28 15:21:05 +00:00
|
|
|
/* Stop timers that should lead to a channel release */
|
|
|
|
osmo_timer_del(&lchan->T3109);
|
|
|
|
|
2010-05-31 13:38:24 +00:00
|
|
|
if (lchan->state == LCHAN_S_REL_ERR) {
|
2016-08-24 15:02:19 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s is in error state, not sending release.\n",
|
2010-05-31 13:38:24 +00:00
|
|
|
gsm_lchan_name(lchan));
|
|
|
|
return -1;
|
|
|
|
}
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2010-05-31 13:38:24 +00:00
|
|
|
msg = rsl_msgb_alloc();
|
2008-12-23 20:25:15 +00:00
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_RF_CHAN_REL);
|
2011-06-25 08:02:33 +00:00
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
msg->lchan = lchan;
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
2016-08-22 16:40:07 +00:00
|
|
|
if (error)
|
|
|
|
DEBUGP(DRSL, "%s RF Channel Release due to error: %d\n",
|
|
|
|
gsm_lchan_name(lchan), error);
|
|
|
|
else
|
|
|
|
DEBUGP(DRSL, "%s RF Channel Release\n", gsm_lchan_name(lchan));
|
2010-05-31 13:38:24 +00:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
/*
|
2011-12-28 11:11:40 +00:00
|
|
|
* FIXME: GSM 04.08 gives us two options for the abnormal
|
|
|
|
* chanel release. This can be either like in the non-existent
|
|
|
|
* sub-lcuase 3.5.1 or for the main signalling link deactivate
|
|
|
|
* the SACCH, start timer T3109 and consider the channel as
|
|
|
|
* released.
|
|
|
|
*
|
|
|
|
* This code is doing the later for all raido links and not
|
|
|
|
* only the main link. Right now all SAPIs are released on the
|
|
|
|
* local end, the SACCH will be de-activated and right now the
|
|
|
|
* T3111 will be started. First T3109 should be started and then
|
|
|
|
* the T3111.
|
|
|
|
*
|
|
|
|
* TODO: Move this out of the function.
|
2010-05-31 13:38:24 +00:00
|
|
|
*/
|
2011-08-17 20:43:54 +00:00
|
|
|
|
2011-12-28 11:11:40 +00:00
|
|
|
/*
|
|
|
|
* sacch de-activate and "local end release"
|
|
|
|
*/
|
2011-12-28 15:21:05 +00:00
|
|
|
if (deact_sacch == SACCH_DEACTIVATE)
|
|
|
|
rsl_deact_sacch(lchan);
|
2011-12-28 11:11:40 +00:00
|
|
|
rsl_release_sapis_from(lchan, 0, RSL_REL_LOCAL_END);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* TODO: start T3109 now.
|
|
|
|
*/
|
2010-06-08 03:53:33 +00:00
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_REL_ERR);
|
2010-05-31 13:38:24 +00:00
|
|
|
}
|
2008-12-27 19:46:06 +00:00
|
|
|
|
2011-08-10 21:26:33 +00:00
|
|
|
/* Start another timer or assume the BTS sends a ACK/NACK? */
|
|
|
|
lchan->act_timer.cb = lchan_deact_tmr_cb;
|
|
|
|
lchan->act_timer.data = lchan;
|
|
|
|
osmo_timer_schedule(&lchan->act_timer, 4, 0);
|
|
|
|
|
2011-03-04 12:41:31 +00:00
|
|
|
rc = abis_rsl_sendmsg(msg);
|
|
|
|
|
2009-08-10 09:43:22 +00:00
|
|
|
/* BTS will respond by RF CHAN REL ACK */
|
2011-03-04 12:41:31 +00:00
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2014-04-19 15:38:33 +00:00
|
|
|
/*
|
|
|
|
* Special handling for channel releases in the error case.
|
|
|
|
*/
|
|
|
|
static int rsl_rf_chan_release_err(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
if (lchan->state != LCHAN_S_ACTIVE)
|
|
|
|
return 0;
|
|
|
|
return rsl_rf_chan_release(lchan, 1, SACCH_DEACTIVATE);
|
|
|
|
}
|
|
|
|
|
2011-01-14 13:16:16 +00:00
|
|
|
static int rsl_rx_rf_chan_rel_ack(struct gsm_lchan *lchan)
|
|
|
|
{
|
2016-07-23 18:01:49 +00:00
|
|
|
struct gsm_bts_trx_ts *ts = lchan->ts;
|
2011-01-14 13:16:16 +00:00
|
|
|
|
|
|
|
DEBUGP(DRSL, "%s RF CHANNEL RELEASE ACK\n", gsm_lchan_name(lchan));
|
|
|
|
|
2012-12-06 18:09:58 +00:00
|
|
|
/* Stop all pending timers */
|
2011-08-10 21:26:33 +00:00
|
|
|
osmo_timer_del(&lchan->act_timer);
|
2012-12-06 18:09:58 +00:00
|
|
|
osmo_timer_del(&lchan->T3111);
|
2011-08-10 21:26:33 +00:00
|
|
|
|
2015-04-04 17:35:22 +00:00
|
|
|
/*
|
|
|
|
* The BTS didn't respond within the timeout to our channel
|
|
|
|
* release request and we have marked the channel as broken.
|
|
|
|
* Now we do receive an ACK and let's be conservative. If it
|
|
|
|
* is a sysmoBTS we know that only one RF Channel Release ACK
|
|
|
|
* will be sent. So let's "repair" the channel.
|
|
|
|
*/
|
2013-05-01 16:44:04 +00:00
|
|
|
if (lchan->state == LCHAN_S_BROKEN) {
|
2016-07-23 18:01:49 +00:00
|
|
|
int do_free = is_sysmobts_v2(ts->trx->bts);
|
2015-04-04 17:35:22 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE,
|
|
|
|
"%s CHAN REL ACK for broken channel. %s.\n",
|
|
|
|
gsm_lchan_name(lchan),
|
|
|
|
do_free ? "Releasing it" : "Keeping it broken");
|
|
|
|
if (do_free)
|
|
|
|
do_lchan_free(lchan);
|
dyn TS: fix OS#1798: on late RF CHAN REL ACK, activate PDCH
Tested by hacking a REL ACK delay of a couple of seconds into osmo-bts' rsl.c
for the first TCH_H lchan:
[[[
diff --git a/include/osmo-bts/rsl.h b/include/osmo-bts/rsl.h
index 093e9cb..b35c3bb 100644
--- a/include/osmo-bts/rsl.h
+++ b/include/osmo-bts/rsl.h
@@ -22,6 +22,7 @@ int rsl_tx_est_ind(struct gsm_lchan *lchan, uint8_t link_id, uint8_t *data, int
int rsl_tx_chan_act_acknack(struct gsm_lchan *lchan, uint8_t cause);
int rsl_tx_conn_fail(struct gsm_lchan *lchan, uint8_t cause);
int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan);
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan);
int rsl_tx_hando_det(struct gsm_lchan *lchan, uint8_t *ho_delay);
/* call-back for LAPDm code, called when it wants to send msgs UP */
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index 3802e25..1f92b0d 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -491,7 +491,16 @@ static int l1sap_info_rel_cnf(struct gsm_bts_trx *trx,
lchan = get_lchan_by_chan_nr(trx, info_act_cnf->chan_nr);
- rsl_tx_rf_rel_ack(lchan);
+ static int yyy = 0;
+
+ DEBUGP(DRSL, "%s YYYYYYYYYYYYYYYYYYYYY %d %s\n",
+ gsm_lchan_name(lchan), yyy, gsm_lchant_name(lchan->type));
+
+ if (lchan->type == GSM_LCHAN_TCH_H && !yyy) {
+ yyy ++;
+ rsl_tx_rf_rel_ack_later(lchan);
+ } else
+ rsl_tx_rf_rel_ack(lchan);
/* During PDCH DEACT, this marks the deactivation of the PDTCH as
* requested by the PCU. Next up, we disconnect the TS completely and
diff --git a/src/common/rsl.c b/src/common/rsl.c
index 3c97af9..7926f21 100644
--- a/src/common/rsl.c
+++ b/src/common/rsl.c
@@ -534,6 +534,22 @@ int rsl_tx_rf_rel_ack(struct gsm_lchan *lchan)
return abis_bts_rsl_sendmsg(msg);
}
+struct osmo_timer_list yyy_timer;
+
+static void yyy_timer_cb(void *data)
+{
+ rsl_tx_rf_rel_ack(data);
+}
+
+int rsl_tx_rf_rel_ack_later(struct gsm_lchan *lchan)
+{
+ yyy_timer.cb = yyy_timer_cb;
+ yyy_timer.data = lchan;
+ osmo_timer_schedule(&yyy_timer, 10, 0);
+ return 0;
+}
+
+
/* 8.4.2 sending CHANnel ACTIVation ACKnowledge */
static int rsl_tx_chan_act_ack(struct gsm_lchan *lchan)
{
]]]
Change-Id: I87e07e1d54882f8f3d667fa300c6e3679f5c920d
Fixes: OS#1798
2016-08-24 15:02:37 +00:00
|
|
|
if (dyn_ts_should_switch_to_pdch(lchan->ts))
|
|
|
|
dyn_ts_switchover_start(lchan->ts, GSM_PCHAN_PDCH);
|
2013-05-01 16:44:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-14 13:16:16 +00:00
|
|
|
if (lchan->state != LCHAN_S_REL_REQ && lchan->state != LCHAN_S_REL_ERR)
|
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s CHAN REL ACK but state %s\n",
|
|
|
|
gsm_lchan_name(lchan),
|
|
|
|
gsm_lchans_name(lchan->state));
|
2013-10-11 11:32:30 +00:00
|
|
|
|
2016-06-14 11:12:00 +00:00
|
|
|
do_lchan_free(lchan);
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
/*
|
|
|
|
* Check Osmocom RSL CHAN ACT style dynamic TCH/F_TCH/H_PDCH TS for pending
|
|
|
|
* transitions in these cases:
|
|
|
|
*
|
|
|
|
* a) after PDCH was released due to switchover request, activate TCH.
|
|
|
|
* BSC initiated this switchover, so dyn.pchan_is != pchan_want and
|
|
|
|
* lchan->type has been set to the desired GSM_LCHAN_*.
|
|
|
|
*
|
|
|
|
* b) Voice call ended and a TCH is released. If the TS is now unused,
|
|
|
|
* switch to PDCH. Here still dyn.pchan_is == dyn.pchan_want because
|
|
|
|
* we're only just notified and may decide to switch to PDCH now.
|
|
|
|
*/
|
|
|
|
if (ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH) {
|
|
|
|
DEBUGP(DRSL, "%s Rx RSL Channel Release ack for lchan %u\n",
|
|
|
|
gsm_ts_and_pchan_name(ts), lchan->nr);
|
|
|
|
|
|
|
|
/* (a) */
|
|
|
|
if (ts->dyn.pchan_is != ts->dyn.pchan_want)
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return dyn_ts_switchover_continue(ts);
|
2016-07-23 17:45:15 +00:00
|
|
|
|
|
|
|
/* (b) */
|
2016-08-24 12:44:11 +00:00
|
|
|
if (dyn_ts_should_switch_to_pdch(ts))
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return dyn_ts_switchover_start(ts, GSM_PCHAN_PDCH);
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-23 20:44:20 +00:00
|
|
|
/*
|
|
|
|
* Put a dynamic TCH/F_PDCH channel back to PDCH mode iff it was
|
|
|
|
* released successfully. If in error, the PDCH ACT will follow after
|
|
|
|
* T3111 in error_timeout_cb().
|
|
|
|
*
|
|
|
|
* Any state other than LCHAN_S_REL_ERR became LCHAN_S_NONE after above
|
|
|
|
* do_lchan_free(). Assert this, because that's what ensures a PDCH ACT
|
2016-07-14 00:51:13 +00:00
|
|
|
* on a TCH/F_PDCH TS in all cases.
|
2016-07-06 12:39:04 +00:00
|
|
|
*
|
|
|
|
* If GPRS is disabled, always skip the PDCH ACT.
|
2016-06-23 20:44:20 +00:00
|
|
|
*/
|
|
|
|
OSMO_ASSERT(lchan->state == LCHAN_S_NONE
|
|
|
|
|| lchan->state == LCHAN_S_REL_ERR);
|
2016-07-23 18:01:49 +00:00
|
|
|
if (ts->trx->bts->gprs.mode == BTS_GPRS_NONE)
|
2016-07-06 12:39:04 +00:00
|
|
|
return 0;
|
2016-07-23 18:01:49 +00:00
|
|
|
if (ts->pchan == GSM_PCHAN_TCH_F_PDCH
|
2016-06-21 18:55:14 +00:00
|
|
|
&& lchan->state == LCHAN_S_NONE)
|
2016-07-23 18:01:49 +00:00
|
|
|
return rsl_ipacc_pdch_activate(ts, 1);
|
2011-01-14 13:16:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_paging_cmd(struct gsm_bts *bts, uint8_t paging_group, uint8_t len,
|
|
|
|
uint8_t *ms_ident, uint8_t chan_needed)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2008-12-25 23:28:35 +00:00
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_PAGING_CMD);
|
|
|
|
dh->chan_nr = RSL_CHAN_PCH_AGCH;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_PAGING_GROUP, paging_group);
|
2008-12-28 02:26:27 +00:00
|
|
|
msgb_tlv_put(msg, RSL_IE_MS_IDENTITY, len-2, ms_ident+2);
|
2008-12-23 20:25:15 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_CHAN_NEEDED, chan_needed);
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = bts->c0->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
int imsi_str2bcd(uint8_t *bcd_out, const char *str_in)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
|
|
|
int i, len = strlen(str_in);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
int num = str_in[i] - 0x30;
|
|
|
|
if (num < 0 || num > 9)
|
|
|
|
return -1;
|
|
|
|
if (i % 2 == 0)
|
|
|
|
bcd_out[i/2] = num;
|
|
|
|
else
|
|
|
|
bcd_out[i/2] |= (num << 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-26 20:25:35 +00:00
|
|
|
/* Chapter 8.5.6 */
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_imm_assign_cmd(struct gsm_bts *bts, uint8_t len, uint8_t *val)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
2008-12-25 23:28:35 +00:00
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
2008-12-23 20:25:15 +00:00
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t buf[MACBLOCK_SIZE];
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_IMMEDIATE_ASSIGN_CMD);
|
|
|
|
dh->chan_nr = RSL_CHAN_PCH_AGCH;
|
|
|
|
|
2009-02-15 14:36:38 +00:00
|
|
|
switch (bts->type) {
|
|
|
|
case GSM_BTS_TYPE_BS11:
|
|
|
|
msgb_tlv_put(msg, RSL_IE_IMM_ASS_INFO, len, val);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* If phase 2, construct a FULL_IMM_ASS_INFO */
|
|
|
|
pad_macblock(buf, val, len);
|
|
|
|
msgb_tlv_put(msg, RSL_IE_FULL_IMM_ASS_INFO, MACBLOCK_SIZE, buf);
|
|
|
|
break;
|
|
|
|
}
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = bts->c0->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2009-08-10 07:51:40 +00:00
|
|
|
/* Send Siemens specific MS RF Power Capability Indication */
|
2009-08-10 08:07:33 +00:00
|
|
|
int rsl_siemens_mrpci(struct gsm_lchan *lchan, struct rsl_mrpci *mrpci)
|
2009-08-10 07:51:40 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
|
|
|
init_dchan_hdr(dh, RSL_MT_SIEMENS_MRPCI);
|
2009-08-10 09:26:14 +00:00
|
|
|
dh->c.msg_discr = ABIS_RSL_MDISC_DED_CHAN;
|
2011-06-25 08:02:33 +00:00
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2011-04-18 15:04:00 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_SIEMENS_MRPCI, *(uint8_t *)mrpci);
|
2009-08-10 07:51:40 +00:00
|
|
|
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s TX Siemens MRPCI 0x%02x\n",
|
2011-04-18 15:04:00 +00:00
|
|
|
gsm_lchan_name(lchan), *(uint8_t *)mrpci);
|
2009-08-10 09:26:14 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-08-10 09:26:14 +00:00
|
|
|
|
2009-08-10 07:51:40 +00:00
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
/* Send "DATA REQUEST" message with given L3 Info payload */
|
2008-12-23 20:25:15 +00:00
|
|
|
/* Chapter 8.3.1 */
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_data_request(struct msgb *msg, uint8_t link_id)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
2008-12-25 23:28:35 +00:00
|
|
|
if (msg->lchan == NULL) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "cannot send DATA REQUEST to unknown lchan\n");
|
2008-12-25 23:28:35 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2011-06-25 08:02:33 +00:00
|
|
|
rsl_rll_push_l3(msg, RSL_MT_DATA_REQ, gsm_lchan2chan_nr(msg->lchan),
|
2010-03-04 09:33:10 +00:00
|
|
|
link_id, 1);
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = msg->lchan->ts->trx->rsl_link;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2009-08-09 11:47:35 +00:00
|
|
|
/* Send "ESTABLISH REQUEST" message with given L3 Info payload */
|
|
|
|
/* Chapter 8.3.1 */
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_establish_request(struct gsm_lchan *lchan, uint8_t link_id)
|
2009-08-09 11:47:35 +00:00
|
|
|
{
|
2010-03-04 09:33:10 +00:00
|
|
|
struct msgb *msg;
|
2009-08-09 11:47:35 +00:00
|
|
|
|
2011-06-25 08:02:33 +00:00
|
|
|
msg = rsl_rll_simple(RSL_MT_EST_REQ, gsm_lchan2chan_nr(lchan),
|
2010-03-04 09:33:10 +00:00
|
|
|
link_id, 0);
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-08-09 11:47:35 +00:00
|
|
|
|
2012-04-26 17:42:19 +00:00
|
|
|
DEBUGP(DRLL, "%s RSL RLL ESTABLISH REQ (link_id=0x%02x)\n",
|
|
|
|
gsm_lchan_name(lchan), link_id);
|
|
|
|
|
2009-08-09 11:47:35 +00:00
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2013-12-05 12:25:06 +00:00
|
|
|
static void rsl_handle_release(struct gsm_lchan *lchan);
|
|
|
|
|
|
|
|
/* Special work handler to handle missing RSL_MT_REL_CONF message from
|
|
|
|
* Nokia InSite BTS */
|
|
|
|
static void lchan_rel_work_cb(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
int sapi;
|
|
|
|
|
|
|
|
for (sapi = 0; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) {
|
|
|
|
if (lchan->sapis[sapi] == LCHAN_SAPI_REL)
|
|
|
|
lchan->sapis[sapi] = LCHAN_SAPI_UNUSED;
|
|
|
|
}
|
|
|
|
rsl_handle_release(lchan);
|
|
|
|
}
|
|
|
|
|
2009-08-08 11:15:07 +00:00
|
|
|
/* Chapter 8.3.7 Request the release of multiframe mode of RLL connection.
|
|
|
|
This is what higher layers should call. The BTS then responds with
|
|
|
|
RELEASE CONFIRM, which we in turn use to trigger RSL CHANNEL RELEASE,
|
|
|
|
which in turn is acknowledged by RSL CHANNEL RELEASE ACK, which calls
|
|
|
|
lchan_free() */
|
2012-12-06 11:01:38 +00:00
|
|
|
int rsl_release_request(struct gsm_lchan *lchan, uint8_t link_id,
|
|
|
|
enum rsl_rel_mode release_mode)
|
2009-08-08 11:15:07 +00:00
|
|
|
{
|
|
|
|
|
2010-03-04 09:33:10 +00:00
|
|
|
struct msgb *msg;
|
|
|
|
|
2011-06-25 08:02:33 +00:00
|
|
|
msg = rsl_rll_simple(RSL_MT_REL_REQ, gsm_lchan2chan_nr(lchan),
|
2010-03-04 09:33:10 +00:00
|
|
|
link_id, 0);
|
2010-06-08 03:57:45 +00:00
|
|
|
/* 0 is normal release, 1 is local end */
|
2012-12-06 11:01:38 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_RELEASE_MODE, release_mode);
|
2009-08-08 11:15:07 +00:00
|
|
|
|
2009-12-29 09:44:17 +00:00
|
|
|
/* FIXME: start some timer in case we don't receive a REL ACK ? */
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-08-08 11:15:07 +00:00
|
|
|
|
2012-04-26 17:42:19 +00:00
|
|
|
DEBUGP(DRLL, "%s RSL RLL RELEASE REQ (link_id=0x%02x, reason=%u)\n",
|
2012-12-06 11:01:38 +00:00
|
|
|
gsm_lchan_name(lchan), link_id, release_mode);
|
2012-04-26 17:42:19 +00:00
|
|
|
|
2013-12-05 12:25:06 +00:00
|
|
|
abis_rsl_sendmsg(msg);
|
|
|
|
|
|
|
|
/* Do not wait for Nokia BTS to send the confirm. */
|
|
|
|
if (is_nokia_bts(lchan->ts->trx->bts)
|
|
|
|
&& lchan->ts->trx->bts->nokia.no_loc_rel_cnf
|
|
|
|
&& release_mode == RSL_REL_LOCAL_END) {
|
|
|
|
DEBUGP(DRLL, "Scheduling release, becasuse Nokia InSite BTS does not send a RELease CONFirm.\n");
|
|
|
|
lchan->sapis[link_id & 0x7] = LCHAN_SAPI_REL;
|
|
|
|
lchan->rel_work.cb = lchan_rel_work_cb;
|
|
|
|
lchan->rel_work.data = lchan;
|
|
|
|
osmo_timer_schedule(&lchan->rel_work, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2009-08-08 11:15:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-28 11:08:28 +00:00
|
|
|
int rsl_lchan_mark_broken(struct gsm_lchan *lchan, const char *reason)
|
|
|
|
{
|
2016-08-24 14:48:00 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s %s lchan broken: %s\n",
|
|
|
|
gsm_lchan_name(lchan), gsm_lchant_name(lchan->type), reason);
|
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_BROKEN);
|
2014-12-28 11:08:28 +00:00
|
|
|
lchan->broken_reason = reason;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-04-09 22:12:31 +00:00
|
|
|
int rsl_lchan_set_state(struct gsm_lchan *lchan, int state)
|
|
|
|
{
|
2016-06-21 19:34:46 +00:00
|
|
|
DEBUGP(DRSL, "%s state %s -> %s\n",
|
|
|
|
gsm_lchan_name(lchan), gsm_lchans_name(lchan->state),
|
|
|
|
gsm_lchans_name(state));
|
2010-04-09 22:12:31 +00:00
|
|
|
lchan->state = state;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-26 20:25:35 +00:00
|
|
|
/* Chapter 8.4.2: Channel Activate Acknowledge */
|
|
|
|
static int rsl_rx_chan_act_ack(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *rslh = msgb_l2(msg);
|
2016-07-14 14:16:33 +00:00
|
|
|
struct gsm_lchan *lchan = msg->lchan;
|
2008-12-26 20:25:35 +00:00
|
|
|
|
|
|
|
/* BTS has confirmed channel activation, we now need
|
|
|
|
* to assign the activated channel to the MS */
|
2008-12-27 01:55:51 +00:00
|
|
|
if (rslh->ie_chan != RSL_IE_CHAN_NR)
|
|
|
|
return -EINVAL;
|
2009-11-29 21:45:52 +00:00
|
|
|
|
2016-07-14 14:16:33 +00:00
|
|
|
osmo_timer_del(&lchan->act_timer);
|
2011-08-10 21:26:33 +00:00
|
|
|
|
2016-07-14 14:16:33 +00:00
|
|
|
if (lchan->state == LCHAN_S_BROKEN) {
|
2013-05-01 16:44:04 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s CHAN ACT ACK for broken channel.\n",
|
2016-07-14 14:16:33 +00:00
|
|
|
gsm_lchan_name(lchan));
|
2013-05-01 16:44:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-14 14:16:33 +00:00
|
|
|
if (lchan->state != LCHAN_S_ACT_REQ)
|
2009-12-29 09:52:38 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s CHAN ACT ACK, but state %s\n",
|
2016-07-14 14:16:33 +00:00
|
|
|
gsm_lchan_name(lchan),
|
|
|
|
gsm_lchans_name(lchan->state));
|
|
|
|
rsl_lchan_set_state(lchan, LCHAN_S_ACTIVE);
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
if (lchan->ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH)
|
|
|
|
dyn_ts_switchover_complete(lchan);
|
|
|
|
|
2016-07-14 14:16:33 +00:00
|
|
|
if (lchan->rqd_ref) {
|
|
|
|
rsl_send_imm_assignment(lchan);
|
|
|
|
talloc_free(lchan->rqd_ref);
|
|
|
|
lchan->rqd_ref = NULL;
|
|
|
|
lchan->rqd_ta = 0;
|
2010-06-22 04:11:59 +00:00
|
|
|
}
|
|
|
|
|
2016-07-14 14:16:33 +00:00
|
|
|
send_lchan_signal(S_LCHAN_ACTIVATE_ACK, lchan, NULL);
|
2009-11-29 21:45:52 +00:00
|
|
|
|
2008-12-27 01:55:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Chapter 8.4.3: Channel Activate NACK */
|
|
|
|
static int rsl_rx_chan_act_nack(struct msgb *msg)
|
|
|
|
{
|
2009-05-01 17:21:37 +00:00
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tp;
|
2008-12-26 20:25:35 +00:00
|
|
|
|
2011-08-10 21:26:33 +00:00
|
|
|
osmo_timer_del(&msg->lchan->act_timer);
|
|
|
|
|
2013-05-01 16:44:04 +00:00
|
|
|
if (msg->lchan->state == LCHAN_S_BROKEN) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s CHANNEL ACTIVATE NACK for broken channel.\n",
|
|
|
|
gsm_lchan_name(msg->lchan));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2011-08-11 02:54:23 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s CHANNEL ACTIVATE NACK ",
|
2009-12-27 17:16:36 +00:00
|
|
|
gsm_lchan_name(msg->lchan));
|
2009-12-27 10:48:11 +00:00
|
|
|
|
2009-05-01 17:21:37 +00:00
|
|
|
/* BTS has rejected channel activation ?!? */
|
|
|
|
if (dh->ie_chan != RSL_IE_CHAN_NR)
|
2008-12-27 01:55:51 +00:00
|
|
|
return -EINVAL;
|
2009-05-01 17:21:37 +00:00
|
|
|
|
|
|
|
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
2009-12-27 17:12:29 +00:00
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_CAUSE)) {
|
2011-04-18 15:04:00 +00:00
|
|
|
const uint8_t *cause = TLVP_VAL(&tp, RSL_IE_CAUSE);
|
2009-12-27 17:12:29 +00:00
|
|
|
print_rsl_cause(LOGL_ERROR, cause,
|
2009-07-28 15:58:09 +00:00
|
|
|
TLVP_LEN(&tp, RSL_IE_CAUSE));
|
2012-12-06 18:25:06 +00:00
|
|
|
msg->lchan->error_cause = *cause;
|
2014-12-28 11:08:28 +00:00
|
|
|
if (*cause != RSL_ERR_RCH_ALR_ACTV_ALLOC) {
|
|
|
|
rsl_lchan_mark_broken(msg->lchan, "NACK on activation");
|
|
|
|
} else
|
2011-12-28 15:21:05 +00:00
|
|
|
rsl_rf_chan_release(msg->lchan, 1, SACCH_DEACTIVATE);
|
2011-08-11 02:47:11 +00:00
|
|
|
|
2014-12-28 11:08:28 +00:00
|
|
|
} else {
|
|
|
|
rsl_lchan_mark_broken(msg->lchan, "NACK on activation no IE");
|
|
|
|
}
|
2010-03-29 06:47:44 +00:00
|
|
|
|
2009-12-27 10:48:11 +00:00
|
|
|
LOGPC(DRSL, LOGL_ERROR, "\n");
|
|
|
|
|
2010-12-27 12:28:20 +00:00
|
|
|
send_lchan_signal(S_LCHAN_ACTIVATE_NACK, msg->lchan, NULL);
|
2008-12-27 01:55:51 +00:00
|
|
|
return 0;
|
2008-12-26 20:25:35 +00:00
|
|
|
}
|
|
|
|
|
2009-02-23 00:02:59 +00:00
|
|
|
/* Chapter 8.4.4: Connection Failure Indication */
|
|
|
|
static int rsl_rx_conn_fail(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tp;
|
|
|
|
|
2014-04-19 14:45:36 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s CONNECTION FAIL: RELEASING state %s ",
|
|
|
|
gsm_lchan_name(msg->lchan),
|
|
|
|
gsm_lchans_name(msg->lchan->state));
|
|
|
|
|
2009-02-23 00:02:59 +00:00
|
|
|
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
|
2009-07-28 15:58:09 +00:00
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_CAUSE))
|
2009-12-24 11:20:20 +00:00
|
|
|
print_rsl_cause(LOGL_NOTICE, TLVP_VAL(&tp, RSL_IE_CAUSE),
|
2009-07-28 15:58:09 +00:00
|
|
|
TLVP_LEN(&tp, RSL_IE_CAUSE));
|
|
|
|
|
2009-12-26 21:33:09 +00:00
|
|
|
LOGPC(DRSL, LOGL_NOTICE, "\n");
|
2016-08-02 09:34:11 +00:00
|
|
|
rate_ctr_inc(&msg->lchan->ts->trx->bts->network->bsc_ctrs->ctr[BSC_CTR_CHAN_RF_FAIL]);
|
2014-04-19 15:38:33 +00:00
|
|
|
return rsl_rf_chan_release_err(msg->lchan);
|
2009-02-23 00:02:59 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 18:07:28 +00:00
|
|
|
static void print_meas_rep_uni(struct gsm_meas_rep_unidir *mru,
|
|
|
|
const char *prefix)
|
|
|
|
{
|
2009-12-16 15:52:07 +00:00
|
|
|
DEBUGPC(DMEAS, "RXL-FULL-%s=%3ddBm RXL-SUB-%s=%3ddBm ",
|
|
|
|
prefix, rxlev2dbm(mru->full.rx_lev),
|
|
|
|
prefix, rxlev2dbm(mru->sub.rx_lev));
|
2009-11-29 18:07:28 +00:00
|
|
|
DEBUGPC(DMEAS, "RXQ-FULL-%s=%d RXQ-SUB-%s=%d ",
|
|
|
|
prefix, mru->full.rx_qual, prefix, mru->sub.rx_qual);
|
|
|
|
}
|
|
|
|
|
2012-07-02 15:12:08 +00:00
|
|
|
static void print_meas_rep(struct gsm_lchan *lchan, struct gsm_meas_rep *mr)
|
2009-11-29 18:07:28 +00:00
|
|
|
{
|
2009-12-16 15:52:07 +00:00
|
|
|
int i;
|
2012-07-02 15:12:08 +00:00
|
|
|
char *name = "";
|
2009-12-16 15:52:07 +00:00
|
|
|
|
2015-12-28 13:04:36 +00:00
|
|
|
if (lchan && lchan->conn)
|
2012-07-02 15:12:08 +00:00
|
|
|
name = subscr_name(lchan->conn->subscr);
|
|
|
|
|
|
|
|
DEBUGP(DMEAS, "[%s] MEASUREMENT RESULT NR=%d ", name, mr->nr);
|
2009-11-29 18:07:28 +00:00
|
|
|
|
|
|
|
if (mr->flags & MEAS_REP_F_DL_DTX)
|
|
|
|
DEBUGPC(DMEAS, "DTXd ");
|
|
|
|
|
|
|
|
print_meas_rep_uni(&mr->ul, "ul");
|
|
|
|
DEBUGPC(DMEAS, "BS_POWER=%d ", mr->bs_power);
|
|
|
|
if (mr->flags & MEAS_REP_F_MS_TO)
|
|
|
|
DEBUGPC(DMEAS, "MS_TO=%d ", mr->ms_timing_offset);
|
|
|
|
|
|
|
|
if (mr->flags & MEAS_REP_F_MS_L1) {
|
2009-12-16 15:52:07 +00:00
|
|
|
DEBUGPC(DMEAS, "L1_MS_PWR=%3ddBm ", mr->ms_l1.pwr);
|
2009-11-29 18:07:28 +00:00
|
|
|
DEBUGPC(DMEAS, "L1_FPC=%u ",
|
|
|
|
mr->flags & MEAS_REP_F_FPC ? 1 : 0);
|
|
|
|
DEBUGPC(DMEAS, "L1_TA=%u ", mr->ms_l1.ta);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mr->flags & MEAS_REP_F_UL_DTX)
|
|
|
|
DEBUGPC(DMEAS, "DTXu ");
|
|
|
|
if (mr->flags & MEAS_REP_F_BA1)
|
|
|
|
DEBUGPC(DMEAS, "BA1 ");
|
|
|
|
if (!(mr->flags & MEAS_REP_F_DL_VALID))
|
|
|
|
DEBUGPC(DMEAS, "NOT VALID ");
|
|
|
|
else
|
|
|
|
print_meas_rep_uni(&mr->dl, "dl");
|
|
|
|
|
|
|
|
DEBUGPC(DMEAS, "NUM_NEIGH=%u\n", mr->num_cell);
|
2009-12-19 17:33:05 +00:00
|
|
|
if (mr->num_cell == 7)
|
|
|
|
return;
|
2009-12-16 15:52:07 +00:00
|
|
|
for (i = 0; i < mr->num_cell; i++) {
|
|
|
|
struct gsm_meas_rep_cell *mrc = &mr->cell[i];
|
2009-12-25 22:02:22 +00:00
|
|
|
DEBUGP(DMEAS, "IDX=%u ARFCN=%u BSIC=%u => %d dBm\n",
|
|
|
|
mrc->neigh_idx, mrc->arfcn, mrc->bsic, rxlev2dbm(mrc->rxlev));
|
2009-12-16 15:52:07 +00:00
|
|
|
}
|
2009-11-29 18:07:28 +00:00
|
|
|
}
|
|
|
|
|
2009-05-01 18:43:47 +00:00
|
|
|
static int rsl_rx_meas_res(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tp;
|
2009-12-15 20:36:05 +00:00
|
|
|
struct gsm_meas_rep *mr = lchan_next_meas_rep(msg->lchan);
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t len;
|
|
|
|
const uint8_t *val;
|
2009-11-29 18:07:28 +00:00
|
|
|
int rc;
|
|
|
|
|
2009-12-21 12:27:11 +00:00
|
|
|
/* check if this channel is actually active */
|
|
|
|
/* FIXME: maybe this check should be way more generic/centralized */
|
2009-12-29 09:44:17 +00:00
|
|
|
if (msg->lchan->state != LCHAN_S_ACTIVE) {
|
2010-07-29 06:50:57 +00:00
|
|
|
LOGP(DRSL, LOGL_DEBUG, "%s: MEAS RES for inactive channel\n",
|
2009-12-29 09:44:17 +00:00
|
|
|
gsm_lchan_name(msg->lchan));
|
2009-12-21 12:27:11 +00:00
|
|
|
return 0;
|
2009-12-29 09:44:17 +00:00
|
|
|
}
|
2009-12-21 12:27:11 +00:00
|
|
|
|
2009-12-15 20:36:05 +00:00
|
|
|
memset(mr, 0, sizeof(*mr));
|
2009-12-16 22:29:34 +00:00
|
|
|
mr->lchan = msg->lchan;
|
2009-11-30 18:16:47 +00:00
|
|
|
|
2009-05-01 18:43:47 +00:00
|
|
|
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
|
2009-11-29 18:07:28 +00:00
|
|
|
if (!TLVP_PRESENT(&tp, RSL_IE_MEAS_RES_NR) ||
|
|
|
|
!TLVP_PRESENT(&tp, RSL_IE_UPLINK_MEAS) ||
|
|
|
|
!TLVP_PRESENT(&tp, RSL_IE_BS_POWER))
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
/* Mandatory Parts */
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->nr = *TLVP_VAL(&tp, RSL_IE_MEAS_RES_NR);
|
2009-11-29 18:07:28 +00:00
|
|
|
|
|
|
|
len = TLVP_LEN(&tp, RSL_IE_UPLINK_MEAS);
|
|
|
|
val = TLVP_VAL(&tp, RSL_IE_UPLINK_MEAS);
|
|
|
|
if (len >= 3) {
|
|
|
|
if (val[0] & 0x40)
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->flags |= MEAS_REP_F_DL_DTX;
|
|
|
|
mr->ul.full.rx_lev = val[0] & 0x3f;
|
|
|
|
mr->ul.sub.rx_lev = val[1] & 0x3f;
|
|
|
|
mr->ul.full.rx_qual = val[2]>>3 & 0x7;
|
|
|
|
mr->ul.sub.rx_qual = val[2] & 0x7;
|
2009-05-01 18:43:47 +00:00
|
|
|
}
|
2009-11-29 18:07:28 +00:00
|
|
|
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->bs_power = *TLVP_VAL(&tp, RSL_IE_BS_POWER);
|
2009-11-29 18:07:28 +00:00
|
|
|
|
|
|
|
/* Optional Parts */
|
2009-05-01 18:43:47 +00:00
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_MS_TIMING_OFFSET))
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->ms_timing_offset =
|
2009-11-29 18:07:28 +00:00
|
|
|
*TLVP_VAL(&tp, RSL_IE_MS_TIMING_OFFSET);
|
|
|
|
|
2009-06-20 16:44:35 +00:00
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_L1_INFO)) {
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
|
|
|
|
2009-11-29 18:07:28 +00:00
|
|
|
val = TLVP_VAL(&tp, RSL_IE_L1_INFO);
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->flags |= MEAS_REP_F_MS_L1;
|
2011-08-17 20:43:54 +00:00
|
|
|
mr->ms_l1.pwr = ms_pwr_dbm(sign_link->trx->bts->band, val[0] >> 3);
|
2009-11-29 18:07:28 +00:00
|
|
|
if (val[0] & 0x04)
|
2009-12-15 20:36:05 +00:00
|
|
|
mr->flags |= MEAS_REP_F_FPC;
|
|
|
|
mr->ms_l1.ta = val[1];
|
2011-12-24 10:49:05 +00:00
|
|
|
/* BS11 and Nokia reports TA shifted by 2 bits */
|
|
|
|
if (msg->lchan->ts->trx->bts->type == GSM_BTS_TYPE_BS11
|
|
|
|
|| msg->lchan->ts->trx->bts->type == GSM_BTS_TYPE_NOKIA_SITE)
|
2011-12-16 16:45:37 +00:00
|
|
|
mr->ms_l1.ta >>= 2;
|
2009-06-20 16:44:35 +00:00
|
|
|
}
|
2009-06-09 20:24:21 +00:00
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_L3_INFO)) {
|
2011-04-18 15:04:00 +00:00
|
|
|
msg->l3h = (uint8_t *) TLVP_VAL(&tp, RSL_IE_L3_INFO);
|
2009-12-15 20:36:05 +00:00
|
|
|
rc = gsm48_parse_meas_rep(mr, msg);
|
2009-11-29 18:07:28 +00:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2012-07-02 15:12:08 +00:00
|
|
|
print_meas_rep(msg->lchan, mr);
|
2009-11-30 18:16:47 +00:00
|
|
|
|
2010-12-27 12:28:20 +00:00
|
|
|
send_lchan_signal(S_LCHAN_MEAS_REP, msg->lchan, mr);
|
2009-06-05 20:07:43 +00:00
|
|
|
|
2009-05-23 06:11:13 +00:00
|
|
|
return 0;
|
2009-05-01 18:43:47 +00:00
|
|
|
}
|
|
|
|
|
2009-11-29 21:45:52 +00:00
|
|
|
/* Chapter 8.4.7 */
|
|
|
|
static int rsl_rx_hando_det(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tp;
|
|
|
|
|
2009-12-27 17:16:36 +00:00
|
|
|
DEBUGP(DRSL, "%s HANDOVER DETECT ", gsm_lchan_name(msg->lchan));
|
2009-11-29 21:45:52 +00:00
|
|
|
|
|
|
|
rsl_tlv_parse(&tp, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_ACCESS_DELAY))
|
|
|
|
DEBUGPC(DRSL, "access delay = %u\n",
|
|
|
|
*TLVP_VAL(&tp, RSL_IE_ACCESS_DELAY));
|
|
|
|
else
|
|
|
|
DEBUGPC(DRSL, "\n");
|
|
|
|
|
2010-12-27 12:28:20 +00:00
|
|
|
send_lchan_signal(S_LCHAN_HANDOVER_DETECT, msg->lchan, NULL);
|
2009-11-29 21:45:52 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-06-13 10:28:21 +00:00
|
|
|
static bool lchan_may_change_pdch(struct gsm_lchan *lchan, bool pdch_act)
|
|
|
|
{
|
|
|
|
struct gsm_bts_trx_ts *ts;
|
|
|
|
|
|
|
|
OSMO_ASSERT(lchan);
|
|
|
|
|
|
|
|
ts = lchan->ts;
|
|
|
|
OSMO_ASSERT(ts);
|
|
|
|
OSMO_ASSERT(ts->trx);
|
|
|
|
OSMO_ASSERT(ts->trx->bts);
|
|
|
|
|
|
|
|
if (lchan->ts->pchan != GSM_PCHAN_TCH_F_PDCH) {
|
2016-06-21 18:53:27 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s pchan=%s Rx PDCH %s ACK"
|
|
|
|
" for channel that is no TCH/F_PDCH\n",
|
|
|
|
gsm_lchan_name(lchan),
|
2016-06-13 10:28:21 +00:00
|
|
|
gsm_pchan_name(ts->pchan),
|
|
|
|
pdch_act? "ACT" : "DEACT");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-06-14 11:12:00 +00:00
|
|
|
if (lchan->state != LCHAN_S_NONE) {
|
2016-06-21 18:53:27 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s pchan=%s Rx PDCH %s ACK"
|
|
|
|
" in unexpected state: %s\n",
|
|
|
|
gsm_lchan_name(lchan),
|
2016-06-13 10:28:21 +00:00
|
|
|
gsm_pchan_name(ts->pchan),
|
|
|
|
pdch_act? "ACT" : "DEACT",
|
|
|
|
gsm_lchans_name(lchan->state));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-10-11 11:32:30 +00:00
|
|
|
static int rsl_rx_pdch_act_ack(struct msgb *msg)
|
|
|
|
{
|
2016-06-13 10:28:21 +00:00
|
|
|
if (!lchan_may_change_pdch(msg->lchan, true))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-06-14 12:08:35 +00:00
|
|
|
msg->lchan->ts->flags |= TS_F_PDCH_ACTIVE;
|
2016-06-15 13:32:29 +00:00
|
|
|
msg->lchan->ts->flags &= ~TS_F_PDCH_ACT_PENDING;
|
2013-10-11 11:32:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsl_rx_pdch_deact_ack(struct msgb *msg)
|
|
|
|
{
|
2016-06-13 10:28:21 +00:00
|
|
|
if (!lchan_may_change_pdch(msg->lchan, false))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2016-06-14 12:08:35 +00:00
|
|
|
msg->lchan->ts->flags &= ~TS_F_PDCH_ACTIVE;
|
2016-06-15 13:32:29 +00:00
|
|
|
msg->lchan->ts->flags &= ~TS_F_PDCH_DEACT_PENDING;
|
2013-10-11 11:32:30 +00:00
|
|
|
|
2016-07-23 19:00:51 +00:00
|
|
|
rsl_chan_activate_lchan(msg->lchan, msg->lchan->dyn.act_type,
|
|
|
|
msg->lchan->dyn.ho_ref);
|
2013-10-11 11:32:30 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
static int abis_rsl_rx_dchan(struct msgb *msg)
|
|
|
|
{
|
2008-12-25 23:28:35 +00:00
|
|
|
struct abis_rsl_dchan_hdr *rslh = msgb_l2(msg);
|
|
|
|
int rc = 0;
|
2009-02-19 17:07:39 +00:00
|
|
|
char *ts_name;
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2016-08-22 23:22:58 +00:00
|
|
|
msg->lchan = lchan_lookup(sign_link->trx, rslh->chan_nr,
|
|
|
|
"Abis RSL rx DCHAN: ");
|
2016-10-10 01:24:05 +00:00
|
|
|
if (!msg->lchan)
|
|
|
|
return -1;
|
2009-12-27 17:16:36 +00:00
|
|
|
ts_name = gsm_lchan_name(msg->lchan);
|
2009-02-19 17:07:39 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
switch (rslh->c.msg_type) {
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_CHAN_ACTIV_ACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s CHANNEL ACTIVATE ACK\n", ts_name);
|
2008-12-26 20:25:35 +00:00
|
|
|
rc = rsl_rx_chan_act_ack(msg);
|
2008-12-25 23:28:35 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_CHAN_ACTIV_NACK:
|
2008-12-27 01:55:51 +00:00
|
|
|
rc = rsl_rx_chan_act_nack(msg);
|
2008-12-25 23:28:35 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_CONN_FAIL:
|
2009-02-23 00:02:59 +00:00
|
|
|
rc = rsl_rx_conn_fail(msg);
|
2008-12-25 23:28:35 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_MEAS_RES:
|
2009-05-01 18:43:47 +00:00
|
|
|
rc = rsl_rx_meas_res(msg);
|
2008-12-27 19:46:06 +00:00
|
|
|
break;
|
2009-11-29 21:45:52 +00:00
|
|
|
case RSL_MT_HANDO_DET:
|
|
|
|
rc = rsl_rx_hando_det(msg);
|
|
|
|
break;
|
2008-12-27 19:46:06 +00:00
|
|
|
case RSL_MT_RF_CHAN_REL_ACK:
|
2011-01-14 13:16:16 +00:00
|
|
|
rc = rsl_rx_rf_chan_rel_ack(msg->lchan);
|
2008-12-25 23:28:35 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_MODE_MODIFY_ACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s CHANNEL MODE MODIFY ACK\n", ts_name);
|
2009-02-18 03:29:53 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_MODE_MODIFY_NACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s CHANNEL MODE MODIFY NACK\n", ts_name);
|
2009-02-18 03:29:53 +00:00
|
|
|
break;
|
2009-10-24 08:29:22 +00:00
|
|
|
case RSL_MT_IPAC_PDCH_ACT_ACK:
|
2016-05-31 15:51:41 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC PDCH ACT ACK\n", ts_name);
|
2013-10-11 11:32:30 +00:00
|
|
|
rc = rsl_rx_pdch_act_ack(msg);
|
2009-10-24 08:29:22 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_IPAC_PDCH_ACT_NACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s IPAC PDCH ACT NACK\n", ts_name);
|
2009-10-24 08:29:22 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_IPAC_PDCH_DEACT_ACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC PDCH DEACT ACK\n", ts_name);
|
2013-10-11 11:32:30 +00:00
|
|
|
rc = rsl_rx_pdch_deact_ack(msg);
|
2009-10-24 08:29:22 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_IPAC_PDCH_DEACT_NACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s IPAC PDCH DEACT NACK\n", ts_name);
|
2009-10-24 08:29:22 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_PHY_CONTEXT_CONF:
|
|
|
|
case RSL_MT_PREPROC_MEAS_RES:
|
|
|
|
case RSL_MT_TALKER_DET:
|
|
|
|
case RSL_MT_LISTENER_DET:
|
|
|
|
case RSL_MT_REMOTE_CODEC_CONF_REP:
|
|
|
|
case RSL_MT_MR_CODEC_MOD_ACK:
|
|
|
|
case RSL_MT_MR_CODEC_MOD_NACK:
|
|
|
|
case RSL_MT_MR_CODEC_MOD_PER:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s Unimplemented Abis RSL DChan "
|
|
|
|
"msg 0x%02x\n", ts_name, rslh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s unknown Abis RSL DChan msg 0x%02x\n",
|
|
|
|
ts_name, rslh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-02-19 17:07:39 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-26 20:25:35 +00:00
|
|
|
static int rsl_rx_error_rep(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
|
2009-07-28 15:58:09 +00:00
|
|
|
struct tlv_parsed tp;
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2008-12-26 20:25:35 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s ERROR REPORT ", gsm_trx_name(sign_link->trx));
|
2009-07-28 15:58:09 +00:00
|
|
|
|
|
|
|
rsl_tlv_parse(&tp, rslh->data, msgb_l2len(msg)-sizeof(*rslh));
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(&tp, RSL_IE_CAUSE))
|
2009-12-24 11:20:20 +00:00
|
|
|
print_rsl_cause(LOGL_ERROR, TLVP_VAL(&tp, RSL_IE_CAUSE),
|
2009-07-28 15:58:09 +00:00
|
|
|
TLVP_LEN(&tp, RSL_IE_CAUSE));
|
|
|
|
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGPC(DRSL, LOGL_ERROR, "\n");
|
2008-12-26 20:25:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
static int abis_rsl_rx_trx(struct msgb *msg)
|
|
|
|
{
|
2008-12-26 20:25:35 +00:00
|
|
|
struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2008-12-25 23:28:35 +00:00
|
|
|
int rc = 0;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
switch (rslh->msg_type) {
|
2008-12-26 20:25:35 +00:00
|
|
|
case RSL_MT_ERROR_REPORT:
|
|
|
|
rc = rsl_rx_error_rep(msg);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_RF_RES_IND:
|
|
|
|
/* interference on idle channels of TRX */
|
2011-08-17 20:43:54 +00:00
|
|
|
//DEBUGP(DRSL, "%s RF Resource Indication\n", gsm_trx_name(sign_link->trx));
|
2009-02-03 12:57:37 +00:00
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_OVERLOAD:
|
2010-03-29 06:47:44 +00:00
|
|
|
/* indicate CCCH / ACCH / processor overload */
|
2009-12-28 22:14:22 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s CCCH/ACCH/CPU Overload\n",
|
2011-08-17 20:43:54 +00:00
|
|
|
gsm_trx_name(sign_link->trx));
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
2011-07-27 22:01:50 +00:00
|
|
|
case 0x42: /* Nokia specific: SI End ACK */
|
|
|
|
LOGP(DRSL, LOGL_INFO, "Nokia SI End ACK\n");
|
|
|
|
break;
|
|
|
|
case 0x43: /* Nokia specific: SI End NACK */
|
|
|
|
LOGP(DRSL, LOGL_INFO, "Nokia SI End NACK\n");
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
default:
|
2009-12-28 22:14:22 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s Unknown Abis RSL TRX message "
|
2011-08-17 20:43:54 +00:00
|
|
|
"type 0x%02x\n", gsm_trx_name(sign_link->trx), rslh->msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-12-25 23:28:35 +00:00
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2009-08-09 22:26:10 +00:00
|
|
|
/* If T3101 expires, we never received a response to IMMEDIATE ASSIGN */
|
|
|
|
static void t3101_expired(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
|
2011-12-28 15:21:05 +00:00
|
|
|
rsl_rf_chan_release(lchan, 1, SACCH_DEACTIVATE);
|
2009-08-09 22:26:10 +00:00
|
|
|
}
|
|
|
|
|
2010-05-31 13:33:15 +00:00
|
|
|
/* If T3111 expires, we will send the RF Channel Request */
|
|
|
|
static void t3111_expired(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
|
2011-12-28 15:21:05 +00:00
|
|
|
rsl_rf_chan_release(lchan, 0, SACCH_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If T3109 expires the MS has not send a UA/UM do the error release */
|
|
|
|
static void t3109_expired(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_lchan *lchan = data;
|
|
|
|
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s SACCH deactivation timeout.\n", gsm_lchan_name(lchan));
|
|
|
|
rsl_rf_chan_release(lchan, 1, SACCH_NONE);
|
2010-05-31 13:33:15 +00:00
|
|
|
}
|
|
|
|
|
2010-12-23 13:39:29 +00:00
|
|
|
/* Format an IMM ASS REJ according to 04.08 Chapter 9.1.20 */
|
|
|
|
static int rsl_send_imm_ass_rej(struct gsm_bts *bts,
|
|
|
|
unsigned int num_req_refs,
|
|
|
|
struct gsm48_req_ref *rqd_refs,
|
|
|
|
uint8_t wait_ind)
|
|
|
|
{
|
|
|
|
uint8_t buf[GSM_MACBLOCK_LEN];
|
|
|
|
struct gsm48_imm_ass_rej *iar = (struct gsm48_imm_ass_rej *)buf;
|
|
|
|
|
|
|
|
/* create IMMEDIATE ASSIGN REJECT 04.08 message */
|
|
|
|
memset(iar, 0, sizeof(*iar));
|
|
|
|
iar->proto_discr = GSM48_PDISC_RR;
|
2013-02-07 10:51:16 +00:00
|
|
|
iar->msg_type = GSM48_MT_RR_IMM_ASS_REJ;
|
2010-12-23 13:39:29 +00:00
|
|
|
iar->page_mode = GSM48_PM_SAME;
|
|
|
|
|
|
|
|
memcpy(&iar->req_ref1, &rqd_refs[0], sizeof(iar->req_ref1));
|
|
|
|
iar->wait_ind1 = wait_ind;
|
|
|
|
|
|
|
|
if (num_req_refs >= 2)
|
|
|
|
memcpy(&iar->req_ref2, &rqd_refs[1], sizeof(iar->req_ref2));
|
|
|
|
else
|
|
|
|
memcpy(&iar->req_ref2, &rqd_refs[0], sizeof(iar->req_ref2));
|
|
|
|
iar->wait_ind2 = wait_ind;
|
|
|
|
|
|
|
|
if (num_req_refs >= 3)
|
|
|
|
memcpy(&iar->req_ref3, &rqd_refs[2], sizeof(iar->req_ref3));
|
|
|
|
else
|
|
|
|
memcpy(&iar->req_ref3, &rqd_refs[0], sizeof(iar->req_ref3));
|
|
|
|
iar->wait_ind3 = wait_ind;
|
|
|
|
|
|
|
|
if (num_req_refs >= 4)
|
|
|
|
memcpy(&iar->req_ref4, &rqd_refs[3], sizeof(iar->req_ref4));
|
|
|
|
else
|
|
|
|
memcpy(&iar->req_ref4, &rqd_refs[0], sizeof(iar->req_ref4));
|
|
|
|
iar->wait_ind4 = wait_ind;
|
|
|
|
|
2013-02-07 10:51:16 +00:00
|
|
|
/* we need to subtract 1 byte from sizeof(*iar) since ia includes the l2_plen field */
|
|
|
|
iar->l2_plen = GSM48_LEN2PLEN((sizeof(*iar)-1));
|
|
|
|
|
|
|
|
return rsl_imm_assign_cmd(bts, sizeof(*iar), (uint8_t *) iar);
|
2010-12-23 13:39:29 +00:00
|
|
|
}
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
/* MS has requested a channel on the RACH */
|
2008-12-23 20:25:15 +00:00
|
|
|
static int rsl_rx_chan_rqd(struct msgb *msg)
|
|
|
|
{
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
|
|
|
struct gsm_bts *bts = sign_link->trx->bts;
|
2008-12-25 23:28:35 +00:00
|
|
|
struct abis_rsl_dchan_hdr *rqd_hdr = msgb_l2(msg);
|
|
|
|
struct gsm48_req_ref *rqd_ref;
|
|
|
|
enum gsm_chan_t lctype;
|
2008-12-29 04:09:31 +00:00
|
|
|
enum gsm_chreq_reason_t chreq_reason;
|
2008-12-25 23:28:35 +00:00
|
|
|
struct gsm_lchan *lchan;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t rqd_ta;
|
2010-09-06 00:58:42 +00:00
|
|
|
int is_lu;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
uint16_t arfcn;
|
2012-02-03 19:10:13 +00:00
|
|
|
uint8_t subch;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
/* parse request reference to be used in immediate assign */
|
|
|
|
if (rqd_hdr->data[0] != RSL_IE_REQ_REFERENCE)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
rqd_ref = (struct gsm48_req_ref *) &rqd_hdr->data[1];
|
|
|
|
|
|
|
|
/* parse access delay and use as TA */
|
|
|
|
if (rqd_hdr->data[sizeof(struct gsm48_req_ref)+1] != RSL_IE_ACCESS_DELAY)
|
|
|
|
return -EINVAL;
|
|
|
|
rqd_ta = rqd_hdr->data[sizeof(struct gsm48_req_ref)+2];
|
|
|
|
|
|
|
|
/* determine channel type (SDCCH/TCH_F/TCH_H) based on
|
|
|
|
* request reference RA */
|
2010-09-06 01:36:02 +00:00
|
|
|
lctype = get_ctype_by_chreq(bts->network, rqd_ref->ra);
|
|
|
|
chreq_reason = get_reason_by_chreq(rqd_ref->ra, bts->network->neci);
|
2008-12-29 04:09:31 +00:00
|
|
|
|
2016-08-02 09:34:11 +00:00
|
|
|
rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CHREQ_TOTAL]);
|
2009-12-21 23:41:05 +00:00
|
|
|
|
2010-09-06 00:58:42 +00:00
|
|
|
/*
|
|
|
|
* We want LOCATION UPDATES to succeed and will assign a TCH
|
|
|
|
* if we have no SDCCH available.
|
|
|
|
*/
|
|
|
|
is_lu = !!(chreq_reason == GSM_CHREQ_REASON_LOCATION_UPD);
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
/* check availability / allocate channel */
|
2010-09-06 00:58:42 +00:00
|
|
|
lchan = lchan_alloc(bts, lctype, is_lu);
|
2008-12-25 23:28:35 +00:00
|
|
|
if (!lchan) {
|
2009-12-27 12:48:09 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "BTS %d CHAN RQD: no resources for %s 0x%x\n",
|
2009-12-27 17:05:25 +00:00
|
|
|
msg->lchan->ts->trx->bts->nr, gsm_lchant_name(lctype), rqd_ref->ra);
|
2016-08-02 09:34:11 +00:00
|
|
|
rate_ctr_inc(&bts->network->bsc_ctrs->ctr[BSC_CTR_CHREQ_NO_CHANNEL]);
|
2010-12-23 13:39:29 +00:00
|
|
|
/* FIXME gather multiple CHAN RQD and reject up to 4 at the same time */
|
|
|
|
if (bts->network->T3122)
|
|
|
|
rsl_send_imm_ass_rej(bts, 1, rqd_ref, bts->network->T3122 & 0xff);
|
2012-11-13 03:46:03 +00:00
|
|
|
return 0;
|
2008-12-25 23:28:35 +00:00
|
|
|
}
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
/*
|
|
|
|
* Expecting lchan state to be NONE, except for dyn TS in PDCH mode.
|
|
|
|
* Those are expected to be ACTIVE: the PDCH release will be sent from
|
|
|
|
* rsl_chan_activate_lchan() below.
|
|
|
|
*/
|
|
|
|
if (lchan->state != LCHAN_S_NONE
|
|
|
|
&& !(lchan->ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH
|
|
|
|
&& lchan->ts->dyn.pchan_is == GSM_PCHAN_PDCH
|
|
|
|
&& lchan->state == LCHAN_S_ACTIVE))
|
2009-12-29 09:44:17 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "%s lchan_alloc() returned channel "
|
2009-12-29 09:52:38 +00:00
|
|
|
"in state %s\n", gsm_lchan_name(lchan),
|
|
|
|
gsm_lchans_name(lchan->state));
|
2009-12-27 17:12:29 +00:00
|
|
|
|
2010-06-22 04:11:59 +00:00
|
|
|
/* save the RACH data as we need it after the CHAN ACT ACK */
|
|
|
|
lchan->rqd_ref = talloc_zero(bts, struct gsm48_req_ref);
|
|
|
|
if (!lchan->rqd_ref) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR, "Failed to allocate gsm48_req_ref.\n");
|
|
|
|
lchan_free(lchan);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(lchan->rqd_ref, rqd_ref, sizeof(*rqd_ref));
|
|
|
|
lchan->rqd_ta = rqd_ta;
|
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
arfcn = lchan->ts->trx->arfcn;
|
|
|
|
subch = lchan->nr;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2009-08-30 06:37:11 +00:00
|
|
|
lchan->encr.alg_id = RSL_ENC_ALG_A5(0); /* no encryption */
|
2009-08-13 08:14:26 +00:00
|
|
|
lchan->ms_power = ms_pwr_ctl_lvl(bts->band, bts->ms_max_power);
|
2009-08-09 22:45:40 +00:00
|
|
|
lchan->bs_power = 0; /* 0dB reduction, output power = Pn */
|
2009-07-29 13:41:29 +00:00
|
|
|
lchan->rsl_cmode = RSL_CMOD_SPD_SIGN;
|
2009-08-28 14:28:28 +00:00
|
|
|
lchan->tch_mode = GSM48_CMODE_SIGN;
|
2010-06-22 04:11:59 +00:00
|
|
|
|
2011-08-10 21:26:33 +00:00
|
|
|
/* Start another timer or assume the BTS sends a ACK/NACK? */
|
|
|
|
lchan->act_timer.cb = lchan_act_tmr_cb;
|
|
|
|
lchan->act_timer.data = lchan;
|
|
|
|
osmo_timer_schedule(&lchan->act_timer, 4, 0);
|
|
|
|
|
2010-06-22 04:11:59 +00:00
|
|
|
DEBUGP(DRSL, "%s Activating ARFCN(%u) SS(%u) lctype %s "
|
2011-12-16 16:45:37 +00:00
|
|
|
"r=%s ra=0x%02x ta=%d\n", gsm_lchan_name(lchan), arfcn, subch,
|
2010-06-22 04:11:59 +00:00
|
|
|
gsm_lchant_name(lchan->type), gsm_chreq_name(chreq_reason),
|
2011-12-16 16:45:37 +00:00
|
|
|
rqd_ref->ra, rqd_ta);
|
|
|
|
|
2016-07-14 23:26:03 +00:00
|
|
|
rsl_chan_activate_lchan(lchan, RSL_ACT_INTRA_IMM_ASS, 0);
|
2011-12-16 16:45:37 +00:00
|
|
|
|
2010-06-22 04:11:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rsl_send_imm_assignment(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts = lchan->ts->trx->bts;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t buf[GSM_MACBLOCK_LEN];
|
2010-06-22 04:11:59 +00:00
|
|
|
struct gsm48_imm_ass *ia = (struct gsm48_imm_ass *) buf;
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* create IMMEDIATE ASSIGN 04.08 messge */
|
2010-06-20 13:18:46 +00:00
|
|
|
memset(ia, 0, sizeof(*ia));
|
2010-06-21 10:08:52 +00:00
|
|
|
/* we set ia->l2_plen once we know the length of the MA below */
|
2010-06-20 13:18:46 +00:00
|
|
|
ia->proto_discr = GSM48_PDISC_RR;
|
|
|
|
ia->msg_type = GSM48_MT_RR_IMM_ASS;
|
|
|
|
ia->page_mode = GSM48_PM_SAME;
|
|
|
|
gsm48_lchan2chan_desc(&ia->chan_desc, lchan);
|
2010-06-14 20:26:10 +00:00
|
|
|
|
2008-12-25 23:28:35 +00:00
|
|
|
/* use request reference extracted from CHAN_RQD */
|
2010-06-22 04:11:59 +00:00
|
|
|
memcpy(&ia->req_ref, lchan->rqd_ref, sizeof(ia->req_ref));
|
|
|
|
ia->timing_advance = lchan->rqd_ta;
|
2010-06-14 20:26:10 +00:00
|
|
|
if (!lchan->ts->hopping.enabled) {
|
2010-06-20 13:18:46 +00:00
|
|
|
ia->mob_alloc_len = 0;
|
2010-06-14 20:26:10 +00:00
|
|
|
} else {
|
2010-06-20 13:18:46 +00:00
|
|
|
ia->mob_alloc_len = lchan->ts->hopping.ma_len;
|
|
|
|
memcpy(ia->mob_alloc, lchan->ts->hopping.ma_data, ia->mob_alloc_len);
|
2010-06-14 20:26:10 +00:00
|
|
|
}
|
2010-06-28 16:41:27 +00:00
|
|
|
/* we need to subtract 1 byte from sizeof(*ia) since ia includes the l2_plen field */
|
|
|
|
ia->l2_plen = GSM48_LEN2PLEN((sizeof(*ia)-1) + ia->mob_alloc_len);
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2009-08-09 22:26:10 +00:00
|
|
|
/* Start timer T3101 to wait for GSM48_MT_RR_PAG_RESP */
|
|
|
|
lchan->T3101.cb = t3101_expired;
|
|
|
|
lchan->T3101.data = lchan;
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&lchan->T3101, bts->network->T3101, 0);
|
2008-12-29 06:23:49 +00:00
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* send IMMEDIATE ASSIGN CMD on RSL to BTS (to send on CCCH to MS) */
|
2011-04-18 15:04:00 +00:00
|
|
|
return rsl_imm_assign_cmd(bts, sizeof(*ia)+ia->mob_alloc_len, (uint8_t *) ia);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 19:26:25 +00:00
|
|
|
/* current load on the CCCH */
|
2009-02-02 22:29:56 +00:00
|
|
|
static int rsl_rx_ccch_load(struct msgb *msg)
|
|
|
|
{
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2009-02-02 22:29:56 +00:00
|
|
|
struct abis_rsl_dchan_hdr *rslh = msgb_l2(msg);
|
2012-02-03 19:26:25 +00:00
|
|
|
struct ccch_signal_data sd;
|
|
|
|
|
|
|
|
sd.bts = sign_link->trx->bts;
|
|
|
|
sd.rach_slot_count = -1;
|
|
|
|
sd.rach_busy_count = -1;
|
|
|
|
sd.rach_access_count = -1;
|
2009-02-02 22:29:56 +00:00
|
|
|
|
|
|
|
switch (rslh->data[0]) {
|
|
|
|
case RSL_IE_PAGING_LOAD:
|
2012-02-03 19:26:25 +00:00
|
|
|
sd.pg_buf_space = rslh->data[1] << 8 | rslh->data[2];
|
|
|
|
if (is_ipaccess_bts(sign_link->trx->bts) && sd.pg_buf_space == 0xffff) {
|
2010-04-19 08:24:07 +00:00
|
|
|
/* paging load below configured threshold, use 50 as default */
|
2012-02-03 19:26:25 +00:00
|
|
|
sd.pg_buf_space = 50;
|
2010-04-19 08:24:07 +00:00
|
|
|
}
|
2012-02-03 19:26:25 +00:00
|
|
|
paging_update_buffer_space(sign_link->trx->bts, sd.pg_buf_space);
|
|
|
|
osmo_signal_dispatch(SS_CCCH, S_CCCH_PAGING_LOAD, &sd);
|
2009-02-02 22:29:56 +00:00
|
|
|
break;
|
|
|
|
case RSL_IE_RACH_LOAD:
|
2009-02-03 20:08:51 +00:00
|
|
|
if (msg->data_len >= 7) {
|
2012-02-03 19:26:25 +00:00
|
|
|
sd.rach_slot_count = rslh->data[2] << 8 | rslh->data[3];
|
|
|
|
sd.rach_busy_count = rslh->data[4] << 8 | rslh->data[5];
|
|
|
|
sd.rach_access_count = rslh->data[6] << 8 | rslh->data[7];
|
|
|
|
osmo_signal_dispatch(SS_CCCH, S_CCCH_RACH_LOAD, &sd);
|
2009-02-03 20:08:51 +00:00
|
|
|
}
|
2009-02-02 22:29:56 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
static int abis_rsl_rx_cchan(struct msgb *msg)
|
|
|
|
{
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2009-02-02 22:29:56 +00:00
|
|
|
struct abis_rsl_dchan_hdr *rslh = msgb_l2(msg);
|
2008-12-25 23:28:35 +00:00
|
|
|
int rc = 0;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2016-08-22 23:22:58 +00:00
|
|
|
msg->lchan = lchan_lookup(sign_link->trx, rslh->chan_nr,
|
|
|
|
"Abis RSL rx CCHAN: ");
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
switch (rslh->c.msg_type) {
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_CHAN_RQD:
|
|
|
|
/* MS has requested a channel on the RACH */
|
|
|
|
rc = rsl_rx_chan_rqd(msg);
|
|
|
|
break;
|
2009-02-02 22:29:56 +00:00
|
|
|
case RSL_MT_CCCH_LOAD_IND:
|
|
|
|
/* current load on the CCCH */
|
|
|
|
rc = rsl_rx_ccch_load(msg);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_DELETE_IND:
|
|
|
|
/* CCCH overloaded, IMM_ASSIGN was dropped */
|
|
|
|
case RSL_MT_CBCH_LOAD_IND:
|
|
|
|
/* current load on the CBCH */
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "Unimplemented Abis RSL TRX message "
|
|
|
|
"type 0x%02x\n", rslh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "Unknown Abis RSL TRX message type "
|
|
|
|
"0x%02x\n", rslh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2008-12-25 23:28:35 +00:00
|
|
|
|
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2008-12-27 01:55:51 +00:00
|
|
|
static int rsl_rx_rll_err_ind(struct msgb *msg)
|
|
|
|
{
|
2013-01-16 20:07:43 +00:00
|
|
|
struct tlv_parsed tp;
|
2008-12-27 01:55:51 +00:00
|
|
|
struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
|
2013-01-16 20:07:43 +00:00
|
|
|
uint8_t rlm_cause;
|
|
|
|
|
|
|
|
rsl_tlv_parse(&tp, rllh->data, msgb_l2len(msg) - sizeof(*rllh));
|
|
|
|
if (!TLVP_PRESENT(&tp, RSL_IE_RLM_CAUSE)) {
|
|
|
|
LOGP(DRLL, LOGL_ERROR,
|
|
|
|
"%s ERROR INDICATION without mandantory cause.\n",
|
|
|
|
gsm_lchan_name(msg->lchan));
|
|
|
|
return -1;
|
|
|
|
}
|
2008-12-27 01:55:51 +00:00
|
|
|
|
2013-01-16 20:07:43 +00:00
|
|
|
rlm_cause = *TLVP_VAL(&tp, RSL_IE_RLM_CAUSE);
|
2014-04-19 14:45:36 +00:00
|
|
|
LOGP(DRLL, LOGL_ERROR, "%s ERROR INDICATION cause=%s in state=%s\n",
|
2009-12-27 17:16:36 +00:00
|
|
|
gsm_lchan_name(msg->lchan),
|
2014-04-19 14:45:36 +00:00
|
|
|
rsl_rlm_cause_name(rlm_cause),
|
|
|
|
gsm_lchans_name(msg->lchan->state));
|
|
|
|
|
2009-08-09 11:47:35 +00:00
|
|
|
rll_indication(msg->lchan, rllh->link_id, BSC_RLLR_IND_ERR_IND);
|
2009-12-26 22:55:00 +00:00
|
|
|
|
2013-01-16 20:07:43 +00:00
|
|
|
if (rlm_cause == RLL_CAUSE_T200_EXPIRED) {
|
2016-08-02 09:34:11 +00:00
|
|
|
rate_ctr_inc(&msg->lchan->ts->trx->bts->network->bsc_ctrs->ctr[BSC_CTR_CHAN_RLL_ERR]);
|
2014-04-19 15:38:33 +00:00
|
|
|
return rsl_rf_chan_release_err(msg->lchan);
|
2010-04-17 04:48:29 +00:00
|
|
|
}
|
2009-07-04 07:40:05 +00:00
|
|
|
|
2008-12-27 01:55:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-02-19 17:07:39 +00:00
|
|
|
|
2010-04-08 20:39:34 +00:00
|
|
|
static void rsl_handle_release(struct gsm_lchan *lchan)
|
|
|
|
{
|
2010-07-29 09:09:36 +00:00
|
|
|
int sapi;
|
2010-05-31 13:33:15 +00:00
|
|
|
struct gsm_bts *bts;
|
2010-07-29 09:09:36 +00:00
|
|
|
|
2011-12-28 11:11:40 +00:00
|
|
|
/*
|
|
|
|
* Maybe only one link/SAPI was releasd or the error handling
|
|
|
|
* was activated. Just return now and let the other code handle
|
|
|
|
* it.
|
|
|
|
*/
|
2010-04-08 20:47:44 +00:00
|
|
|
if (lchan->state != LCHAN_S_REL_REQ)
|
2010-07-29 09:09:36 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
for (sapi = 0; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) {
|
|
|
|
if (lchan->sapis[sapi] == LCHAN_SAPI_UNUSED)
|
|
|
|
continue;
|
2010-12-24 11:51:07 +00:00
|
|
|
LOGP(DRSL, LOGL_DEBUG, "%s waiting for SAPI=%d to be released.\n",
|
2010-07-29 09:09:36 +00:00
|
|
|
gsm_lchan_name(lchan), sapi);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-08 20:47:44 +00:00
|
|
|
|
2011-12-28 15:21:05 +00:00
|
|
|
/* Stop T3109 and wait for T3111 before re-using the channel */
|
|
|
|
osmo_timer_del(&lchan->T3109);
|
2010-05-31 13:33:15 +00:00
|
|
|
lchan->T3111.cb = t3111_expired;
|
|
|
|
lchan->T3111.data = lchan;
|
|
|
|
bts = lchan->ts->trx->bts;
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&lchan->T3111, bts->network->T3111, 0);
|
2010-04-08 20:39:34 +00:00
|
|
|
}
|
|
|
|
|
2010-03-29 06:47:44 +00:00
|
|
|
/* ESTABLISH INDICATION, LOCATION AREA UPDATE REQUEST
|
2008-12-23 20:25:15 +00:00
|
|
|
0x02, 0x06,
|
|
|
|
0x01, 0x20,
|
|
|
|
0x02, 0x00,
|
|
|
|
0x0b, 0x00, 0x0f, 0x05, 0x08, ... */
|
|
|
|
|
|
|
|
static int abis_rsl_rx_rll(struct msgb *msg)
|
|
|
|
{
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2008-12-23 20:25:15 +00:00
|
|
|
struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
|
2009-02-19 17:07:39 +00:00
|
|
|
int rc = 0;
|
|
|
|
char *ts_name;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t sapi = rllh->link_id & 7;
|
2008-12-25 23:28:35 +00:00
|
|
|
|
2016-08-22 23:22:58 +00:00
|
|
|
msg->lchan = lchan_lookup(sign_link->trx, rllh->chan_nr,
|
|
|
|
"Abis RSL rx RLL: ");
|
2009-12-27 17:16:36 +00:00
|
|
|
ts_name = gsm_lchan_name(msg->lchan);
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRLL, "%s SAPI=%u ", ts_name, sapi);
|
2008-12-23 20:25:15 +00:00
|
|
|
|
|
|
|
switch (rllh->c.msg_type) {
|
|
|
|
case RSL_MT_DATA_IND:
|
2009-02-19 17:07:39 +00:00
|
|
|
DEBUGPC(DRLL, "DATA INDICATION\n");
|
2010-03-29 06:47:44 +00:00
|
|
|
if (msgb_l2len(msg) >
|
2009-02-28 13:17:55 +00:00
|
|
|
sizeof(struct abis_rsl_common_hdr) + sizeof(*rllh) &&
|
|
|
|
rllh->data[0] == RSL_IE_L3_INFO) {
|
|
|
|
msg->l3h = &rllh->data[3];
|
2009-08-14 09:41:12 +00:00
|
|
|
return gsm0408_rcvmsg(msg, rllh->link_id);
|
2009-02-28 13:17:55 +00:00
|
|
|
}
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_EST_IND:
|
2009-02-19 17:07:39 +00:00
|
|
|
DEBUGPC(DRLL, "ESTABLISH INDICATION\n");
|
2009-08-09 22:26:10 +00:00
|
|
|
/* lchan is established, stop T3101 */
|
2009-10-28 13:23:39 +00:00
|
|
|
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_MS;
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_del(&msg->lchan->T3101);
|
2010-03-29 06:47:44 +00:00
|
|
|
if (msgb_l2len(msg) >
|
2009-02-28 13:17:55 +00:00
|
|
|
sizeof(struct abis_rsl_common_hdr) + sizeof(*rllh) &&
|
|
|
|
rllh->data[0] == RSL_IE_L3_INFO) {
|
|
|
|
msg->l3h = &rllh->data[3];
|
2009-08-14 09:41:12 +00:00
|
|
|
return gsm0408_rcvmsg(msg, rllh->link_id);
|
2009-02-28 13:17:55 +00:00
|
|
|
}
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
2009-08-09 11:47:35 +00:00
|
|
|
case RSL_MT_EST_CONF:
|
2009-08-09 12:13:58 +00:00
|
|
|
DEBUGPC(DRLL, "ESTABLISH CONFIRM\n");
|
2009-10-28 13:23:39 +00:00
|
|
|
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_NET;
|
2009-08-09 11:47:35 +00:00
|
|
|
rll_indication(msg->lchan, rllh->link_id,
|
|
|
|
BSC_RLLR_IND_EST_CONF);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_REL_IND:
|
2009-08-08 11:15:07 +00:00
|
|
|
/* BTS informs us of having received DISC from MS */
|
2009-08-04 00:50:21 +00:00
|
|
|
DEBUGPC(DRLL, "RELEASE INDICATION\n");
|
2009-10-28 13:23:39 +00:00
|
|
|
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_UNUSED;
|
2009-08-09 11:47:35 +00:00
|
|
|
rll_indication(msg->lchan, rllh->link_id,
|
|
|
|
BSC_RLLR_IND_REL_IND);
|
2010-04-08 20:39:34 +00:00
|
|
|
rsl_handle_release(msg->lchan);
|
2008-12-27 19:46:06 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_REL_CONF:
|
2009-08-08 11:15:07 +00:00
|
|
|
/* BTS informs us of having received UA from MS,
|
|
|
|
* in response to DISC that we've sent earlier */
|
2009-08-04 00:50:21 +00:00
|
|
|
DEBUGPC(DRLL, "RELEASE CONFIRMATION\n");
|
2009-10-28 13:23:39 +00:00
|
|
|
msg->lchan->sapis[rllh->link_id & 0x7] = LCHAN_SAPI_UNUSED;
|
2010-04-08 20:39:34 +00:00
|
|
|
rsl_handle_release(msg->lchan);
|
2008-12-27 01:55:51 +00:00
|
|
|
break;
|
|
|
|
case RSL_MT_ERROR_IND:
|
2016-07-26 17:39:43 +00:00
|
|
|
DEBUGPC(DRLL, "ERROR INDICATION\n");
|
2008-12-27 01:55:51 +00:00
|
|
|
rc = rsl_rx_rll_err_ind(msg);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case RSL_MT_UNIT_DATA_IND:
|
2016-07-26 17:39:43 +00:00
|
|
|
DEBUGPC(DRLL, "UNIT DATA INDICATION\n");
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRLL, LOGL_NOTICE, "unimplemented Abis RLL message "
|
|
|
|
"type 0x%02x\n", rllh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
break;
|
|
|
|
default:
|
2016-07-26 17:39:43 +00:00
|
|
|
DEBUGPC(DRLL, "UNKNOWN\n");
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRLL, LOGL_NOTICE, "unknown Abis RLL message "
|
|
|
|
"type 0x%02x\n", rllh->c.msg_type);
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
2008-12-25 23:28:35 +00:00
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static uint8_t ipa_smod_s_for_lchan(struct gsm_lchan *lchan)
|
2009-07-28 16:11:56 +00:00
|
|
|
{
|
2009-12-01 20:28:23 +00:00
|
|
|
switch (lchan->tch_mode) {
|
2009-07-28 16:11:56 +00:00
|
|
|
case GSM48_CMODE_SPEECH_V1:
|
2009-12-01 20:28:23 +00:00
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return 0x00;
|
|
|
|
case GSM_LCHAN_TCH_H:
|
|
|
|
return 0x03;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-07-28 16:11:56 +00:00
|
|
|
case GSM48_CMODE_SPEECH_EFR:
|
2009-12-01 20:28:23 +00:00
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return 0x01;
|
|
|
|
/* there's no half-rate EFR */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-07-28 16:11:56 +00:00
|
|
|
case GSM48_CMODE_SPEECH_AMR:
|
2009-12-01 20:28:23 +00:00
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return 0x02;
|
|
|
|
case GSM_LCHAN_TCH_H:
|
|
|
|
return 0x05;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-12-01 20:28:23 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-07-28 16:11:56 +00:00
|
|
|
}
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "Cannot determine ip.access speech mode for "
|
2009-12-01 20:28:23 +00:00
|
|
|
"tch_mode == 0x%02x\n", lchan->tch_mode);
|
2009-07-28 16:11:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
static uint8_t ipa_rtp_pt_for_lchan(struct gsm_lchan *lchan)
|
2009-12-20 21:06:40 +00:00
|
|
|
{
|
|
|
|
switch (lchan->tch_mode) {
|
|
|
|
case GSM48_CMODE_SPEECH_V1:
|
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return RTP_PT_GSM_FULL;
|
|
|
|
case GSM_LCHAN_TCH_H:
|
|
|
|
return RTP_PT_GSM_HALF;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-12-20 21:06:40 +00:00
|
|
|
case GSM48_CMODE_SPEECH_EFR:
|
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
return RTP_PT_GSM_EFR;
|
|
|
|
/* there's no half-rate EFR */
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-12-20 21:06:40 +00:00
|
|
|
case GSM48_CMODE_SPEECH_AMR:
|
|
|
|
switch (lchan->type) {
|
|
|
|
case GSM_LCHAN_TCH_F:
|
|
|
|
case GSM_LCHAN_TCH_H:
|
2011-07-21 08:24:46 +00:00
|
|
|
return RTP_PT_AMR;
|
2009-12-20 21:06:40 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2014-04-04 10:14:55 +00:00
|
|
|
break;
|
2009-12-20 21:06:40 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LOGP(DRSL, LOGL_ERROR, "Cannot determine ip.access rtp payload type for "
|
|
|
|
"tch_mode == 0x%02x\n & lchan_type == %d",
|
|
|
|
lchan->tch_mode, lchan->type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-16 21:12:08 +00:00
|
|
|
/* ip.access specific RSL extensions */
|
2009-12-19 15:42:06 +00:00
|
|
|
static void ipac_parse_rtp(struct gsm_lchan *lchan, struct tlv_parsed *tv)
|
|
|
|
{
|
|
|
|
struct in_addr ip;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint16_t port, conn_id;
|
2009-12-19 15:42:06 +00:00
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_LOCAL_IP)) {
|
2014-06-27 15:05:47 +00:00
|
|
|
ip.s_addr = tlvp_val32_unal(tv, RSL_IE_IPAC_LOCAL_IP);
|
2009-12-19 15:42:06 +00:00
|
|
|
DEBUGPC(DRSL, "LOCAL_IP=%s ", inet_ntoa(ip));
|
|
|
|
lchan->abis_ip.bound_ip = ntohl(ip.s_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_LOCAL_PORT)) {
|
2014-06-27 15:05:47 +00:00
|
|
|
port = tlvp_val16_unal(tv, RSL_IE_IPAC_LOCAL_PORT);
|
2009-12-19 15:42:06 +00:00
|
|
|
port = ntohs(port);
|
|
|
|
DEBUGPC(DRSL, "LOCAL_PORT=%u ", port);
|
|
|
|
lchan->abis_ip.bound_port = port;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_CONN_ID)) {
|
2014-06-27 15:05:47 +00:00
|
|
|
conn_id = tlvp_val16_unal(tv, RSL_IE_IPAC_CONN_ID);
|
2009-12-19 15:42:06 +00:00
|
|
|
conn_id = ntohs(conn_id);
|
|
|
|
DEBUGPC(DRSL, "CON_ID=%u ", conn_id);
|
|
|
|
lchan->abis_ip.conn_id = conn_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_RTP_PAYLOAD2)) {
|
|
|
|
lchan->abis_ip.rtp_payload2 =
|
|
|
|
*TLVP_VAL(tv, RSL_IE_IPAC_RTP_PAYLOAD2);
|
|
|
|
DEBUGPC(DRSL, "RTP_PAYLOAD2=0x%02x ",
|
|
|
|
lchan->abis_ip.rtp_payload2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_SPEECH_MODE)) {
|
|
|
|
lchan->abis_ip.speech_mode =
|
|
|
|
*TLVP_VAL(tv, RSL_IE_IPAC_SPEECH_MODE);
|
|
|
|
DEBUGPC(DRSL, "speech_mode=0x%02x ",
|
|
|
|
lchan->abis_ip.speech_mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_REMOTE_IP)) {
|
2014-06-27 15:05:47 +00:00
|
|
|
ip.s_addr = tlvp_val32_unal(tv, RSL_IE_IPAC_REMOTE_IP);
|
2009-12-19 15:42:06 +00:00
|
|
|
DEBUGPC(DRSL, "REMOTE_IP=%s ", inet_ntoa(ip));
|
|
|
|
lchan->abis_ip.connect_ip = ntohl(ip.s_addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TLVP_PRESENT(tv, RSL_IE_IPAC_REMOTE_PORT)) {
|
2014-06-27 15:05:47 +00:00
|
|
|
port = tlvp_val16_unal(tv, RSL_IE_IPAC_REMOTE_PORT);
|
2009-12-19 15:42:06 +00:00
|
|
|
port = ntohs(port);
|
|
|
|
DEBUGPC(DRSL, "REMOTE_PORT=%u ", port);
|
|
|
|
lchan->abis_ip.connect_port = port;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-03 11:06:58 +00:00
|
|
|
/*! \brief Issue IPA RSL CRCX to configure RTP on BTS side
|
|
|
|
* \param[in] lchan Logical Channel for which we issue CRCX
|
|
|
|
*/
|
2009-11-18 20:06:12 +00:00
|
|
|
int rsl_ipacc_crcx(struct gsm_lchan *lchan)
|
2009-02-16 21:12:08 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
2009-11-18 20:06:12 +00:00
|
|
|
init_dchan_hdr(dh, RSL_MT_IPAC_CRCX);
|
2009-02-16 21:12:08 +00:00
|
|
|
dh->c.msg_discr = ABIS_RSL_MDISC_IPACCESS;
|
2011-06-25 08:02:33 +00:00
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2009-07-28 16:11:56 +00:00
|
|
|
/* 0x1- == receive-only, 0x-1 == EFR codec */
|
2009-12-19 15:42:06 +00:00
|
|
|
lchan->abis_ip.speech_mode = 0x10 | ipa_smod_s_for_lchan(lchan);
|
2009-12-20 21:06:40 +00:00
|
|
|
lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
|
2009-12-19 15:42:06 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
|
2009-12-20 21:06:40 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
|
2009-07-28 16:11:56 +00:00
|
|
|
|
2009-12-20 21:06:40 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC_BIND speech_mode=0x%02x RTP_PAYLOAD=%d\n",
|
|
|
|
gsm_lchan_name(lchan), lchan->abis_ip.speech_mode,
|
|
|
|
lchan->abis_ip.rtp_payload);
|
2009-07-28 16:11:56 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2013-02-03 11:06:58 +00:00
|
|
|
/*! \brief Issue IPA RSL MDCX to configure MGW-side of RTP
|
|
|
|
* \param[in] lchan Logical Channel for which we issue MDCX
|
|
|
|
* \param[in] ip Remote (MGW) IP address for RTP
|
|
|
|
* \param[in] port Remote (MGW) UDP port number for RTP
|
|
|
|
* \param[in] rtp_payload2 Contents of RTP PAYLOAD 2 IE
|
|
|
|
*/
|
2011-04-18 15:04:00 +00:00
|
|
|
int rsl_ipacc_mdcx(struct gsm_lchan *lchan, uint32_t ip, uint16_t port,
|
|
|
|
uint8_t rtp_payload2)
|
2009-02-16 21:12:08 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint32_t *att_ip;
|
2009-07-28 16:11:56 +00:00
|
|
|
struct in_addr ia;
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
2009-11-18 20:06:12 +00:00
|
|
|
init_dchan_hdr(dh, RSL_MT_IPAC_MDCX);
|
2009-02-16 21:12:08 +00:00
|
|
|
dh->c.msg_discr = ABIS_RSL_MDISC_IPACCESS;
|
2011-06-25 08:02:33 +00:00
|
|
|
dh->chan_nr = gsm_lchan2chan_nr(lchan);
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
/* we need to store these now as MDCX_ACK does not return them :( */
|
|
|
|
lchan->abis_ip.rtp_payload2 = rtp_payload2;
|
|
|
|
lchan->abis_ip.connect_port = port;
|
|
|
|
lchan->abis_ip.connect_ip = ip;
|
|
|
|
|
2009-07-29 10:12:18 +00:00
|
|
|
/* 0x0- == both directions, 0x-1 == EFR codec */
|
2009-12-19 15:42:06 +00:00
|
|
|
lchan->abis_ip.speech_mode = 0x00 | ipa_smod_s_for_lchan(lchan);
|
2009-12-20 21:06:40 +00:00
|
|
|
lchan->abis_ip.rtp_payload = ipa_rtp_pt_for_lchan(lchan);
|
2009-07-29 10:12:18 +00:00
|
|
|
|
2009-07-28 16:11:56 +00:00
|
|
|
ia.s_addr = htonl(ip);
|
2009-12-20 21:06:40 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC_MDCX IP=%s PORT=%d RTP_PAYLOAD=%d RTP_PAYLOAD2=%d "
|
|
|
|
"CONN_ID=%d speech_mode=0x%02x\n", gsm_lchan_name(lchan),
|
|
|
|
inet_ntoa(ia), port, lchan->abis_ip.rtp_payload, rtp_payload2,
|
|
|
|
lchan->abis_ip.conn_id, lchan->abis_ip.speech_mode);
|
2009-12-19 15:42:06 +00:00
|
|
|
|
|
|
|
msgb_tv16_put(msg, RSL_IE_IPAC_CONN_ID, lchan->abis_ip.conn_id);
|
|
|
|
msgb_v_put(msg, RSL_IE_IPAC_REMOTE_IP);
|
2011-04-18 15:04:00 +00:00
|
|
|
att_ip = (uint32_t *) msgb_put(msg, sizeof(ip));
|
2009-12-19 15:42:06 +00:00
|
|
|
*att_ip = ia.s_addr;
|
|
|
|
msgb_tv16_put(msg, RSL_IE_IPAC_REMOTE_PORT, port);
|
|
|
|
msgb_tv_put(msg, RSL_IE_IPAC_SPEECH_MODE, lchan->abis_ip.speech_mode);
|
2009-12-20 21:06:40 +00:00
|
|
|
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD, lchan->abis_ip.rtp_payload);
|
2009-07-28 16:11:56 +00:00
|
|
|
if (rtp_payload2)
|
|
|
|
msgb_tv_put(msg, RSL_IE_IPAC_RTP_PAYLOAD2, rtp_payload2);
|
2011-08-17 20:43:54 +00:00
|
|
|
|
|
|
|
msg->dst = lchan->ts->trx->rsl_link;
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-12-20 15:51:09 +00:00
|
|
|
/* tell BTS to connect RTP stream to our local RTP socket */
|
|
|
|
int rsl_ipacc_mdcx_to_rtpsock(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct rtp_socket *rs = lchan->abis_ip.rtp_socket;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = rsl_ipacc_mdcx(lchan, ntohl(rs->rtp.sin_local.sin_addr.s_addr),
|
|
|
|
ntohs(rs->rtp.sin_local.sin_port),
|
|
|
|
/* FIXME: use RTP payload of bound socket, not BTS*/
|
|
|
|
lchan->abis_ip.rtp_payload2);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2010-12-23 11:59:52 +00:00
|
|
|
int rsl_ipacc_pdch_activate(struct gsm_bts_trx_ts *ts, int act)
|
2009-10-24 08:29:22 +00:00
|
|
|
{
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t msg_type;
|
2010-03-28 06:42:09 +00:00
|
|
|
|
2016-06-15 13:32:29 +00:00
|
|
|
if (ts->flags & TS_F_PDCH_PENDING_MASK) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s PDCH %s requested, but a PDCH%s%s is still pending\n",
|
|
|
|
gsm_ts_name(ts),
|
|
|
|
act ? "ACT" : "DEACT",
|
|
|
|
ts->flags & TS_F_PDCH_ACT_PENDING? " ACT" : "",
|
|
|
|
ts->flags & TS_F_PDCH_DEACT_PENDING? " DEACT" : "");
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (act){
|
2016-07-06 12:39:04 +00:00
|
|
|
/* Callers should heed the GPRS mode. */
|
|
|
|
OSMO_ASSERT(ts->trx->bts->gprs.mode != BTS_GPRS_NONE);
|
2010-03-28 06:42:09 +00:00
|
|
|
msg_type = RSL_MT_IPAC_PDCH_ACT;
|
2016-06-15 13:32:29 +00:00
|
|
|
ts->flags |= TS_F_PDCH_ACT_PENDING;
|
|
|
|
} else {
|
2010-03-28 06:42:09 +00:00
|
|
|
msg_type = RSL_MT_IPAC_PDCH_DEACT;
|
2016-06-15 13:32:29 +00:00
|
|
|
ts->flags |= TS_F_PDCH_DEACT_PENDING;
|
|
|
|
}
|
|
|
|
/* TODO add timeout to cancel PDCH DE/ACT */
|
2009-10-24 08:29:22 +00:00
|
|
|
|
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(msg, sizeof(*dh));
|
2010-03-28 06:42:09 +00:00
|
|
|
init_dchan_hdr(dh, msg_type);
|
2009-10-24 08:29:22 +00:00
|
|
|
dh->c.msg_discr = ABIS_RSL_MDISC_DED_CHAN;
|
2016-07-18 21:43:44 +00:00
|
|
|
dh->chan_nr = gsm_pchan2chan_nr(GSM_PCHAN_PDCH, ts->nr, 0);
|
2009-10-24 08:29:22 +00:00
|
|
|
|
2016-05-31 15:51:41 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC PDCH %sACT\n", gsm_ts_name(ts),
|
2010-03-28 06:42:09 +00:00
|
|
|
act ? "" : "DE");
|
2009-10-24 08:29:22 +00:00
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = ts->trx->rsl_link;
|
2009-10-24 08:29:22 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
2009-11-18 20:06:12 +00:00
|
|
|
static int abis_rsl_rx_ipacc_crcx_ack(struct msgb *msg)
|
2009-02-16 21:12:08 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tv;
|
2009-12-01 20:26:49 +00:00
|
|
|
struct gsm_lchan *lchan = msg->lchan;
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
/* the BTS has acknowledged a local bind, it now tells us the IP
|
|
|
|
* address and port number to which it has bound the given logical
|
|
|
|
* channel */
|
|
|
|
|
|
|
|
rsl_tlv_parse(&tv, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
if (!TLVP_PRESENT(&tv, RSL_IE_IPAC_LOCAL_PORT) ||
|
|
|
|
!TLVP_PRESENT(&tv, RSL_IE_IPAC_LOCAL_IP) ||
|
2009-07-12 07:45:05 +00:00
|
|
|
!TLVP_PRESENT(&tv, RSL_IE_IPAC_CONN_ID)) {
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "mandatory IE missing");
|
2009-02-16 21:12:08 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2009-12-20 14:42:44 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
ipac_parse_rtp(lchan, &tv);
|
2009-12-20 14:42:44 +00:00
|
|
|
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_dispatch(SS_ABISIP, S_ABISIP_CRCX_ACK, msg->lchan);
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-07-28 16:11:56 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
static int abis_rsl_rx_ipacc_mdcx_ack(struct msgb *msg)
|
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tv;
|
|
|
|
struct gsm_lchan *lchan = msg->lchan;
|
2009-02-17 14:35:45 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
/* the BTS has acknowledged a remote connect request and
|
|
|
|
* it now tells us the IP address and port number to which it has
|
|
|
|
* connected the given logical channel */
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2009-12-19 15:42:06 +00:00
|
|
|
rsl_tlv_parse(&tv, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
ipac_parse_rtp(lchan, &tv);
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_dispatch(SS_ABISIP, S_ABISIP_MDCX_ACK, msg->lchan);
|
2009-02-17 14:35:45 +00:00
|
|
|
|
2009-02-16 21:12:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-18 20:06:12 +00:00
|
|
|
static int abis_rsl_rx_ipacc_dlcx_ind(struct msgb *msg)
|
2009-02-16 21:12:08 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh = msgb_l2(msg);
|
|
|
|
struct tlv_parsed tv;
|
|
|
|
|
|
|
|
rsl_tlv_parse(&tv, dh->data, msgb_l2len(msg)-sizeof(*dh));
|
|
|
|
|
2009-07-28 15:58:09 +00:00
|
|
|
if (TLVP_PRESENT(&tv, RSL_IE_CAUSE))
|
2009-12-24 11:20:20 +00:00
|
|
|
print_rsl_cause(LOGL_DEBUG, TLVP_VAL(&tv, RSL_IE_CAUSE),
|
2009-07-28 15:58:09 +00:00
|
|
|
TLVP_LEN(&tv, RSL_IE_CAUSE));
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2011-05-06 10:12:31 +00:00
|
|
|
osmo_signal_dispatch(SS_ABISIP, S_ABISIP_DLCX_IND, msg->lchan);
|
2009-07-28 16:02:05 +00:00
|
|
|
|
2009-02-16 21:12:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int abis_rsl_rx_ipacc(struct msgb *msg)
|
|
|
|
{
|
2011-08-17 20:43:54 +00:00
|
|
|
struct e1inp_sign_link *sign_link = msg->dst;
|
2009-02-16 21:12:08 +00:00
|
|
|
struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
|
2009-12-24 11:20:20 +00:00
|
|
|
char *ts_name;
|
2009-02-16 21:12:08 +00:00
|
|
|
int rc = 0;
|
|
|
|
|
2016-08-22 23:22:58 +00:00
|
|
|
msg->lchan = lchan_lookup(sign_link->trx, rllh->chan_nr,
|
|
|
|
"Abis RSL rx IPACC: ");
|
2009-12-27 17:16:36 +00:00
|
|
|
ts_name = gsm_lchan_name(msg->lchan);
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
switch (rllh->c.msg_type) {
|
2009-11-18 20:06:12 +00:00
|
|
|
case RSL_MT_IPAC_CRCX_ACK:
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC_CRCX_ACK ", ts_name);
|
2009-11-18 20:06:12 +00:00
|
|
|
rc = abis_rsl_rx_ipacc_crcx_ack(msg);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
2009-11-18 20:06:12 +00:00
|
|
|
case RSL_MT_IPAC_CRCX_NACK:
|
2009-02-16 21:12:08 +00:00
|
|
|
/* somehow the BTS was unable to bind the lchan to its local
|
|
|
|
* port?!? */
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s IPAC_CRCX_NACK\n", ts_name);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
2009-11-18 20:06:12 +00:00
|
|
|
case RSL_MT_IPAC_MDCX_ACK:
|
2009-02-16 21:12:08 +00:00
|
|
|
/* the BTS tells us that a connect operation was successful */
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC_MDCX_ACK ", ts_name);
|
2009-12-19 15:42:06 +00:00
|
|
|
rc = abis_rsl_rx_ipacc_mdcx_ack(msg);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
2009-11-18 20:06:12 +00:00
|
|
|
case RSL_MT_IPAC_MDCX_NACK:
|
2009-02-16 21:12:08 +00:00
|
|
|
/* somehow the BTS was unable to connect the lchan to a remote
|
|
|
|
* port */
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s IPAC_MDCX_NACK\n", ts_name);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
2009-11-18 20:06:12 +00:00
|
|
|
case RSL_MT_IPAC_DLCX_IND:
|
2009-12-24 11:20:20 +00:00
|
|
|
DEBUGP(DRSL, "%s IPAC_DLCX_IND ", ts_name);
|
2009-11-18 20:06:12 +00:00
|
|
|
rc = abis_rsl_rx_ipacc_dlcx_ind(msg);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-12-24 11:20:20 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "Unknown ip.access msg_type 0x%02x\n",
|
2009-12-17 22:10:46 +00:00
|
|
|
rllh->c.msg_type);
|
2009-02-16 21:12:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-05-01 17:21:37 +00:00
|
|
|
DEBUGPC(DRSL, "\n");
|
2009-02-16 21:12:08 +00:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
int dyn_ts_switchover_start(struct gsm_bts_trx_ts *ts,
|
2016-07-23 18:08:41 +00:00
|
|
|
enum gsm_phys_chan_config to_pchan)
|
2016-07-23 17:45:15 +00:00
|
|
|
{
|
|
|
|
int ss;
|
|
|
|
int rc = -EIO;
|
|
|
|
|
|
|
|
OSMO_ASSERT(ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH);
|
|
|
|
DEBUGP(DRSL, "%s starting switchover to %s\n",
|
|
|
|
gsm_ts_and_pchan_name(ts), gsm_pchan_name(to_pchan));
|
|
|
|
|
|
|
|
if (ts->dyn.pchan_is != ts->dyn.pchan_want) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s: Attempt to switch dynamic channel to %s,"
|
|
|
|
" but is already in switchover.\n",
|
|
|
|
gsm_ts_and_pchan_name(ts),
|
|
|
|
gsm_pchan_name(to_pchan));
|
|
|
|
return ts->dyn.pchan_want == to_pchan? 0 : -EAGAIN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ts->dyn.pchan_is == to_pchan) {
|
|
|
|
LOGP(DRSL, LOGL_INFO,
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
"%s %s Already is in %s mode, cannot switchover.\n",
|
2016-07-23 17:45:15 +00:00
|
|
|
gsm_ts_name(ts), gsm_pchan_name(ts->pchan),
|
|
|
|
gsm_pchan_name(to_pchan));
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return -EINVAL;
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Paranoia: let's make sure all is indeed released. */
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
for (ss = 0; ss < ts_subslots(ts); ss++) {
|
2016-07-23 17:45:15 +00:00
|
|
|
struct gsm_lchan *lc = &ts->lchan[ss];
|
|
|
|
if (lc->state != LCHAN_S_NONE) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Attempt to switch dynamic channel to %s,"
|
|
|
|
" but is not fully released.\n",
|
|
|
|
gsm_ts_and_pchan_name(ts),
|
|
|
|
gsm_pchan_name(to_pchan));
|
|
|
|
return -EAGAIN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Record that we're busy switching. */
|
|
|
|
ts->dyn.pchan_want = to_pchan;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To switch from PDCH, we need to initiate the release from the BSC
|
|
|
|
* side. dyn_ts_switchover_continue() will be called from
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
* rsl_rx_rf_chan_rel_ack(). PDCH is always on lchan[0].
|
2016-07-23 17:45:15 +00:00
|
|
|
*/
|
|
|
|
if (ts->dyn.pchan_is == GSM_PCHAN_PDCH) {
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
rsl_lchan_set_state(ts->lchan, LCHAN_S_REL_REQ);
|
|
|
|
rc = rsl_rf_chan_release(ts->lchan, 0, SACCH_NONE);
|
2016-07-23 17:45:15 +00:00
|
|
|
if (rc) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s RSL RF Chan Release failed\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return dyn_ts_switchover_failed(ts, rc);
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* To switch from TCH/F and TCH/H pchans, this has been called from
|
|
|
|
* rsl_rx_rf_chan_rel_ack(), i.e. release is complete. Go ahead and
|
|
|
|
* activate as new type. This will always be PDCH.
|
|
|
|
*/
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return dyn_ts_switchover_continue(ts);
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
static int dyn_ts_switchover_continue(struct gsm_bts_trx_ts *ts)
|
2016-07-23 17:45:15 +00:00
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
uint8_t act_type;
|
|
|
|
uint8_t ho_ref;
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
int ss;
|
|
|
|
struct gsm_lchan *lchan;
|
2016-07-23 17:45:15 +00:00
|
|
|
|
|
|
|
OSMO_ASSERT(ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH);
|
|
|
|
DEBUGP(DRSL, "%s switchover: release complete,"
|
|
|
|
" activating new pchan type\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
|
|
|
|
|
|
|
if (ts->dyn.pchan_is == ts->dyn.pchan_want) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Requested to switchover dynamic channel to the"
|
|
|
|
" same type it is already in.\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
|
|
|
return 0;
|
|
|
|
}
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
|
|
|
|
for (ss = 0; ss < ts_subslots(ts); ss++) {
|
|
|
|
lchan = &ts->lchan[ss];
|
|
|
|
if (lchan->rqd_ref) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s During dyn TS switchover, expecting no"
|
|
|
|
" Request Reference to be pending. Discarding!\n",
|
|
|
|
gsm_lchan_name(lchan));
|
|
|
|
talloc_free(lchan->rqd_ref);
|
|
|
|
lchan->rqd_ref = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* When switching pchan modes, all lchans are unused. So always
|
|
|
|
* activate whatever wants to be activated on the first lchan. (We
|
|
|
|
* wouldn't remember to use lchan[1] across e.g. a PDCH deact anyway)
|
|
|
|
*/
|
|
|
|
lchan = ts->lchan;
|
2016-07-23 17:45:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For TCH/x, the lchan->type has been set in lchan_alloc(), but it may
|
|
|
|
* have been lost during channel release due to dynamic switchover.
|
|
|
|
*
|
|
|
|
* For PDCH, the lchan->type will actually remain NONE.
|
|
|
|
* TODO: set GSM_LCHAN_PDTCH?
|
|
|
|
*/
|
|
|
|
switch (ts->dyn.pchan_want) {
|
|
|
|
case GSM_PCHAN_TCH_F:
|
|
|
|
lchan->type = GSM_LCHAN_TCH_F;
|
|
|
|
break;
|
|
|
|
case GSM_PCHAN_TCH_H:
|
|
|
|
lchan->type = GSM_LCHAN_TCH_H;
|
|
|
|
break;
|
|
|
|
case GSM_PCHAN_PDCH:
|
|
|
|
lchan->type = GSM_LCHAN_NONE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Invalid target pchan for dynamic TS\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
|
|
|
}
|
|
|
|
|
|
|
|
act_type = (ts->dyn.pchan_want == GSM_PCHAN_PDCH)
|
|
|
|
? RSL_ACT_OSMO_PDCH
|
|
|
|
: lchan->dyn.act_type;
|
|
|
|
ho_ref = (ts->dyn.pchan_want == GSM_PCHAN_PDCH)
|
|
|
|
? 0
|
|
|
|
: lchan->dyn.ho_ref;
|
|
|
|
|
|
|
|
/* Fetch the rqd_ref back from before switchover started. */
|
|
|
|
lchan->rqd_ref = lchan->dyn.rqd_ref;
|
|
|
|
lchan->rqd_ta = lchan->dyn.rqd_ta;
|
|
|
|
lchan->dyn.rqd_ref = NULL;
|
|
|
|
lchan->dyn.rqd_ta = 0;
|
|
|
|
|
2016-08-24 14:57:31 +00:00
|
|
|
/* During switchover, we have received a release ack, which means that
|
|
|
|
* the act_timer has been stopped. Start the timer again so we mark
|
|
|
|
* this channel broken if the activation ack comes too late. */
|
|
|
|
lchan->act_timer.cb = lchan_act_tmr_cb;
|
|
|
|
lchan->act_timer.data = lchan;
|
|
|
|
osmo_timer_schedule(&lchan->act_timer, 4, 0);
|
|
|
|
|
2016-07-23 17:45:15 +00:00
|
|
|
rc = rsl_chan_activate_lchan(lchan, act_type, ho_ref);
|
|
|
|
if (rc) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s RSL Chan Activate failed\n",
|
|
|
|
gsm_ts_and_pchan_name(ts));
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
return dyn_ts_switchover_failed(ts, rc);
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
static int dyn_ts_switchover_failed(struct gsm_bts_trx_ts *ts, int rc)
|
2016-07-23 17:45:15 +00:00
|
|
|
{
|
|
|
|
ts->dyn.pchan_want = ts->dyn.pchan_is;
|
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s Error %d during dynamic channel switchover."
|
|
|
|
" Going back to previous pchan.\n", gsm_ts_and_pchan_name(ts),
|
|
|
|
rc);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dyn_ts_switchover_complete(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
enum gsm_phys_chan_config pchan_act;
|
|
|
|
enum gsm_phys_chan_config pchan_was;
|
|
|
|
struct gsm_bts_trx_ts *ts = lchan->ts;
|
|
|
|
|
|
|
|
OSMO_ASSERT(ts->pchan == GSM_PCHAN_TCH_F_TCH_H_PDCH);
|
|
|
|
|
|
|
|
pchan_act = pchan_for_lchant(lchan->type);
|
|
|
|
/*
|
|
|
|
* Paranoia: do the types match?
|
|
|
|
* In case of errors: we've received an act ack already, so what to do
|
|
|
|
* about it? Logging the error should suffice for now.
|
|
|
|
*/
|
|
|
|
if (pchan_act != ts->dyn.pchan_want)
|
|
|
|
LOGP(DRSL, LOGL_ERROR,
|
|
|
|
"%s Requested transition does not match lchan type %s\n",
|
|
|
|
gsm_ts_and_pchan_name(ts),
|
dyn TS: clearly use lchan[0], fixing minor confusion
The dyn_ts_switchover_*() functions made the impression that they act on a
specific lchan of a timeslot. The assumption that we would remember to use e.g.
lchan[1] across a PDCH deactivation is brain damaged to begin with; and
factually we always use lchan[0] anyway (the only case for using lchan[1] would
be when switching to TCH/H, but the channel allocator will always return
lchan[0] for that).
Instead of the brain damaged lchan args, use a ts arg across all
dyn_ts_switchover_*() functions, with one exception: The
dyn_ts_switchover_complete() actually receives an RSL activation ack message on
a specific lchan and needs to evaluate its lchan type. This will always be
lchan[0] as it is now, but we should stick with the lchan the message was sent
for.
For PDCH, a check to use lchan[0] already existed, when composing the ACT
message in rsl_chan_activate_lchan_as_pdch(). Replace with an assertion.
Adjust all callers to pass ts instead of lchan.
In dyn_ts_switchover_start(), there was a dead code check that jumps to
switchover_complete() in case the pchan already matches. This never hits,
because we only call dyn_ts_switchover_start() when pchans mismatch. So avoid
guessing at passing lchan[0] to dyn_ts_switchover_complete() by not calling it
at all but logging an error instead.
In rsl_chan_activate_lchan(), we remember some values before going into
switchover from PDCH. Explicitly store them in lchan[0], because after a PDCH
release we have always and will activate no other than lchan[0].
In dyn_ts_switchover_continue(), move the check for any existing lchan->rqd_ref
further above, and more correctly check all lchans that were so far valid on
the TS, instead of just one.
This partly prepares for a subsequent commit to fix the act_timer use for dyn
TS: with the old lchan arg, we might schedule an activation timer on lchan[1]
but receive an ack on lchan[0] (for PDCH), leading to an act_timer expiry.
Change-Id: I3f5d48a9bdaa49a42a1908d4a03744638c59796a
2016-08-24 14:57:31 +00:00
|
|
|
gsm_lchant_name(lchan->type));
|
2016-07-23 17:45:15 +00:00
|
|
|
|
|
|
|
pchan_was = ts->dyn.pchan_is;
|
|
|
|
ts->dyn.pchan_is = ts->dyn.pchan_want = pchan_act;
|
|
|
|
|
2016-08-24 12:42:58 +00:00
|
|
|
if (pchan_was != ts->dyn.pchan_is)
|
|
|
|
LOGP(DRSL, LOGL_INFO, "%s switchover from %s complete.\n",
|
|
|
|
gsm_ts_and_pchan_name(ts), gsm_pchan_name(pchan_was));
|
2016-07-23 17:45:15 +00:00
|
|
|
}
|
2009-02-16 21:12:08 +00:00
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
/* Entry-point where L2 RSL from BTS enters */
|
2008-12-25 23:28:35 +00:00
|
|
|
int abis_rsl_rcvmsg(struct msgb *msg)
|
2008-12-23 20:25:15 +00:00
|
|
|
{
|
2009-11-20 14:14:01 +00:00
|
|
|
struct abis_rsl_common_hdr *rslh;
|
2009-02-03 12:57:37 +00:00
|
|
|
int rc = 0;
|
2008-12-23 20:25:15 +00:00
|
|
|
|
2009-11-20 14:14:01 +00:00
|
|
|
if (!msg) {
|
|
|
|
DEBUGP(DRSL, "Empty RSL msg?..\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgb_l2len(msg) < sizeof(*rslh)) {
|
|
|
|
DEBUGP(DRSL, "Truncated RSL message with l2len: %u\n", msgb_l2len(msg));
|
2012-05-31 18:22:34 +00:00
|
|
|
msgb_free(msg);
|
2009-11-20 14:14:01 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
rslh = msgb_l2(msg);
|
|
|
|
|
2008-12-23 20:25:15 +00:00
|
|
|
switch (rslh->msg_discr & 0xfe) {
|
|
|
|
case ABIS_RSL_MDISC_RLL:
|
|
|
|
rc = abis_rsl_rx_rll(msg);
|
|
|
|
break;
|
|
|
|
case ABIS_RSL_MDISC_DED_CHAN:
|
|
|
|
rc = abis_rsl_rx_dchan(msg);
|
|
|
|
break;
|
|
|
|
case ABIS_RSL_MDISC_COM_CHAN:
|
|
|
|
rc = abis_rsl_rx_cchan(msg);
|
|
|
|
break;
|
2008-12-25 23:28:35 +00:00
|
|
|
case ABIS_RSL_MDISC_TRX:
|
|
|
|
rc = abis_rsl_rx_trx(msg);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
case ABIS_RSL_MDISC_LOC:
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "unimplemented RSL msg disc 0x%02x\n",
|
2009-02-03 12:57:37 +00:00
|
|
|
rslh->msg_discr);
|
|
|
|
break;
|
2009-02-16 21:12:08 +00:00
|
|
|
case ABIS_RSL_MDISC_IPACCESS:
|
|
|
|
rc = abis_rsl_rx_ipacc(msg);
|
|
|
|
break;
|
2008-12-23 20:25:15 +00:00
|
|
|
default:
|
2009-12-17 22:10:46 +00:00
|
|
|
LOGP(DRSL, LOGL_NOTICE, "unknown RSL message discriminator "
|
|
|
|
"0x%02x\n", rslh->msg_discr);
|
2012-05-31 18:22:34 +00:00
|
|
|
rc = -EINVAL;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
2008-12-26 00:04:49 +00:00
|
|
|
msgb_free(msg);
|
2008-12-25 23:28:35 +00:00
|
|
|
return rc;
|
2008-12-23 20:25:15 +00:00
|
|
|
}
|
2009-02-04 00:31:39 +00:00
|
|
|
|
2010-07-21 07:54:32 +00:00
|
|
|
int rsl_sms_cb_command(struct gsm_bts *bts, uint8_t chan_number,
|
2014-12-28 14:00:45 +00:00
|
|
|
struct rsl_ie_cb_cmd_type cb_command,
|
|
|
|
const uint8_t *data, int len)
|
2010-07-21 07:54:32 +00:00
|
|
|
{
|
|
|
|
struct abis_rsl_dchan_hdr *dh;
|
|
|
|
struct msgb *cb_cmd;
|
|
|
|
|
|
|
|
cb_cmd = rsl_msgb_alloc();
|
|
|
|
if (!cb_cmd)
|
|
|
|
return -1;
|
|
|
|
|
2014-12-28 14:00:45 +00:00
|
|
|
dh = (struct abis_rsl_dchan_hdr *) msgb_put(cb_cmd, sizeof(*dh));
|
2010-07-21 07:54:32 +00:00
|
|
|
init_dchan_hdr(dh, RSL_MT_SMS_BC_CMD);
|
2014-12-28 14:00:45 +00:00
|
|
|
dh->c.msg_discr = ABIS_RSL_MDISC_COM_CHAN;
|
|
|
|
dh->chan_nr = chan_number; /* TODO: check the chan config */
|
2010-07-21 07:54:32 +00:00
|
|
|
|
2014-12-28 14:00:45 +00:00
|
|
|
msgb_tv_put(cb_cmd, RSL_IE_CB_CMD_TYPE, *(uint8_t*)&cb_command);
|
2010-07-21 07:54:32 +00:00
|
|
|
msgb_tlv_put(cb_cmd, RSL_IE_SMSCB_MSG, len, data);
|
|
|
|
|
2014-12-28 14:00:45 +00:00
|
|
|
cb_cmd->dst = bts->c0->rsl_link;
|
2010-07-21 07:54:32 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(cb_cmd);
|
|
|
|
}
|
2011-07-27 22:01:50 +00:00
|
|
|
|
|
|
|
int rsl_nokia_si_begin(struct gsm_bts_trx *trx)
|
|
|
|
{
|
|
|
|
struct abis_rsl_common_hdr *ch;
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
|
|
|
|
ch = (struct abis_rsl_common_hdr *) msgb_put(msg, sizeof(*ch));
|
|
|
|
ch->msg_discr = ABIS_RSL_MDISC_TRX;
|
|
|
|
ch->msg_type = 0x40; /* Nokia SI Begin */
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = trx->rsl_link;
|
2011-07-27 22:01:50 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rsl_nokia_si_end(struct gsm_bts_trx *trx)
|
|
|
|
{
|
|
|
|
struct abis_rsl_common_hdr *ch;
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
|
|
|
|
ch = (struct abis_rsl_common_hdr *) msgb_put(msg, sizeof(*ch));
|
|
|
|
ch->msg_discr = ABIS_RSL_MDISC_TRX;
|
|
|
|
ch->msg_type = 0x41; /* Nokia SI End */
|
|
|
|
|
|
|
|
msgb_tv_put(msg, 0xFD, 0x00); /* Nokia Pagemode Info, No paging reorganisation required */
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = trx->rsl_link;
|
2011-07-27 22:01:50 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
int rsl_bs_power_control(struct gsm_bts_trx *trx, uint8_t channel, uint8_t reduction)
|
|
|
|
{
|
|
|
|
struct abis_rsl_common_hdr *ch;
|
|
|
|
struct msgb *msg = rsl_msgb_alloc();
|
|
|
|
|
|
|
|
ch = (struct abis_rsl_common_hdr *) msgb_put(msg, sizeof(*ch));
|
|
|
|
ch->msg_discr = ABIS_RSL_MDISC_DED_CHAN;
|
|
|
|
ch->msg_type = RSL_MT_BS_POWER_CONTROL;
|
|
|
|
|
|
|
|
msgb_tv_put(msg, RSL_IE_CHAN_NR, channel);
|
|
|
|
msgb_tv_put(msg, RSL_IE_BS_POWER, reduction); /* reduction in 2dB steps */
|
|
|
|
|
2011-08-17 20:43:54 +00:00
|
|
|
msg->dst = trx->rsl_link;
|
2011-07-27 22:01:50 +00:00
|
|
|
|
|
|
|
return abis_rsl_sendmsg(msg);
|
|
|
|
}
|
2011-12-27 21:24:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Release all allocated SAPIs starting from @param start and
|
|
|
|
* release them with the given release mode. Once the release
|
|
|
|
* confirmation arrives it will be attempted to release the
|
|
|
|
* the RF channel.
|
|
|
|
*/
|
|
|
|
int rsl_release_sapis_from(struct gsm_lchan *lchan, int start,
|
|
|
|
enum rsl_rel_mode release_mode)
|
|
|
|
{
|
|
|
|
int no_sapi = 1;
|
|
|
|
int sapi;
|
|
|
|
|
|
|
|
for (sapi = start; sapi < ARRAY_SIZE(lchan->sapis); ++sapi) {
|
|
|
|
uint8_t link_id;
|
|
|
|
if (lchan->sapis[sapi] == LCHAN_SAPI_UNUSED)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
link_id = sapi;
|
|
|
|
if (lchan->type == GSM_LCHAN_TCH_F || lchan->type == GSM_LCHAN_TCH_H)
|
|
|
|
link_id |= 0x40;
|
|
|
|
rsl_release_request(lchan, link_id, release_mode);
|
|
|
|
no_sapi = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return no_sapi;
|
|
|
|
}
|
2011-12-28 15:21:05 +00:00
|
|
|
|
|
|
|
int rsl_start_t3109(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts = lchan->ts->trx->bts;
|
|
|
|
|
|
|
|
/* Disabled, mostly legacy code */
|
|
|
|
if (bts->network->T3109 == 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
lchan->T3109.cb = t3109_expired;
|
|
|
|
lchan->T3109.data = lchan;
|
|
|
|
osmo_timer_schedule(&lchan->T3109, bts->network->T3109, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2012-12-25 22:45:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief directly RF Channel Release the lchan
|
|
|
|
*
|
|
|
|
* When no SAPI was allocated, directly release the logical channel. This
|
|
|
|
* should only be called from chan_alloc.c on channel release handling. In
|
|
|
|
* case no SAPI was established the RF Channel can be directly released,
|
|
|
|
*/
|
|
|
|
int rsl_direct_rf_release(struct gsm_lchan *lchan)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ARRAY_SIZE(lchan->sapis); ++i) {
|
|
|
|
if (lchan->sapis[i] != LCHAN_SAPI_UNUSED) {
|
|
|
|
LOGP(DRSL, LOGL_ERROR, "%s SAPI(%d) still allocated.\n",
|
|
|
|
gsm_lchan_name(lchan), i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now release it */
|
|
|
|
return rsl_rf_chan_release(lchan, 0, SACCH_NONE);
|
|
|
|
}
|