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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Relevant specs:
|
|
|
|
* 12.21:
|
|
|
|
* - 9.4.12 for CCCH Local Threshold
|
|
|
|
*
|
|
|
|
* 05.58:
|
|
|
|
* - 8.5.2 CCCH Load indication
|
|
|
|
* - 9.3.15 Paging Load
|
|
|
|
*
|
|
|
|
* Approach:
|
|
|
|
* - Send paging command to subscriber
|
|
|
|
* - On Channel Request we will remember the reason
|
|
|
|
* - After the ACK we will request the identity
|
|
|
|
* - Then we will send assign the gsm_subscriber and
|
|
|
|
* - and call a callback
|
|
|
|
*/
|
|
|
|
|
2009-01-06 23:50:39 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2009-02-14 18:05:03 +00:00
|
|
|
#include <assert.h>
|
2009-01-06 23:50:39 +00:00
|
|
|
|
2009-01-06 21:47:18 +00:00
|
|
|
#include <openbsc/paging.h>
|
2011-03-22 15:47:59 +00:00
|
|
|
#include <osmocom/core/talloc.h>
|
2009-01-06 21:47:18 +00:00
|
|
|
#include <openbsc/debug.h>
|
2009-02-14 22:51:03 +00:00
|
|
|
#include <openbsc/signal.h>
|
2009-01-06 23:50:39 +00:00
|
|
|
#include <openbsc/abis_rsl.h>
|
2009-02-06 18:54:00 +00:00
|
|
|
#include <openbsc/gsm_data.h>
|
2010-04-09 22:06:17 +00:00
|
|
|
#include <openbsc/chan_alloc.h>
|
2010-06-17 08:43:24 +00:00
|
|
|
#include <openbsc/bsc_api.h>
|
2009-01-06 21:47:18 +00:00
|
|
|
|
2009-08-15 00:30:58 +00:00
|
|
|
void *tall_paging_ctx;
|
2009-06-20 20:36:41 +00:00
|
|
|
|
2010-09-06 02:05:23 +00:00
|
|
|
#define PAGING_TIMER 0, 500000
|
|
|
|
|
2009-02-04 02:14:45 +00:00
|
|
|
static unsigned int calculate_group(struct gsm_bts *bts, struct gsm_subscriber *subscr)
|
|
|
|
{
|
|
|
|
int ccch_conf;
|
|
|
|
int bs_cc_chans;
|
|
|
|
int blocks;
|
|
|
|
unsigned int group;
|
|
|
|
|
2009-12-01 12:34:30 +00:00
|
|
|
ccch_conf = bts->si_common.chan_desc.ccch_conf;
|
2009-02-04 02:14:45 +00:00
|
|
|
bs_cc_chans = rsl_ccch_conf_to_bs_cc_chans(ccch_conf);
|
|
|
|
/* code word + 2, as 2 channels equals 0x0 */
|
2009-02-04 13:38:26 +00:00
|
|
|
blocks = rsl_number_of_paging_subchannels(bts);
|
2009-02-04 02:14:45 +00:00
|
|
|
group = get_paging_group(str_to_imsi(subscr->imsi),
|
|
|
|
bs_cc_chans, blocks);
|
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
2009-01-06 23:10:57 +00:00
|
|
|
/*
|
|
|
|
* Kill one paging request update the internal list...
|
|
|
|
*/
|
2009-02-09 23:42:03 +00:00
|
|
|
static void paging_remove_request(struct gsm_bts_paging_state *paging_bts,
|
2009-02-06 18:54:00 +00:00
|
|
|
struct gsm_paging_request *to_be_deleted)
|
2009-02-06 18:08:18 +00:00
|
|
|
{
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_del(&to_be_deleted->T3113);
|
2009-01-06 23:10:57 +00:00
|
|
|
llist_del(&to_be_deleted->entry);
|
2009-02-10 17:35:04 +00:00
|
|
|
subscr_put(to_be_deleted->subscr);
|
2009-06-20 20:36:41 +00:00
|
|
|
talloc_free(to_be_deleted);
|
2009-01-06 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
2009-02-06 22:33:25 +00:00
|
|
|
static void page_ms(struct gsm_paging_request *request)
|
|
|
|
{
|
2011-04-18 15:04:00 +00:00
|
|
|
uint8_t mi[128];
|
2009-01-06 23:50:39 +00:00
|
|
|
unsigned int mi_len;
|
2009-02-06 22:33:25 +00:00
|
|
|
unsigned int page_group;
|
|
|
|
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_INFO, "Going to send paging commands: imsi: '%s' tmsi: '0x%x'\n",
|
2009-08-21 12:55:57 +00:00
|
|
|
request->subscr->imsi, request->subscr->tmsi);
|
|
|
|
|
|
|
|
if (request->subscr->tmsi == GSM_RESERVED_TMSI)
|
|
|
|
mi_len = gsm48_generate_mid_from_imsi(mi, request->subscr->imsi);
|
|
|
|
else
|
|
|
|
mi_len = gsm48_generate_mid_from_tmsi(mi, request->subscr->tmsi);
|
2009-02-06 22:33:25 +00:00
|
|
|
|
|
|
|
page_group = calculate_group(request->bts, request->subscr);
|
2010-06-16 06:10:45 +00:00
|
|
|
gsm0808_page(request->bts, page_group, mi_len, mi, request->chan_type);
|
2009-02-06 22:33:25 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 02:05:23 +00:00
|
|
|
static void paging_schedule_if_needed(struct gsm_bts_paging_state *paging_bts)
|
|
|
|
{
|
|
|
|
if (llist_empty(&paging_bts->pending_requests))
|
|
|
|
return;
|
|
|
|
|
2011-05-06 10:11:06 +00:00
|
|
|
if (!osmo_timer_pending(&paging_bts->work_timer))
|
|
|
|
osmo_timer_schedule(&paging_bts->work_timer, PAGING_TIMER);
|
2010-09-06 02:05:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-04-20 02:59:33 +00:00
|
|
|
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts);
|
2010-04-19 11:41:26 +00:00
|
|
|
static void paging_give_credit(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_bts_paging_state *paging_bts = data;
|
|
|
|
|
|
|
|
LOGP(DPAG, LOGL_NOTICE, "No slots available on bts nr %d\n", paging_bts->bts->nr);
|
|
|
|
paging_bts->available_slots = 20;
|
2010-04-20 02:59:33 +00:00
|
|
|
paging_handle_pending_requests(paging_bts);
|
2010-04-19 11:41:26 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 02:11:25 +00:00
|
|
|
static int can_send_pag_req(struct gsm_bts *bts, int rsl_type)
|
|
|
|
{
|
|
|
|
struct pchan_load pl;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
memset(&pl, 0, sizeof(pl));
|
|
|
|
bts_chan_load(&pl, bts);
|
|
|
|
|
|
|
|
switch (rsl_type) {
|
|
|
|
case RSL_CHANNEED_TCH_F:
|
|
|
|
case RSL_CHANNEED_TCH_ForH:
|
2010-04-20 09:15:21 +00:00
|
|
|
goto count_tch;
|
2010-09-06 02:11:25 +00:00
|
|
|
break;
|
|
|
|
case RSL_CHANNEED_SDCCH:
|
|
|
|
goto count_sdcch;
|
|
|
|
break;
|
|
|
|
case RSL_CHANNEED_ANY:
|
|
|
|
default:
|
|
|
|
if (bts->network->pag_any_tch)
|
2010-04-20 09:15:21 +00:00
|
|
|
goto count_tch;
|
2010-09-06 02:11:25 +00:00
|
|
|
else
|
|
|
|
goto count_sdcch;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* could available SDCCH */
|
|
|
|
count_sdcch:
|
|
|
|
count = 0;
|
|
|
|
count += pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].total
|
|
|
|
- pl.pchan[GSM_PCHAN_SDCCH8_SACCH8C].used;
|
|
|
|
count += pl.pchan[GSM_PCHAN_CCCH_SDCCH4].total
|
|
|
|
- pl.pchan[GSM_PCHAN_CCCH_SDCCH4].used;
|
|
|
|
return bts->paging.free_chans_need > count;
|
2010-04-20 09:15:21 +00:00
|
|
|
|
|
|
|
count_tch:
|
|
|
|
count = 0;
|
|
|
|
count += pl.pchan[GSM_PCHAN_TCH_F].total
|
|
|
|
- pl.pchan[GSM_PCHAN_TCH_F].used;
|
|
|
|
if (bts->network->neci)
|
|
|
|
count += pl.pchan[GSM_PCHAN_TCH_H].total
|
|
|
|
- pl.pchan[GSM_PCHAN_TCH_H].used;
|
|
|
|
return bts->paging.free_chans_need > count;
|
2010-09-06 02:11:25 +00:00
|
|
|
}
|
|
|
|
|
2009-02-14 18:05:03 +00:00
|
|
|
/*
|
|
|
|
* This is kicked by the periodic PAGING LOAD Indicator
|
|
|
|
* coming from abis_rsl.c
|
|
|
|
*
|
|
|
|
* We attempt to iterate once over the list of items but
|
|
|
|
* only upto available_slots.
|
|
|
|
*/
|
2009-02-11 01:49:15 +00:00
|
|
|
static void paging_handle_pending_requests(struct gsm_bts_paging_state *paging_bts)
|
|
|
|
{
|
2010-09-06 02:05:23 +00:00
|
|
|
struct gsm_paging_request *request = NULL;
|
2009-02-14 18:05:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if the pending_requests list is empty and
|
|
|
|
* return then.
|
|
|
|
*/
|
2009-02-17 01:39:41 +00:00
|
|
|
if (llist_empty(&paging_bts->pending_requests)) {
|
|
|
|
/* since the list is empty, no need to reschedule the timer */
|
2009-01-06 23:10:57 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-09 16:38:06 +00:00
|
|
|
/*
|
2010-04-19 11:41:26 +00:00
|
|
|
* In case the BTS does not provide us with load indication and we
|
|
|
|
* ran out of slots, call an autofill routine. It might be that the
|
|
|
|
* BTS did not like our paging messages and then we have counted down
|
|
|
|
* to zero and we do not get any messages.
|
2010-04-09 16:38:06 +00:00
|
|
|
*/
|
|
|
|
if (paging_bts->available_slots == 0) {
|
2010-04-19 11:41:26 +00:00
|
|
|
paging_bts->credit_timer.cb = paging_give_credit;
|
|
|
|
paging_bts->credit_timer.data = paging_bts;
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&paging_bts->credit_timer, 5, 0);
|
2010-04-19 11:41:26 +00:00
|
|
|
return;
|
2010-04-09 16:38:06 +00:00
|
|
|
}
|
|
|
|
|
2010-09-06 02:05:23 +00:00
|
|
|
request = llist_entry(paging_bts->pending_requests.next,
|
|
|
|
struct gsm_paging_request, entry);
|
2009-02-14 18:05:03 +00:00
|
|
|
|
2010-09-06 02:11:25 +00:00
|
|
|
/* we need to determine the number of free channels */
|
|
|
|
if (paging_bts->free_chans_need != -1) {
|
|
|
|
if (can_send_pag_req(request->bts, request->chan_type) != 0)
|
|
|
|
goto skip_paging;
|
|
|
|
}
|
|
|
|
|
2010-09-06 02:05:23 +00:00
|
|
|
/* handle the paging request now */
|
|
|
|
page_ms(request);
|
|
|
|
paging_bts->available_slots--;
|
2010-12-23 17:19:17 +00:00
|
|
|
request->attempts++;
|
2009-02-14 18:05:03 +00:00
|
|
|
|
2010-09-06 02:05:23 +00:00
|
|
|
/* take the current and add it to the back */
|
|
|
|
llist_del(&request->entry);
|
|
|
|
llist_add_tail(&request->entry, &paging_bts->pending_requests);
|
2010-04-09 19:53:35 +00:00
|
|
|
|
2010-09-06 02:11:25 +00:00
|
|
|
skip_paging:
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&paging_bts->work_timer, PAGING_TIMER);
|
2009-02-17 01:39:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void paging_worker(void *data)
|
|
|
|
{
|
|
|
|
struct gsm_bts_paging_state *paging_bts = data;
|
|
|
|
|
|
|
|
paging_handle_pending_requests(paging_bts);
|
2009-01-06 23:10:57 +00:00
|
|
|
}
|
|
|
|
|
2011-04-26 13:44:57 +00:00
|
|
|
static void paging_init_if_needed(struct gsm_bts *bts)
|
2009-02-06 18:54:00 +00:00
|
|
|
{
|
2011-04-26 13:44:57 +00:00
|
|
|
if (bts->paging.bts)
|
|
|
|
return;
|
|
|
|
|
2009-02-06 18:54:00 +00:00
|
|
|
bts->paging.bts = bts;
|
|
|
|
INIT_LLIST_HEAD(&bts->paging.pending_requests);
|
2009-02-17 01:39:41 +00:00
|
|
|
bts->paging.work_timer.cb = paging_worker;
|
|
|
|
bts->paging.work_timer.data = &bts->paging;
|
2009-02-10 00:06:19 +00:00
|
|
|
|
|
|
|
/* Large number, until we get a proper message */
|
2010-04-09 20:55:55 +00:00
|
|
|
bts->paging.available_slots = 20;
|
2009-02-06 18:54:00 +00:00
|
|
|
}
|
|
|
|
|
2009-02-09 23:42:03 +00:00
|
|
|
static int paging_pending_request(struct gsm_bts_paging_state *bts,
|
2009-01-06 21:47:18 +00:00
|
|
|
struct gsm_subscriber *subscr) {
|
2009-02-06 18:54:00 +00:00
|
|
|
struct gsm_paging_request *req;
|
2009-01-06 21:47:18 +00:00
|
|
|
|
|
|
|
llist_for_each_entry(req, &bts->pending_requests, entry) {
|
|
|
|
if (subscr == req->subscr)
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-02-10 17:35:04 +00:00
|
|
|
static void paging_T3113_expired(void *data)
|
|
|
|
{
|
2009-02-14 18:04:59 +00:00
|
|
|
struct gsm_paging_request *req = (struct gsm_paging_request *)data;
|
2009-11-17 09:16:46 +00:00
|
|
|
void *cbfn_param;
|
|
|
|
gsm_cbfn *cbfn;
|
2010-12-23 17:19:17 +00:00
|
|
|
int msg;
|
2009-02-10 17:35:04 +00:00
|
|
|
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_INFO, "T3113 expired for request %p (%s)\n",
|
2009-02-10 17:35:04 +00:00
|
|
|
req, req->subscr->imsi);
|
2009-02-16 22:05:44 +00:00
|
|
|
|
2009-11-17 09:16:46 +00:00
|
|
|
/* must be destroyed before calling cbfn, to prevent double free */
|
2010-04-08 14:48:46 +00:00
|
|
|
counter_inc(req->bts->network->stats.paging.expired);
|
2009-11-17 09:16:46 +00:00
|
|
|
cbfn_param = req->cbfn_param;
|
|
|
|
cbfn = req->cbfn;
|
2010-12-23 17:19:17 +00:00
|
|
|
|
|
|
|
/* did we ever manage to page the subscriber */
|
|
|
|
msg = req->attempts > 0 ? GSM_PAGING_EXPIRED : GSM_PAGING_BUSY;
|
|
|
|
|
|
|
|
/* destroy it now. Do not access req afterwards */
|
2009-02-10 17:35:04 +00:00
|
|
|
paging_remove_request(&req->bts->paging, req);
|
2009-11-17 09:16:46 +00:00
|
|
|
|
|
|
|
if (cbfn)
|
2010-12-23 17:19:17 +00:00
|
|
|
cbfn(GSM_HOOK_RR_PAGING, msg, NULL, NULL,
|
2009-11-17 09:16:46 +00:00
|
|
|
cbfn_param);
|
2009-02-10 17:35:04 +00:00
|
|
|
}
|
|
|
|
|
2009-08-15 01:16:17 +00:00
|
|
|
static int _paging_request(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
2009-06-10 00:45:42 +00:00
|
|
|
int type, gsm_cbfn *cbfn, void *data)
|
2009-02-16 22:52:23 +00:00
|
|
|
{
|
2009-02-06 18:54:00 +00:00
|
|
|
struct gsm_bts_paging_state *bts_entry = &bts->paging;
|
|
|
|
struct gsm_paging_request *req;
|
2009-01-06 21:47:18 +00:00
|
|
|
|
2009-02-14 23:53:20 +00:00
|
|
|
if (paging_pending_request(bts_entry, subscr)) {
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_INFO, "Paging request already pending for %s\n", subscr->imsi);
|
2009-08-15 01:16:17 +00:00
|
|
|
return -EEXIST;
|
2009-02-14 23:53:20 +00:00
|
|
|
}
|
|
|
|
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_DEBUG, "Start paging of subscriber %llu on bts %d.\n",
|
2009-08-08 13:08:19 +00:00
|
|
|
subscr->id, bts->nr);
|
2009-06-26 18:25:23 +00:00
|
|
|
req = talloc_zero(tall_paging_ctx, struct gsm_paging_request);
|
2009-01-06 21:47:18 +00:00
|
|
|
req->subscr = subscr_get(subscr);
|
|
|
|
req->bts = bts;
|
2009-01-06 23:10:57 +00:00
|
|
|
req->chan_type = type;
|
2009-02-16 22:52:23 +00:00
|
|
|
req->cbfn = cbfn;
|
|
|
|
req->cbfn_param = data;
|
2009-02-10 17:35:04 +00:00
|
|
|
req->T3113.cb = paging_T3113_expired;
|
|
|
|
req->T3113.data = req;
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_schedule(&req->T3113, bts->network->T3113, 0);
|
2009-02-14 23:53:20 +00:00
|
|
|
llist_add_tail(&req->entry, &bts_entry->pending_requests);
|
2010-09-06 02:05:23 +00:00
|
|
|
paging_schedule_if_needed(bts_entry);
|
2009-08-15 01:16:17 +00:00
|
|
|
|
|
|
|
return 0;
|
2009-01-06 21:47:18 +00:00
|
|
|
}
|
2009-02-06 12:52:14 +00:00
|
|
|
|
2009-08-15 01:16:17 +00:00
|
|
|
int paging_request(struct gsm_network *network, struct gsm_subscriber *subscr,
|
|
|
|
int type, gsm_cbfn *cbfn, void *data)
|
2009-06-10 00:45:42 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts *bts = NULL;
|
2009-08-15 09:25:45 +00:00
|
|
|
int num_pages = 0;
|
2009-06-10 00:45:42 +00:00
|
|
|
|
2009-12-22 18:07:32 +00:00
|
|
|
counter_inc(network->stats.paging.attempted);
|
2009-12-21 23:41:05 +00:00
|
|
|
|
2009-08-01 17:31:47 +00:00
|
|
|
/* start paging subscriber on all BTS within Location Area */
|
2009-06-10 00:45:42 +00:00
|
|
|
do {
|
2009-08-15 09:25:45 +00:00
|
|
|
int rc;
|
|
|
|
|
2009-03-31 02:35:19 +00:00
|
|
|
bts = gsm_bts_by_lac(network, subscr->lac, bts);
|
2009-06-10 00:45:42 +00:00
|
|
|
if (!bts)
|
|
|
|
break;
|
2009-12-28 15:36:28 +00:00
|
|
|
|
|
|
|
/* skip all currently inactive TRX */
|
|
|
|
if (!trx_is_usable(bts->c0))
|
|
|
|
continue;
|
|
|
|
|
2011-04-26 13:44:57 +00:00
|
|
|
/* maybe it is the first time we use it */
|
|
|
|
paging_init_if_needed(bts);
|
|
|
|
|
2009-08-15 09:25:45 +00:00
|
|
|
num_pages++;
|
2009-06-10 00:45:42 +00:00
|
|
|
|
2009-08-15 01:16:17 +00:00
|
|
|
/* Trigger paging, pass any error to caller */
|
|
|
|
rc = _paging_request(bts, subscr, type, cbfn, data);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2009-06-10 00:45:42 +00:00
|
|
|
} while (1);
|
2009-08-15 01:16:17 +00:00
|
|
|
|
2009-12-21 23:41:05 +00:00
|
|
|
if (num_pages == 0)
|
2009-12-22 18:07:32 +00:00
|
|
|
counter_inc(network->stats.paging.detached);
|
2009-12-21 23:41:05 +00:00
|
|
|
|
2009-08-15 09:25:45 +00:00
|
|
|
return num_pages;
|
2009-06-10 00:45:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-06 12:52:14 +00:00
|
|
|
/* we consciously ignore the type of the request here */
|
2009-06-10 00:45:42 +00:00
|
|
|
static void _paging_request_stop(struct gsm_bts *bts, struct gsm_subscriber *subscr,
|
2010-12-01 20:41:35 +00:00
|
|
|
struct gsm_subscriber_connection *conn,
|
|
|
|
struct msgb *msg)
|
2009-02-06 12:52:14 +00:00
|
|
|
{
|
2009-02-06 18:54:00 +00:00
|
|
|
struct gsm_bts_paging_state *bts_entry = &bts->paging;
|
|
|
|
struct gsm_paging_request *req, *req2;
|
2009-02-06 12:52:14 +00:00
|
|
|
|
2011-04-26 13:44:57 +00:00
|
|
|
paging_init_if_needed(bts);
|
|
|
|
|
2009-02-06 12:52:14 +00:00
|
|
|
llist_for_each_entry_safe(req, req2, &bts_entry->pending_requests,
|
|
|
|
entry) {
|
2009-02-06 18:08:18 +00:00
|
|
|
if (req->subscr == subscr) {
|
2010-06-17 07:05:57 +00:00
|
|
|
if (conn && req->cbfn) {
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d, calling cbfn.\n", bts->nr);
|
2009-02-16 22:52:23 +00:00
|
|
|
req->cbfn(GSM_HOOK_RR_PAGING, GSM_PAGING_SUCCEEDED,
|
2010-12-01 20:41:35 +00:00
|
|
|
msg, conn, req->cbfn_param);
|
2009-06-10 15:11:52 +00:00
|
|
|
} else
|
2010-04-09 20:02:39 +00:00
|
|
|
LOGP(DPAG, LOGL_DEBUG, "Stop paging on bts %d silently.\n", bts->nr);
|
2009-02-09 23:42:03 +00:00
|
|
|
paging_remove_request(&bts->paging, req);
|
2009-02-06 18:08:18 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-02-06 12:52:14 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 00:06:19 +00:00
|
|
|
|
2009-06-10 00:45:42 +00:00
|
|
|
/* Stop paging on all other bts' */
|
|
|
|
void paging_request_stop(struct gsm_bts *_bts, struct gsm_subscriber *subscr,
|
2010-12-01 20:41:35 +00:00
|
|
|
struct gsm_subscriber_connection *conn,
|
|
|
|
struct msgb *msg)
|
2009-06-10 00:45:42 +00:00
|
|
|
{
|
|
|
|
struct gsm_bts *bts = NULL;
|
|
|
|
|
2009-08-21 03:43:44 +00:00
|
|
|
if (_bts)
|
2010-12-01 20:41:35 +00:00
|
|
|
_paging_request_stop(_bts, subscr, conn, msg);
|
2009-06-10 09:46:58 +00:00
|
|
|
|
2009-06-10 00:45:42 +00:00
|
|
|
do {
|
|
|
|
/*
|
|
|
|
* FIXME: Don't use the lac of the subscriber...
|
|
|
|
* as it might have magically changed the lac.. use the
|
|
|
|
* location area of the _bts as reconfiguration of the
|
|
|
|
* network is probably happening less often.
|
|
|
|
*/
|
2009-08-21 03:43:44 +00:00
|
|
|
bts = gsm_bts_by_lac(subscr->net, subscr->lac, bts);
|
2009-06-10 00:45:42 +00:00
|
|
|
if (!bts)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Stop paging */
|
2010-04-30 05:32:05 +00:00
|
|
|
if (bts != _bts)
|
2010-12-01 20:41:35 +00:00
|
|
|
_paging_request_stop(bts, subscr, NULL, NULL);
|
2009-06-10 00:45:42 +00:00
|
|
|
} while (1);
|
|
|
|
}
|
|
|
|
|
2011-04-18 15:04:00 +00:00
|
|
|
void paging_update_buffer_space(struct gsm_bts *bts, uint16_t free_slots)
|
2009-02-10 00:06:19 +00:00
|
|
|
{
|
2011-04-26 13:44:57 +00:00
|
|
|
paging_init_if_needed(bts);
|
|
|
|
|
2011-05-06 10:11:06 +00:00
|
|
|
osmo_timer_del(&bts->paging.credit_timer);
|
2009-02-10 00:06:19 +00:00
|
|
|
bts->paging.available_slots = free_slots;
|
2010-09-06 02:05:23 +00:00
|
|
|
paging_schedule_if_needed(&bts->paging);
|
2009-02-10 00:06:19 +00:00
|
|
|
}
|
2011-04-26 13:52:34 +00:00
|
|
|
|
|
|
|
unsigned int paging_pending_requests_nr(struct gsm_bts *bts)
|
|
|
|
{
|
|
|
|
unsigned int requests = 0;
|
|
|
|
struct gsm_paging_request *req;
|
|
|
|
|
|
|
|
paging_init_if_needed(bts);
|
|
|
|
|
|
|
|
llist_for_each_entry(req, &bts->paging.pending_requests, entry)
|
|
|
|
++requests;
|
|
|
|
|
|
|
|
return requests;
|
|
|
|
}
|