Neels Hofmeyr | b8afb5f | 2016-06-02 01:18:02 +0200 | [diff] [blame] | 1 | /* 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 Hofmeyr | d3b7fa8 | 2016-07-23 20:08:41 +0200 | [diff] [blame] | 26 | void tchf_pdch_ts_init(struct gsm_bts_trx_ts *ts) |
Neels Hofmeyr | b8afb5f | 2016-06-02 01:18:02 +0200 | [diff] [blame] | 27 | { |
| 28 | int rc; |
| 29 | |
Neels Hofmeyr | 9ddd8e6 | 2016-07-06 14:39:04 +0200 | [diff] [blame] | 30 | if (ts->trx->bts->gprs.mode == BTS_GPRS_NONE) { |
Neels Hofmeyr | 2e84b60 | 2016-07-23 20:06:27 +0200 | [diff] [blame] | 31 | LOGP(DRSL, LOGL_NOTICE, "%s: GPRS mode is 'none':" |
Neels Hofmeyr | 9ddd8e6 | 2016-07-06 14:39:04 +0200 | [diff] [blame] | 32 | " not activating PDCH.\n", |
Neels Hofmeyr | 2e84b60 | 2016-07-23 20:06:27 +0200 | [diff] [blame] | 33 | gsm_ts_and_pchan_name(ts)); |
Neels Hofmeyr | 9ddd8e6 | 2016-07-06 14:39:04 +0200 | [diff] [blame] | 34 | return; |
| 35 | } |
| 36 | |
Neels Hofmeyr | 2e84b60 | 2016-07-23 20:06:27 +0200 | [diff] [blame] | 37 | LOGP(DRSL, LOGL_DEBUG, "%s: trying to PDCH ACT\n", |
| 38 | gsm_ts_and_pchan_name(ts)); |
Neels Hofmeyr | 9331df1 | 2016-07-06 14:38:20 +0200 | [diff] [blame] | 39 | |
| 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 Hofmeyr | b8afb5f | 2016-06-02 01:18:02 +0200 | [diff] [blame] | 44 | } |
Neels Hofmeyr | d3b7fa8 | 2016-07-23 20:08:41 +0200 | [diff] [blame] | 45 | |
| 46 | void 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 Hofmeyr | b74a2c8 | 2016-08-24 16:57:31 +0200 | [diff] [blame] | 55 | dyn_ts_switchover_start(ts, GSM_PCHAN_PDCH); |
Neels Hofmeyr | d3b7fa8 | 2016-07-23 20:08:41 +0200 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | void 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 | } |