Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 1 | /* (C) 2008-2010 by Harald Welte <laforge@gnumonks.org> |
| 2 | * |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU Affero General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU Affero General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU Affero General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | * |
| 18 | */ |
| 19 | |
Neels Hofmeyr | c016479 | 2017-09-04 15:15:32 +0200 | [diff] [blame] | 20 | #include <osmocom/bsc/osmo_bsc.h> |
| 21 | #include <osmocom/bsc/bsc_msc_data.h> |
| 22 | #include <osmocom/bsc/gsm_04_08_utils.h> |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 23 | #include <osmocom/bsc/handover_cfg.h> |
Stefan Sperling | 6cee893 | 2018-01-30 18:14:22 +0100 | [diff] [blame] | 24 | #include <osmocom/bsc/chan_alloc.h> |
| 25 | |
| 26 | /* XXX hard-coded for now */ |
| 27 | #define T3122_CHAN_LOAD_SAMPLE_INTERVAL 1 /* in seconds */ |
| 28 | |
| 29 | static void update_t3122_chan_load_timer(void *data) |
| 30 | { |
| 31 | struct gsm_network *net = data; |
| 32 | struct gsm_bts *bts; |
| 33 | |
| 34 | llist_for_each_entry(bts, &net->bts_list, list) |
| 35 | bts_update_t3122_chan_load(bts); |
| 36 | |
| 37 | /* Keep this timer ticking. */ |
| 38 | osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0); |
| 39 | } |
Max | e6052c4 | 2016-06-30 10:25:49 +0200 | [diff] [blame] | 40 | |
Neels Hofmeyr | 27681a3 | 2016-05-14 00:45:26 +0200 | [diff] [blame] | 41 | struct gsm_network *bsc_network_init(void *ctx, |
Neels Hofmeyr | 77c8d5f | 2016-05-09 19:12:44 +0200 | [diff] [blame] | 42 | uint16_t country_code, |
Harald Welte | d9956d9 | 2017-12-17 21:48:47 +0100 | [diff] [blame] | 43 | uint16_t network_code) |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 44 | { |
| 45 | struct gsm_network *net; |
| 46 | |
Neels Hofmeyr | ab1b381 | 2018-02-13 23:34:07 +0100 | [diff] [blame] | 47 | net = talloc_zero(ctx, struct gsm_network); |
| 48 | if (!net) |
| 49 | return NULL; |
| 50 | |
| 51 | net->country_code = country_code; |
| 52 | net->network_code = network_code; |
Harald Welte | 51e4bf3 | 2017-12-23 17:30:18 +0100 | [diff] [blame] | 53 | /* Permit a compile-time default of A5/3 and A5/1 */ |
| 54 | net->a5_encryption_mask = (1 << 3) | (1 << 1); |
Neels Hofmeyr | ab1b381 | 2018-02-13 23:34:07 +0100 | [diff] [blame] | 55 | |
| 56 | /* Use 30 min periodic update interval as sane default */ |
| 57 | net->t3212 = 5; |
| 58 | |
Neels Hofmeyr | ab1b381 | 2018-02-13 23:34:07 +0100 | [diff] [blame] | 59 | INIT_LLIST_HEAD(&net->subscr_conns); |
| 60 | |
| 61 | net->bsc_subscribers = talloc_zero(net, struct llist_head); |
| 62 | INIT_LLIST_HEAD(net->bsc_subscribers); |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 63 | |
| 64 | net->bsc_data = talloc_zero(net, struct osmo_bsc_data); |
| 65 | if (!net->bsc_data) { |
| 66 | talloc_free(net); |
| 67 | return NULL; |
| 68 | } |
| 69 | |
| 70 | /* Init back pointer */ |
| 71 | net->bsc_data->auto_off_timeout = -1; |
| 72 | net->bsc_data->network = net; |
| 73 | INIT_LLIST_HEAD(&net->bsc_data->mscs); |
Holger Hans Peter Freyther | 1ba0730 | 2015-01-27 10:27:53 +0100 | [diff] [blame] | 74 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 75 | net->num_bts = 0; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 76 | net->T3101 = GSM_T3101_DEFAULT; |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 77 | net->T3103 = GSM_T3103_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 78 | net->T3105 = GSM_T3105_DEFAULT; |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 79 | net->T3107 = GSM_T3107_DEFAULT; |
| 80 | net->T3109 = GSM_T3109_DEFAULT; |
| 81 | net->T3111 = GSM_T3111_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 82 | net->T3113 = GSM_T3113_DEFAULT; |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 83 | net->T3115 = GSM_T3115_DEFAULT; |
| 84 | net->T3117 = GSM_T3117_DEFAULT; |
| 85 | net->T3119 = GSM_T3119_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 86 | net->T3122 = GSM_T3122_DEFAULT; |
Harald Welte | a0d324b | 2017-07-20 01:47:39 +0200 | [diff] [blame] | 87 | net->T3141 = GSM_T3141_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 88 | |
Neels Hofmeyr | e25018b | 2017-11-27 21:29:33 +0100 | [diff] [blame] | 89 | net->ho = ho_cfg_init(net, NULL); |
Neels Hofmeyr | 909e972 | 2017-12-07 03:54:01 +0100 | [diff] [blame^] | 90 | net->hodec2.congestion_check_interval_s = HO_CFG_CONGESTION_CHECK_DEFAULT; |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 91 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 92 | INIT_LLIST_HEAD(&net->bts_list); |
| 93 | |
Stefan Sperling | 6cee893 | 2018-01-30 18:14:22 +0100 | [diff] [blame] | 94 | /* |
| 95 | * At present all BTS in the network share one channel load timeout. |
| 96 | * If this becomes a problem for networks with a lot of BTS, this |
| 97 | * code could be refactored to run the timeout individually per BTS. |
| 98 | */ |
| 99 | osmo_timer_setup(&net->t3122_chan_load_timer, update_t3122_chan_load_timer, net); |
| 100 | osmo_timer_schedule(&net->t3122_chan_load_timer, T3122_CHAN_LOAD_SAMPLE_INTERVAL, 0); |
| 101 | |
Alexander Couzens | 20423ea | 2016-07-12 15:42:02 +0200 | [diff] [blame] | 102 | /* init statistics */ |
Alexander Couzens | b847a21 | 2016-08-02 11:34:11 +0200 | [diff] [blame] | 103 | net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0); |
Harald Welte | ed208de | 2017-07-12 00:25:51 +0200 | [diff] [blame] | 104 | if (!net->bsc_ctrs) { |
| 105 | talloc_free(net); |
| 106 | return NULL; |
| 107 | } |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 108 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 109 | gsm_net_update_ctype(net); |
| 110 | |
Jacob Erlbeck | cdd4302 | 2014-11-10 11:21:32 +0100 | [diff] [blame] | 111 | return net; |
| 112 | } |
| 113 | |