agch/pch: Use PCH for AGCH msgs

This patch extends paging_gen_msg() by adding an output parameter
is_empty that is true, if only a paging message with dummy entries
has been placed into buffer. This feature is then used by
bts_ccch_copy_msg() to insert an AGCH message if is_empty is true.

Ticket: SYS#224
Sponsored-by: On-Waves ehf
This commit is contained in:
Jacob Erlbeck 2014-02-14 14:18:51 +01:00 committed by Holger Hans Peter Freyther
parent 2d725e77f7
commit 7503540959
5 changed files with 34 additions and 8 deletions

View File

@ -40,7 +40,8 @@ int paging_add_imm_ass(struct paging_state *ps, const uint8_t *data,
uint8_t len);
/* generate paging message for given gsm time */
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt);
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt,
int *is_empty);
/* inspection methods below */

View File

@ -326,8 +326,13 @@ int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt
struct gsm_bts_role_bts *btsb = bts->role;
int rc;
if (!is_ag_res)
return paging_gen_msg(btsb->paging_state, out_buf, gt);
if (!is_ag_res) {
int is_empty = 1;
rc = paging_gen_msg(btsb->paging_state, out_buf, gt, &is_empty);
if (!is_empty)
return rc;
}
/* special queue of messages from IMM ASS CMD */
msg = bts_agch_dequeue(bts);
@ -337,7 +342,11 @@ int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt
memcpy(out_buf, msgb_l3(msg), msgb_l3len(msg));
rc = msgb_l3len(msg);
msgb_free(msg);
btsb->agch_queue_agch_msgs++;
if (is_ag_res)
btsb->agch_queue_agch_msgs++;
else
btsb->agch_queue_pch_msgs++;
return rc;
}

View File

@ -377,12 +377,14 @@ static void sort_pr_tmsi_imsi(struct paging_record *pr[], unsigned int n)
}
/* generate paging message for given gsm time */
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt)
int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *gt,
int *is_empty)
{
struct llist_head *group_q;
int group;
int len;
*is_empty = 0;
ps->btsb->load.ccch.pch_total += 1;
group = get_pag_subch_nr(ps, gt);
@ -400,6 +402,7 @@ int paging_gen_msg(struct paging_state *ps, uint8_t *out_buf, struct gsm_time *g
//DEBUGP(DPAG, "Tx PAGING TYPE 1 (empty)\n");
len = fill_paging_type_1(out_buf, empty_id_lv, 0,
NULL, 0);
*is_empty = 1;
} else {
struct paging_record *pr[4];
unsigned int num_pr = 0, imm_ass = 0;

View File

@ -19,5 +19,5 @@ T BCCH slots
50 28 14 28 28 28
Testing AGCH messages queue handling.
AGCH filled: count 720, imm.ass 80, imm.ass.rej 640 (refs 640), queue limit 32, occupied 720, dropped 0, merged 0, rejected 0, ag-res 0, non-res 0
AGCH drained: multiframes 721, imm.ass 80, imm.ass.rej 640 (refs 640), queue limit 32, occupied 0, dropped 0, merged 0, rejected 0, ag-res 720, non-res 0
AGCH drained: multiframes 241, imm.ass 80, imm.ass.rej 641 (refs 641), queue limit 32, occupied 0, dropped 0, merged 0, rejected 0, ag-res 240, non-res 480
Success

View File

@ -47,6 +47,7 @@ static void test_paging_smoke(void)
int rc;
uint8_t out_buf[GSM_MACBLOCK_LEN];
struct gsm_time g_time;
int is_empty = -1;
printf("Testing that paging messages expire.\n");
/* add paging entry */
@ -59,12 +60,22 @@ static void test_paging_smoke(void)
g_time.t1 = 0;
g_time.t2 = 0;
g_time.t3 = 6;
rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time);
rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time, &is_empty);
ASSERT_TRUE(rc == 13);
ASSERT_TRUE(is_empty == 0);
ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0));
ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0);
/* now test the empty queue */
g_time.fn = 0;
g_time.t1 = 0;
g_time.t2 = 0;
g_time.t3 = 6;
rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time, &is_empty);
ASSERT_TRUE(rc == 6);
ASSERT_TRUE(is_empty == 1);
/*
* TODO: test all the cases of different amount tmsi/imsi and check
* if we fill the slots in a optimal way.
@ -76,6 +87,7 @@ static void test_paging_sleep(void)
int rc;
uint8_t out_buf[GSM_MACBLOCK_LEN];
struct gsm_time g_time;
int is_empty = -1;
printf("Testing that paging messages expire with sleep.\n");
/* add paging entry */
@ -91,8 +103,9 @@ static void test_paging_sleep(void)
g_time.t1 = 0;
g_time.t2 = 0;
g_time.t3 = 6;
rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time);
rc = paging_gen_msg(btsb->paging_state, out_buf, &g_time, &is_empty);
ASSERT_TRUE(rc == 13);
ASSERT_TRUE(is_empty == 0);
ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0));
ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0);