blob: 2d0f8da6a853f1da178913fb1326e291918bb22d [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#ifndef PAGING_H
21#define PAGING_H
22
Harald Welte12247c62009-05-21 07:23:02 +000023#include <stdlib.h>
Harald Welteb68899d2009-01-06 21:47:18 +000024#include <string.h>
25
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010026#include <osmocom/core/linuxlist.h>
Pablo Neira Ayuso136f4532011-03-22 16:47:59 +010027#include <osmocom/core/timer.h>
Harald Welteb68899d2009-01-06 21:47:18 +000028
Neels Hofmeyrc0164792017-09-04 15:15:32 +020029#include <osmocom/bsc/gsm_data.h>
30#include <osmocom/bsc/bsc_subscriber.h>
Neels Hofmeyr766f5902020-09-18 02:49:15 +020031#include <osmocom/bsc/bsc_msc_data.h>
Neels Hofmeyra5c71bf2017-01-25 16:15:43 +010032
Harald Weltef4b66fb2017-12-11 15:21:48 +010033struct bsc_msc_data;
34
Neels Hofmeyr766f5902020-09-18 02:49:15 +020035#define LOG_PAGING(PARAMS, SUBSYS, LEVEL, fmt, args...) \
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020036 LOGP(SUBSYS, LEVEL, "(msc%d) Paging%s: %s: " fmt, \
Neels Hofmeyr766f5902020-09-18 02:49:15 +020037 (PARAMS)->msc ? (PARAMS)->msc->nr : -1, \
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020038 (PARAMS)->reason == BSC_PAGING_FOR_LCS ? " for LCS" : "", \
Neels Hofmeyr4c5fd382020-09-18 04:02:13 +020039 bsc_subscr_name((PARAMS)->bsub), \
Neels Hofmeyr766f5902020-09-18 02:49:15 +020040 ##args)
41
42#define LOG_PAGING_BTS(PARAMS, BTS, SUBSYS, LEVEL, fmt, args...) \
43 LOG_PAGING(PARAMS, SUBSYS, LEVEL, "(bts%u) " fmt, (BTS) ? (BTS)->nr : 255, ##args)
44
Neels Hofmeyr86a1dca2020-09-15 01:03:58 +000045#define BSUB_USE_PAGING_START "paging-start"
46#define BSUB_USE_PAGING_REQUEST "paging-req"
47
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020048/* Bitmask of reasons for Paging. Each individual Paging via bsc_paging_start() typically has only one of these reasons
49 * set, but when a subscriber responds, we need to aggregate all pending Paging reasons (by bitwise-OR). */
50enum bsc_paging_reason {
51 BSC_PAGING_NONE = 0,
52 BSC_PAGING_FROM_CN = 0x1,
53 BSC_PAGING_FOR_LCS = 0x2,
54};
55
Neels Hofmeyr766f5902020-09-18 02:49:15 +020056struct bsc_paging_params {
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020057 enum bsc_paging_reason reason;
Neels Hofmeyr766f5902020-09-18 02:49:15 +020058 struct bsc_msc_data *msc;
Neels Hofmeyr4c5fd382020-09-18 04:02:13 +020059 struct bsc_subscr *bsub;
Neels Hofmeyr766f5902020-09-18 02:49:15 +020060 uint32_t tmsi;
61 struct osmo_mobile_identity imsi;
62 uint8_t chan_needed;
63 struct gsm0808_cell_id_list2 cil;
64};
65
Holger Hans Peter Freyther85334f12010-11-09 17:00:42 +010066/**
67 * A pending paging request
68 */
69struct gsm_paging_request {
70 /* list_head for list of all paging requests */
71 struct llist_head entry;
72 /* the subscriber which we're paging. Later gsm_paging_request
Neels Hofmeyr6d804b12017-02-18 22:20:46 +010073 * should probably become a part of the bsc_subsrc struct? */
74 struct bsc_subscr *bsub;
Holger Hans Peter Freyther85334f12010-11-09 17:00:42 +010075 /* back-pointer to the BTS on which we are paging */
76 struct gsm_bts *bts;
77 /* what kind of channel type do we ask the MS to establish */
78 int chan_type;
79
80 /* Timer 3113: how long do we try to page? */
Pablo Neira Ayusobf540cb2011-05-06 12:11:06 +020081 struct osmo_timer_list T3113;
Holger Hans Peter Freyther85334f12010-11-09 17:00:42 +010082
Holger Hans Peter Freytherd3baf412010-12-23 18:19:17 +010083 /* How often did we ask the BTS to page? */
84 int attempts;
85
Harald Weltef4b66fb2017-12-11 15:21:48 +010086 /* MSC that has issued this paging */
87 struct bsc_msc_data *msc;
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020088
89 enum bsc_paging_reason reason;
Holger Hans Peter Freyther85334f12010-11-09 17:00:42 +010090};
91
Harald Welteb68899d2009-01-06 21:47:18 +000092/* schedule paging request */
Neels Hofmeyr4c5fd382020-09-18 04:02:13 +020093int paging_request_bts(const struct bsc_paging_params *params, struct gsm_bts *bts);
Harald Welteb68899d2009-01-06 21:47:18 +000094
Neels Hofmeyrd4946b22020-09-18 02:49:21 +020095int paging_request_stop(struct bsc_msc_data **msc_p, enum bsc_paging_reason *reasons_p,
96 struct gsm_bts *bts, struct bsc_subscr *bsub);
Neels Hofmeyr4ae338d2020-09-17 17:54:39 +020097int paging_request_cancel(struct bsc_subscr *bsub, enum bsc_paging_reason reasons);
Harald Welte763da002009-02-06 12:52:14 +000098
Holger Freyther392209c2009-02-10 00:06:19 +000099/* update paging load */
Holger Hans Peter Freytherc42ad8b2011-04-18 17:04:00 +0200100void paging_update_buffer_space(struct gsm_bts *bts, uint16_t);
Holger Freyther392209c2009-02-10 00:06:19 +0000101
Holger Hans Peter Freyther66e14cd2011-04-26 15:52:34 +0200102/* pending paging requests */
103unsigned int paging_pending_requests_nr(struct gsm_bts *bts);
104
Harald Welted382bf62017-12-11 15:33:35 +0100105void paging_flush_bts(struct gsm_bts *bts, struct bsc_msc_data *msc);
106void paging_flush_network(struct gsm_network *net, struct bsc_msc_data *msc);
107
Neels Hofmeyr86ce1052020-09-18 02:49:32 +0200108int bsc_paging_start(struct bsc_paging_params *params);
Harald Welteb68899d2009-01-06 21:47:18 +0000109#endif