blob: e5422fc5cd7a6ace1f32975f0de23c433bd6a4f9 [file] [log] [blame]
Neels Hofmeyrb8afb5f2016-06-02 01:18:02 +02001/* Dynamic PDCH initialisation implementation shared across NM and RSL */
2
3/* (C) 2016 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 * All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
15 *
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21#include <osmocom/core/logging.h>
22#include <openbsc/debug.h>
23#include <openbsc/gsm_data.h>
24#include <openbsc/abis_rsl.h>
25
Neels Hofmeyrd3b7fa82016-07-23 20:08:41 +020026void tchf_pdch_ts_init(struct gsm_bts_trx_ts *ts)
Neels Hofmeyrb8afb5f2016-06-02 01:18:02 +020027{
28 int rc;
29
Neels Hofmeyr9ddd8e62016-07-06 14:39:04 +020030 if (ts->trx->bts->gprs.mode == BTS_GPRS_NONE) {
Neels Hofmeyr2e84b602016-07-23 20:06:27 +020031 LOGP(DRSL, LOGL_NOTICE, "%s: GPRS mode is 'none':"
Neels Hofmeyr9ddd8e62016-07-06 14:39:04 +020032 " not activating PDCH.\n",
Neels Hofmeyr2e84b602016-07-23 20:06:27 +020033 gsm_ts_and_pchan_name(ts));
Neels Hofmeyr9ddd8e62016-07-06 14:39:04 +020034 return;
35 }
36
Neels Hofmeyr2e84b602016-07-23 20:06:27 +020037 LOGP(DRSL, LOGL_DEBUG, "%s: trying to PDCH ACT\n",
38 gsm_ts_and_pchan_name(ts));
Neels Hofmeyr9331df12016-07-06 14:38:20 +020039
40 rc = rsl_ipacc_pdch_activate(ts, 1);
41 if (rc != 0)
42 LOGP(DRSL, LOGL_ERROR, "%s %s: PDCH ACT failed\n",
43 gsm_ts_name(ts), gsm_pchan_name(ts->pchan));
Neels Hofmeyrb8afb5f2016-06-02 01:18:02 +020044}
Neels Hofmeyrd3b7fa82016-07-23 20:08:41 +020045
46void tchf_tchh_pdch_ts_init(struct gsm_bts_trx_ts *ts)
47{
48 if (ts->trx->bts->gprs.mode == BTS_GPRS_NONE) {
49 LOGP(DRSL, LOGL_NOTICE, "%s: GPRS mode is 'none':"
50 " not activating PDCH.\n",
51 gsm_ts_and_pchan_name(ts));
52 return;
53 }
54
Neels Hofmeyrb74a2c82016-08-24 16:57:31 +020055 dyn_ts_switchover_start(ts, GSM_PCHAN_PDCH);
Neels Hofmeyrd3b7fa82016-07-23 20:08:41 +020056}
57
58void dyn_ts_init(struct gsm_bts_trx_ts *ts)
59{
60 /* Clear all TCH/F_PDCH flags */
61 ts->flags &= ~(TS_F_PDCH_PENDING_MASK | TS_F_PDCH_ACTIVE);
62
63 /* Clear TCH/F_TCH/H_PDCH state */
64 ts->dyn.pchan_is = ts->dyn.pchan_want = GSM_PCHAN_NONE;
65 ts->dyn.pending_chan_activ = NULL;
66
67 switch (ts->pchan) {
68 case GSM_PCHAN_TCH_F_PDCH:
69 tchf_pdch_ts_init(ts);
70 break;
71 case GSM_PCHAN_TCH_F_TCH_H_PDCH:
72 tchf_tchh_pdch_ts_init(ts);
73 break;
74 default:
75 break;
76 }
77}