blob: 2de098bdbbae24f4882c9824f3cd4df8f3346917 [file] [log] [blame]
Harald Welteb68899d2009-01-06 21:47:18 +00001/* Paging helper and manager.... */
2/* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
3 * All Rights Reserved
4 *
5 * This program is free software; you can redistribute it and/or modify
Harald Welte9af6ddf2011-01-01 15:25:50 +01006 * 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
Harald Welteb68899d2009-01-06 21:47:18 +00008 * (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
Harald Welte9af6ddf2011-01-01 15:25:50 +010013 * GNU Affero General Public License for more details.
Harald Welteb68899d2009-01-06 21:47:18 +000014 *
Harald Welte9af6ddf2011-01-01 15:25:50 +010015 * 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/>.
Harald Welteb68899d2009-01-06 21:47:18 +000017 *
18 */
19
20/*
21 * Relevant specs:
22 * 12.21:
23 * - 9.4.12 for CCCH Local Threshold
24 *
25 * 05.58:
26 * - 8.5.2 CCCH Load indication
27 * - 9.3.15 Paging Load
28 *
29 * Approach:
30 * - Send paging command to subscriber
31 * - On Channel Request we will remember the reason
32 * - After the ACK we will request the identity
33 * - Then we will send assign the gsm_subscriber and
34 * - and call a callback
35 */
36
Harald Welte2f1311b2009-01-06 23:50:39 +000037#include <stdio.h>
38#include <stdlib.h>
Holger Freythere36e15e2009-02-14 18:05:03 +000039#include <assert.h>
Harald Welte2f1311b2009-01-06 23:50:39 +000040
Harald Welteb68899d2009-01-06 21:47:18 +000041#include <openbsc/paging.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010042#include <osmocom/core/talloc.h>
Harald Welteb68899d2009-01-06 21:47:18 +000043#include <openbsc/debug.h>
Holger Freyther4af2b482009-02-14 22:51:03 +000044#include <openbsc/signal.h>
Harald Welte2f1311b2009-01-06 23:50:39 +000045#include <openbsc/abis_rsl.h>
Holger Freytherceb59b72009-02-06 18:54:00 +000046#include <openbsc/gsm_data.h>
Holger Hans Peter Freytheref811782010-04-10 00:06:17 +020047#include <openbsc/chan_alloc.h>
Holger Hans Peter Freytherc6bb3c42010-06-17 16:43:24 +080048#include <openbsc/bsc_api.h>
Harald Welteb68899d2009-01-06 21:47:18 +000049
Harald Welte (local)d19e58b2009-08-15 02:30:58 +020050void *tall_paging_ctx;
Harald Welte2cf161b2009-06-20 22:36:41 +020051
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +080052#define PAGING_TIMER 0, 500000
53
Holger Freyther3aa8d6c2009-02-04 02:14:45 +000054static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber *subscr)
55{
56 int ccch_conf;
57 int bs_cc_chans;
58 int blocks;
59 unsigned int group;
60
Harald Weltea43f7892009-12-01 18:04:30 +053061 ccch_conf = bts->si_common.chan_desc.ccch_conf;
Holger Freyther3aa8d6c2009-02-04 02:14:45 +000062 bs_cc_chans = rsl_ccch_conf_to_bs_cc_chans(ccch_conf);
63 /* code word + 2, as 2 channels equals 0x0 */
Holger Freyther152a1472009-02-04 13:38:26 +000064 blocks = rsl_number_of_paging_subchannels(bts);
Holger Freyther3aa8d6c2009-02-04 02:14:45 +000065 group = get_paging_group(str_to_imsi(subscr->imsi),
66 bs_cc_chans, blocks);
67 return group;
68}
69
Harald Welte38c2f132009-01-06 23:10:57 +000070/*
71 * Kill one paging request update the internal list...
72 */
Holger Freyther1fd34142009-02-09 23:42:03 +000073static void paging_remove_request(struct gsm_bts_paging_state *paging_bts,
Holger Freytherceb59b72009-02-06 18:54:00 +000074 struct gsm_paging_request *to_be_deleted)
Holger Freyther3d949242009-02-06 18:08:18 +000075{
Harald Welteff117a82009-05-23 05:22:08 +000076 bsc_del_timer(&to_be_deleted->T3113);
Harald Welte38c2f132009-01-06 23:10:57 +000077 llist_del(&to_be_deleted->entry);
Harald Welte51cce1e2009-02-10 17:35:04 +000078 subscr_put(to_be_deleted->subscr);
Harald Welte2cf161b2009-06-20 22:36:41 +020079 talloc_free(to_be_deleted);
Harald Welte38c2f132009-01-06 23:10:57 +000080}
81
Holger Freyther33ba7522009-02-06 22:33:25 +000082static void page_ms(struct gsm_paging_request *request)
83{
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +020084 uint8_t mi[128];
Harald Welte2f1311b2009-01-06 23:50:39 +000085 unsigned int mi_len;
Holger Freyther33ba7522009-02-06 22:33:25 +000086 unsigned int page_group;
87
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +020088 LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: '%s' tmsi: '0x%x'\n",
Holger Hans Peter Freytherb28285d2009-08-21 14:55:57 +020089 request->subscr->imsi, request->subscr->tmsi);
90
91 if (request->subscr->tmsi == GSM_RESERVED_TMSI)
92 mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi);
93 else
94 mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi);
Holger Freyther33ba7522009-02-06 22:33:25 +000095
96 page_group = calculate_group(request->bts, request->subscr);
Holger Hans Peter Freyther77008462010-06-16 14:10:45 +080097 gsm0808_page(request->bts, page_group, mi_len, mi, request->chan_type);
Holger Freyther33ba7522009-02-06 22:33:25 +000098}
99
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800100static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
101{
102 if (llist_empty(&paging_bts->pending_requests))
103 return;
104
105 if (!bsc_timer_pending(&paging_bts->work_timer))
106 bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
107}
108
109
Holger Hans Peter Freyther78fab292010-04-20 10:59:33 +0800110static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts);
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800111static void paging_give_credit(void *data)
112{
113 struct gsm_bts_paging_state *paging_bts = data;
114
115 LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n", paging_bts->bts->nr);
116 paging_bts->available_slots = 20;
Holger Hans Peter Freyther78fab292010-04-20 10:59:33 +0800117 paging_handle_pending_requests(paging_bts);
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800118}
119
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800120static int can_send_pag_req(struct gsm_bts *bts, int rsl_type)
121{
122 struct pchan_load pl;
123 int count;
124
125 memset(&pl, 0, sizeof(pl));
126 bts_chan_load(&pl, bts);
127
128 switch (rsl_type) {
129 case RSL_CHANNEED_TCH_F:
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800130 case RSL_CHANNEED_TCH_ForH:
Holger Hans Peter Freyther2e4447b2010-04-20 17:15:21 +0800131 goto count_tch;
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800132 break;
133 case RSL_CHANNEED_SDCCH:
134 goto count_sdcch;
135 break;
136 case RSL_CHANNEED_ANY:
137 default:
138 if (bts->network->pag_any_tch)
Holger Hans Peter Freyther2e4447b2010-04-20 17:15:21 +0800139 goto count_tch;
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800140 else
141 goto count_sdcch;
142 break;
143 }
144
145 return 0;
146
147 /* could available SDCCH */
148count_sdcch:
149 count = 0;
150 count += pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].total
151 - pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].used;
152 count += pl.pchan[GSM_PCHAN_CCCH_SDCCH4].total
153 - pl.pchan[GSM_PCHAN_CCCH_SDCCH4].used;
154 return bts->paging.free_chans_need > count;
Holger Hans Peter Freyther2e4447b2010-04-20 17:15:21 +0800155
156count_tch:
157 count = 0;
158 count += pl.pchan[GSM_PCHAN_TCH_F].total
159 - pl.pchan[GSM_PCHAN_TCH_F].used;
160 if (bts->network->neci)
161 count += pl.pchan[GSM_PCHAN_TCH_H].total
162 - pl.pchan[GSM_PCHAN_TCH_H].used;
163 return bts->paging.free_chans_need > count;
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800164}
165
Holger Freythere36e15e2009-02-14 18:05:03 +0000166/*
167 * This is kicked by the periodic PAGING LOAD Indicator
168 * coming from abis_rsl.c
169 *
170 * We attempt to iterate once over the list of items but
171 * only upto available_slots.
172 */
Holger Freytherb1ffbb62009-02-11 01:49:15 +0000173static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts)
174{
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800175 struct gsm_paging_request *request = NULL;
Harald Welte38c2f132009-01-06 23:10:57 +0000176
Holger Freythere36e15e2009-02-14 18:05:03 +0000177 /*
178 * Determine if the pending_requests list is empty and
179 * return then.
180 */
Harald Welte75a1fa82009-02-17 01:39:41 +0000181 if (llist_empty(&paging_bts->pending_requests)) {
Harald Welte75a1fa82009-02-17 01:39:41 +0000182 /* since the list is empty, no need to reschedule the timer */
Harald Welte38c2f132009-01-06 23:10:57 +0000183 return;
184 }
185
Holger Hans Peter Freyther19722d42010-04-09 18:38:06 +0200186 /*
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800187 * In case the BTS does not provide us with load indication and we
188 * ran out of slots, call an autofill routine. It might be that the
189 * BTS did not like our paging messages and then we have counted down
190 * to zero and we do not get any messages.
Holger Hans Peter Freyther19722d42010-04-09 18:38:06 +0200191 */
192 if (paging_bts->available_slots == 0) {
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800193 paging_bts->credit_timer.cb = paging_give_credit;
194 paging_bts->credit_timer.data = paging_bts;
195 bsc_schedule_timer(&paging_bts->credit_timer, 5, 0);
196 return;
Holger Hans Peter Freyther19722d42010-04-09 18:38:06 +0200197 }
198
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800199 request = llist_entry(paging_bts->pending_requests.next,
200 struct gsm_paging_request, entry);
Holger Freythere36e15e2009-02-14 18:05:03 +0000201
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800202 /* we need to determine the number of free channels */
203 if (paging_bts->free_chans_need != -1) {
204 if (can_send_pag_req(request->bts, request->chan_type) != 0)
205 goto skip_paging;
206 }
207
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800208 /* handle the paging request now */
209 page_ms(request);
210 paging_bts->available_slots--;
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +0100211 request->attempts++;
Holger Freythere36e15e2009-02-14 18:05:03 +0000212
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800213 /* take the current and add it to the back */
214 llist_del(&request->entry);
215 llist_add_tail(&request->entry, &paging_bts->pending_requests);
Holger Hans Peter Freyther754e8012010-04-09 21:53:35 +0200216
Holger Hans Peter Freythere66bf1f2010-09-06 10:11:25 +0800217skip_paging:
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800218 bsc_schedule_timer(&paging_bts->work_timer, PAGING_TIMER);
Harald Welte75a1fa82009-02-17 01:39:41 +0000219}
220
221static void paging_worker(void *data)
222{
223 struct gsm_bts_paging_state *paging_bts = data;
224
225 paging_handle_pending_requests(paging_bts);
Harald Welte38c2f132009-01-06 23:10:57 +0000226}
227
Holger Freyther1fd34142009-02-09 23:42:03 +0000228void paging_init(struct gsm_bts *bts)
Holger Freytherceb59b72009-02-06 18:54:00 +0000229{
230 bts->paging.bts = bts;
231 INIT_LLIST_HEAD(&bts->paging.pending_requests);
Harald Welte75a1fa82009-02-17 01:39:41 +0000232 bts->paging.work_timer.cb = paging_worker;
233 bts->paging.work_timer.data = &bts->paging;
Holger Freyther392209c2009-02-10 00:06:19 +0000234
235 /* Large number, until we get a proper message */
Holger Hans Peter Freyther14696002010-04-09 22:55:55 +0200236 bts->paging.available_slots = 20;
Holger Freytherceb59b72009-02-06 18:54:00 +0000237}
238
Holger Freyther1fd34142009-02-09 23:42:03 +0000239static int paging_pending_request(struct gsm_bts_paging_state *bts,
Harald Welteb68899d2009-01-06 21:47:18 +0000240 struct gsm_subscriber *subscr) {
Holger Freytherceb59b72009-02-06 18:54:00 +0000241 struct gsm_paging_request *req;
Harald Welteb68899d2009-01-06 21:47:18 +0000242
243 llist_for_each_entry(req, &bts->pending_requests, entry) {
244 if (subscr == req->subscr)
245 return 1;
246 }
247
248 return 0;
249}
250
Harald Welte51cce1e2009-02-10 17:35:04 +0000251static void paging_T3113_expired(void *data)
252{
Holger Freyther83e44b02009-02-14 18:04:59 +0000253 struct gsm_paging_request *req = (struct gsm_paging_request *)data;
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100254 void *cbfn_param;
255 gsm_cbfn *cbfn;
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +0100256 int msg;
Harald Welte51cce1e2009-02-10 17:35:04 +0000257
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +0200258 LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n",
Harald Welte51cce1e2009-02-10 17:35:04 +0000259 req, req->subscr->imsi);
Holger Freyther4af2b482009-02-14 22:51:03 +0000260
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100261 /* must be destroyed before calling cbfn, to prevent double free */
Holger Hans Peter Freyther07d838a2010-04-08 16:48:46 +0200262 counter_inc(req->bts->network->stats.paging.expired);
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100263 cbfn_param = req->cbfn_param;
264 cbfn = req->cbfn;
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +0100265
266 /* did we ever manage to page the subscriber */
267 msg = req->attempts > 0 ? GSM_PAGING_EXPIRED : GSM_PAGING_BUSY;
268
269 /* destroy it now. Do not access req afterwards */
Harald Welte51cce1e2009-02-10 17:35:04 +0000270 paging_remove_request(&req->bts->paging, req);
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100271
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100272 if (cbfn)
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +0100273 cbfn(GSM_HOOK_RR_PAGING, msg, NULL, NULL,
Holger Hans Peter Freytherfe9da822009-11-17 10:16:46 +0100274 cbfn_param);
Harald Welte51cce1e2009-02-10 17:35:04 +0000275}
276
Harald Weltee903edf2009-08-15 03:16:17 +0200277static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200278 int type, gsm_cbfn *cbfn, void *data)
Harald Welte09e38af2009-02-16 22:52:23 +0000279{
Holger Freytherceb59b72009-02-06 18:54:00 +0000280 struct gsm_bts_paging_state *bts_entry = &bts->paging;
281 struct gsm_paging_request *req;
Harald Welteb68899d2009-01-06 21:47:18 +0000282
Holger Freyther49314f62009-02-14 23:53:20 +0000283 if (paging_pending_request(bts_entry, subscr)) {
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +0200284 LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi);
Harald Weltee903edf2009-08-15 03:16:17 +0200285 return -EEXIST;
Holger Freyther49314f62009-02-14 23:53:20 +0000286 }
287
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +0200288 LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n",
Harald Weltef6cea1d2009-08-08 15:08:19 +0200289 subscr->id, bts->nr);
Harald Welte470ec292009-06-26 20:25:23 +0200290 req = talloc_zero(tall_paging_ctx, struct gsm_paging_request);
Harald Welteb68899d2009-01-06 21:47:18 +0000291 req->subscr = subscr_get(subscr);
292 req->bts = bts;
Harald Welte38c2f132009-01-06 23:10:57 +0000293 req->chan_type = type;
Harald Welte09e38af2009-02-16 22:52:23 +0000294 req->cbfn = cbfn;
295 req->cbfn_param = data;
Harald Welte51cce1e2009-02-10 17:35:04 +0000296 req->T3113.cb = paging_T3113_expired;
297 req->T3113.data = req;
Holger Hans Peter Freyther4642d492009-11-21 21:48:53 +0100298 bsc_schedule_timer(&req->T3113, bts->network->T3113, 0);
Holger Freyther49314f62009-02-14 23:53:20 +0000299 llist_add_tail(&req->entry, &bts_entry->pending_requests);
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800300 paging_schedule_if_needed(bts_entry);
Harald Weltee903edf2009-08-15 03:16:17 +0200301
302 return 0;
Harald Welteb68899d2009-01-06 21:47:18 +0000303}
Harald Welte763da002009-02-06 12:52:14 +0000304
Harald Weltee903edf2009-08-15 03:16:17 +0200305int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr,
306 int type, gsm_cbfn *cbfn, void *data)
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200307{
308 struct gsm_bts *bts = NULL;
Harald Welte (local)0abaf332009-08-15 11:25:45 +0200309 int num_pages = 0;
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200310
Harald Welteffa55a42009-12-22 19:07:32 +0100311 counter_inc(network->stats.paging.attempted);
Harald Welte24ff6ee2009-12-22 00:41:05 +0100312
Harald Weltea1b28582009-08-01 19:31:47 +0200313 /* start paging subscriber on all BTS within Location Area */
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200314 do {
Harald Welte (local)0abaf332009-08-15 11:25:45 +0200315 int rc;
316
Holger Freyther04866d42009-03-31 04:35:19 +0200317 bts = gsm_bts_by_lac(network, subscr->lac, bts);
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200318 if (!bts)
319 break;
Harald Welte (local)82ff3972009-12-28 16:36:28 +0100320
321 /* skip all currently inactive TRX */
322 if (!trx_is_usable(bts->c0))
323 continue;
324
Harald Welte (local)0abaf332009-08-15 11:25:45 +0200325 num_pages++;
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200326
Harald Weltee903edf2009-08-15 03:16:17 +0200327 /* Trigger paging, pass any error to caller */
328 rc = _paging_request(bts, subscr, type, cbfn, data);
329 if (rc < 0)
330 return rc;
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200331 } while (1);
Harald Weltee903edf2009-08-15 03:16:17 +0200332
Harald Welte24ff6ee2009-12-22 00:41:05 +0100333 if (num_pages == 0)
Harald Welteffa55a42009-12-22 19:07:32 +0100334 counter_inc(network->stats.paging.detached);
Harald Welte24ff6ee2009-12-22 00:41:05 +0100335
Harald Welte (local)0abaf332009-08-15 11:25:45 +0200336 return num_pages;
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200337}
338
339
Harald Welte763da002009-02-06 12:52:14 +0000340/* we consciously ignore the type of the request here */
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200341static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr,
Sylvain Munautc7ff2572010-12-01 21:41:35 +0100342 struct gsm_subscriber_connection *conn,
343 struct msgb *msg)
Harald Welte763da002009-02-06 12:52:14 +0000344{
Holger Freytherceb59b72009-02-06 18:54:00 +0000345 struct gsm_bts_paging_state *bts_entry = &bts->paging;
346 struct gsm_paging_request *req, *req2;
Harald Welte763da002009-02-06 12:52:14 +0000347
348 llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests,
349 entry) {
Holger Freyther3d949242009-02-06 18:08:18 +0000350 if (req->subscr == subscr) {
Holger Hans Peter Freyther86481c22010-06-17 15:05:57 +0800351 if (conn && req->cbfn) {
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +0200352 LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d, calling cbfn.\n", bts->nr);
Harald Welte09e38af2009-02-16 22:52:23 +0000353 req->cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED,
Sylvain Munautc7ff2572010-12-01 21:41:35 +0100354 msg, conn, req->cbfn_param);
Harald Welte4bfdfe72009-06-10 23:11:52 +0800355 } else
Holger Hans Peter Freytherc50b8362010-04-09 22:02:39 +0200356 LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d silently.\n", bts->nr);
Holger Freyther1fd34142009-02-09 23:42:03 +0000357 paging_remove_request(&bts->paging, req);
Holger Freyther3d949242009-02-06 18:08:18 +0000358 break;
359 }
Harald Welte763da002009-02-06 12:52:14 +0000360 }
361}
Holger Freyther392209c2009-02-10 00:06:19 +0000362
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200363/* Stop paging on all other bts' */
364void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
Sylvain Munautc7ff2572010-12-01 21:41:35 +0100365 struct gsm_subscriber_connection *conn,
366 struct msgb *msg)
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200367{
368 struct gsm_bts *bts = NULL;
369
Holger Hans Peter Freyther927f0562009-08-21 05:43:44 +0200370 if (_bts)
Sylvain Munautc7ff2572010-12-01 21:41:35 +0100371 _paging_request_stop(_bts, subscr, conn, msg);
Holger Hans Peter Freytherfdac4cc2009-06-10 11:46:58 +0200372
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200373 do {
374 /*
375 * FIXME: Don't use the lac of the subscriber...
376 * as it might have magically changed the lac.. use the
377 * location area of the _bts as reconfiguration of the
378 * network is probably happening less often.
379 */
Holger Hans Peter Freyther927f0562009-08-21 05:43:44 +0200380 bts = gsm_bts_by_lac(subscr->net, subscr->lac, bts);
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200381 if (!bts)
382 break;
383
384 /* Stop paging */
Holger Hans Peter Freythera5811362010-04-30 13:32:05 +0800385 if (bts != _bts)
Sylvain Munautc7ff2572010-12-01 21:41:35 +0100386 _paging_request_stop(bts, subscr, NULL, NULL);
Holger Hans Peter Freyther2c451232009-06-10 02:45:42 +0200387 } while (1);
388}
389
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200390void paging_update_buffer_space(struct gsm_bts *bts, uint16_t free_slots)
Holger Freyther392209c2009-02-10 00:06:19 +0000391{
Holger Hans Peter Freyther6410d932010-04-19 19:41:26 +0800392 bsc_del_timer(&bts->paging.credit_timer);
Holger Freyther392209c2009-02-10 00:06:19 +0000393 bts->paging.available_slots = free_slots;
Holger Hans Peter Freythereb241aa2010-09-06 10:05:23 +0800394 paging_schedule_if_needed(&bts->paging);
Holger Freyther392209c2009-02-10 00:06:19 +0000395}