2009-01-06 21:47:18 +00:00
|
|
|
/* Paging helper and manager.... */
|
|
|
|
/* (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
|
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2011-01-01 14:25:50 +00:00
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2009-01-06 21:47:18 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2011-01-01 14:25:50 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
2009-01-06 21:47:18 +00:00
|
|
|
*
|
2011-01-01 14:25:50 +00:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-01-06 21:47:18 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PAGING_H
|
|
|
|
#define PAGING_H
|
|
|
|
|
2009-05-21 07:23:02 +00:00
|
|
|
#include <stdlib.h>
|
2009-01-06 21:47:18 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/linuxlist.h>
|
|
|
|
#include <osmocom/core/timer.h>
|
2009-01-06 21:47:18 +00:00
|
|
|
|
2017-09-04 13:15:32 +00:00
|
|
|
#include <osmocom/bsc/gsm_data.h>
|
|
|
|
#include <osmocom/bsc/bsc_subscriber.h>
|
2020-09-18 00:49:15 +00:00
|
|
|
#include <osmocom/bsc/bsc_msc_data.h>
|
2017-01-25 15:15:43 +00:00
|
|
|
|
2017-12-11 14:21:48 +00:00
|
|
|
struct bsc_msc_data;
|
|
|
|
|
2020-09-18 00:49:15 +00:00
|
|
|
#define LOG_PAGING(PARAMS, SUBSYS, LEVEL, fmt, args...) \
|
2022-04-27 12:49:47 +00:00
|
|
|
LOGP(SUBSYS, LEVEL, "(msc=%d) Paging%s: %s: " fmt, \
|
2020-09-18 00:49:15 +00:00
|
|
|
(PARAMS)->msc ? (PARAMS)->msc->nr : -1, \
|
2020-09-18 00:49:21 +00:00
|
|
|
(PARAMS)->reason == BSC_PAGING_FOR_LCS ? " for LCS" : "", \
|
2020-09-18 02:02:13 +00:00
|
|
|
bsc_subscr_name((PARAMS)->bsub), \
|
2020-09-18 00:49:15 +00:00
|
|
|
##args)
|
|
|
|
|
|
|
|
#define LOG_PAGING_BTS(PARAMS, BTS, SUBSYS, LEVEL, fmt, args...) \
|
2022-04-27 12:49:47 +00:00
|
|
|
LOG_PAGING(PARAMS, SUBSYS, LEVEL, "(bts=%u) " fmt, (BTS) ? (BTS)->nr : 255, ##args)
|
2020-09-18 00:49:15 +00:00
|
|
|
|
2020-09-15 01:03:58 +00:00
|
|
|
#define BSUB_USE_PAGING_START "paging-start"
|
|
|
|
#define BSUB_USE_PAGING_REQUEST "paging-req"
|
|
|
|
|
2020-09-18 00:49:21 +00:00
|
|
|
/* Bitmask of reasons for Paging. Each individual Paging via bsc_paging_start() typically has only one of these reasons
|
|
|
|
* set, but when a subscriber responds, we need to aggregate all pending Paging reasons (by bitwise-OR). */
|
|
|
|
enum bsc_paging_reason {
|
|
|
|
BSC_PAGING_NONE = 0,
|
|
|
|
BSC_PAGING_FROM_CN = 0x1,
|
|
|
|
BSC_PAGING_FOR_LCS = 0x2,
|
|
|
|
};
|
|
|
|
|
2022-11-28 11:13:24 +00:00
|
|
|
/* OS#5552, OS#5553: Maximum allowed scheduling transmit delay in paging
|
|
|
|
* requests to be queued, in seconds. If calculated delay for requests to be
|
|
|
|
* queued goes over this threshold, they are discarded instead of inserted to
|
|
|
|
* the queue. This avoids keeping queueing requests which will be scheduled for
|
|
|
|
* transmission too late.
|
|
|
|
*/
|
|
|
|
#define PAGING_THRESHOLD_X3113_DEFAULT_SEC 60
|
|
|
|
|
2022-11-29 11:37:53 +00:00
|
|
|
#define MAX_PAGING_BLOCKS_CCCH 9
|
|
|
|
#define MAX_BS_PA_MFRMS 9
|
|
|
|
|
2020-09-18 00:49:15 +00:00
|
|
|
struct bsc_paging_params {
|
2020-09-18 00:49:21 +00:00
|
|
|
enum bsc_paging_reason reason;
|
2020-09-18 00:49:15 +00:00
|
|
|
struct bsc_msc_data *msc;
|
2020-09-18 02:02:13 +00:00
|
|
|
struct bsc_subscr *bsub;
|
2020-09-18 00:49:15 +00:00
|
|
|
uint32_t tmsi;
|
|
|
|
struct osmo_mobile_identity imsi;
|
|
|
|
uint8_t chan_needed;
|
|
|
|
struct gsm0808_cell_id_list2 cil;
|
|
|
|
};
|
|
|
|
|
2010-11-09 16:00:42 +00:00
|
|
|
/**
|
|
|
|
* A pending paging request
|
|
|
|
*/
|
|
|
|
struct gsm_paging_request {
|
|
|
|
/* list_head for list of all paging requests */
|
|
|
|
struct llist_head entry;
|
2022-11-22 13:02:48 +00:00
|
|
|
/* the subscriber which we're paging. This struct is included using
|
|
|
|
* bsub_entry field in list bsub->active_paging_requests */
|
add struct bsc_subscr, separating libbsc from gsm_subscriber
In a future commit, gsm_subscriber will be replaced by vlr_subscr, and it will
not make sense to use vlr_subscr in libbsc. Thus we need a dedicated BSC
subscriber: struct bsc_subscr.
Add rf_policy arg to bsc_grace_paging_request() because the bsc_subscr will no
longer have a backpointer to gsm_network (used to be via subscr->group).
Create a separate logging filter for the new BSC subscriber. The implementation
of adjusting the filter context is added in libbsc to not introduce
bsc_subscr_get/_put() dependencies to libcommon.
During Paging Response, fetch a bsc_subscr from the mobile identity, like we do
for the gsm_subscriber. It looks like a duplication now, but will make sense
for the VLR as well as for future MSC split patches.
Naming: it was requested to not name the new struct bsc_sub, because 'sub' is
too ambiguous. At the same time it would be fine to have 'bsc_sub_' as function
prefix. Instead of struct bsc_subscriber and bsc_sub_ prefix, I decided to
match both up as struct bsc_subscr and bsc_subscr_ function prefix. It's fast
to type, relatively short, unambiguous, and the naming is consistent.
Add bsc_subscr unit test.
Related: OS#1592, OS#1594
Change-Id: Ia61cc00e8bb186b976939a4fc8f7cf9ce6aa3d8e
2017-02-18 21:20:46 +00:00
|
|
|
struct bsc_subscr *bsub;
|
2022-11-22 13:02:48 +00:00
|
|
|
struct llist_head bsub_entry;
|
2010-11-09 16:00:42 +00:00
|
|
|
/* back-pointer to the BTS on which we are paging */
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
/* what kind of channel type do we ask the MS to establish */
|
|
|
|
int chan_type;
|
2022-04-27 12:22:58 +00:00
|
|
|
/* paging group of the subscriber: */
|
|
|
|
uint8_t pgroup;
|
2010-11-09 16:00:42 +00:00
|
|
|
|
|
|
|
/* Timer 3113: how long do we try to page? */
|
2011-05-06 10:11:06 +00:00
|
|
|
struct osmo_timer_list T3113;
|
2010-11-09 16:00:42 +00:00
|
|
|
|
2010-12-23 17:19:17 +00:00
|
|
|
/* How often did we ask the BTS to page? */
|
|
|
|
int attempts;
|
2022-04-26 11:58:50 +00:00
|
|
|
/* Timestamp of last time the subscriber was paged */
|
|
|
|
struct timespec last_attempt_ts;
|
2010-12-23 17:19:17 +00:00
|
|
|
|
2017-12-11 14:21:48 +00:00
|
|
|
/* MSC that has issued this paging */
|
|
|
|
struct bsc_msc_data *msc;
|
2020-09-18 00:49:21 +00:00
|
|
|
|
|
|
|
enum bsc_paging_reason reason;
|
2010-11-09 16:00:42 +00:00
|
|
|
};
|
|
|
|
|
2022-04-21 12:14:15 +00:00
|
|
|
/*
|
|
|
|
* This keeps track of the paging status of one BTS. It
|
|
|
|
* includes a number of pending requests, a back pointer
|
|
|
|
* to the gsm_bts, a timer and some more state.
|
|
|
|
*/
|
|
|
|
struct gsm_bts_paging_state {
|
2022-11-28 17:51:53 +00:00
|
|
|
/* pending requests (initial paging request, no retransmits) */
|
|
|
|
struct llist_head initial_req_list;
|
|
|
|
/* Number of requests in initial_req_list */
|
|
|
|
unsigned int initial_req_list_len;
|
|
|
|
/* pending requests (already transmitted at least once) */
|
|
|
|
struct llist_head retrans_req_list;
|
2022-05-06 13:41:51 +00:00
|
|
|
/* Number of requests in pending_requests_len */
|
2022-11-28 17:51:53 +00:00
|
|
|
unsigned int retrans_req_list_len;
|
|
|
|
|
2022-11-29 11:37:53 +00:00
|
|
|
/* Number of requests in initial_req_list, indexed by pgroup. */
|
|
|
|
unsigned int initial_req_pgroup_counts[MAX_PAGING_BLOCKS_CCCH * MAX_BS_PA_MFRMS];
|
|
|
|
|
2022-04-21 12:14:15 +00:00
|
|
|
struct gsm_bts *bts;
|
|
|
|
|
|
|
|
struct osmo_timer_list work_timer;
|
|
|
|
struct osmo_timer_list credit_timer;
|
|
|
|
|
2022-05-05 16:20:15 +00:00
|
|
|
/* Last time paging worker was triggered */
|
|
|
|
struct timespec last_sched_ts;
|
|
|
|
|
2022-04-21 12:14:15 +00:00
|
|
|
/* free chans needed */
|
|
|
|
int free_chans_need;
|
|
|
|
|
|
|
|
/* load */
|
|
|
|
uint16_t available_slots;
|
|
|
|
};
|
|
|
|
|
2022-05-04 17:27:34 +00:00
|
|
|
void paging_global_init(void);
|
|
|
|
|
2022-04-21 12:00:32 +00:00
|
|
|
void paging_init(struct gsm_bts *bts);
|
2022-04-25 16:41:07 +00:00
|
|
|
void paging_destructor(struct gsm_bts *bts);
|
2022-04-21 12:00:32 +00:00
|
|
|
|
2009-01-06 21:47:18 +00:00
|
|
|
/* schedule paging request */
|
2020-09-18 02:02:13 +00:00
|
|
|
int paging_request_bts(const struct bsc_paging_params *params, struct gsm_bts *bts);
|
2009-01-06 21:47:18 +00:00
|
|
|
|
2022-11-22 12:45:16 +00:00
|
|
|
void paging_request_stop(struct bsc_msc_data **msc_p, enum bsc_paging_reason *reasons_p,
|
2020-09-18 00:49:21 +00:00
|
|
|
struct gsm_bts *bts, struct bsc_subscr *bsub);
|
2022-11-22 12:45:16 +00:00
|
|
|
void paging_request_cancel(struct bsc_subscr *bsub, enum bsc_paging_reason reasons);
|
2009-02-06 12:52:14 +00:00
|
|
|
|
2011-04-26 13:52:34 +00:00
|
|
|
/* pending paging requests */
|
2022-11-24 16:05:53 +00:00
|
|
|
unsigned int paging_pending_requests_nr(const struct gsm_bts *bts);
|
2011-04-26 13:52:34 +00:00
|
|
|
|
2017-12-11 14:33:35 +00:00
|
|
|
void paging_flush_bts(struct gsm_bts *bts, struct bsc_msc_data *msc);
|
|
|
|
void paging_flush_network(struct gsm_network *net, struct bsc_msc_data *msc);
|
|
|
|
|
2022-11-24 16:05:53 +00:00
|
|
|
uint16_t paging_estimate_available_slots(const struct gsm_bts *bts, unsigned int time_span_s);
|
2022-04-25 16:05:17 +00:00
|
|
|
|
2020-09-18 00:49:32 +00:00
|
|
|
int bsc_paging_start(struct bsc_paging_params *params);
|
2009-01-06 21:47:18 +00:00
|
|
|
#endif
|