[PATCH 5/8] agch/pch: Use PCH for AGCH msgs

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Fri Feb 21 23:36:06 UTC 2014


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
and there are more entries in the AGCH queue than fit into the
reserved blocks.

Ticket: #224
Sponsored-by: On-Waves ehf
---
 include/osmo-bts/paging.h  |    3 ++-
 src/common/bts.c           |   19 ++++++++++++++++---
 src/common/paging.c        |    5 ++++-
 tests/agch/agch_test.ok    |    2 +-
 tests/paging/paging_test.c |    8 ++++++--
 5 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/include/osmo-bts/paging.h b/include/osmo-bts/paging.h
index d31f5c1..38accd7 100644
--- a/include/osmo-bts/paging.h
+++ b/include/osmo-bts/paging.h
@@ -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 */
diff --git a/src/common/bts.c b/src/common/bts.c
index 508d562..4ba2ec7 100644
--- a/src/common/bts.c
+++ b/src/common/bts.c
@@ -331,9 +331,18 @@ int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt
 	struct msgb *msg;
 	struct gsm_bts_role_bts *btsb = bts->role;
 	int rc;
+	int is_empty = 1;
+	struct gsm48_system_information_type_3 *si3 =
+		GSM_BTS_SI(bts, SYSINFO_TYPE_3);
+	int bs_ag_blks_res = si3->control_channel_desc.bs_ag_blks_res;
+	int agch_res_full = btsb->agch_queue_length > bs_ag_blks_res;
 
-	if (!is_ag_res)
-		return paging_gen_msg(btsb->paging_state, out_buf, gt);
+	if (!is_ag_res) {
+		rc = paging_gen_msg(btsb->paging_state, out_buf, gt, &is_empty);
+
+		if (!is_empty || !agch_res_full)
+			return rc;
+	}
 
 	/* special queue of messages from IMM ASS CMD */
 	msg = bts_agch_dequeue(bts);
@@ -347,7 +356,11 @@ int bts_ccch_copy_msg(struct gsm_bts *bts, uint8_t *out_buf, struct gsm_time *gt
 	     ((struct gsm48_imm_ass *)msgb_l3(msg))->msg_type,
 	     is_ag_res ? "AGCH" : "PCH");
 	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;
 }
diff --git a/src/common/paging.c b/src/common/paging.c
index 7c71c6f..f75f12d 100644
--- a/src/common/paging.c
+++ b/src/common/paging.c
@@ -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;
diff --git a/tests/agch/agch_test.ok b/tests/agch/agch_test.ok
index 8442f07..70a9797 100644
--- a/tests/agch/agch_test.ok
+++ b/tests/agch/agch_test.ok
@@ -1,4 +1,4 @@
 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
diff --git a/tests/paging/paging_test.c b/tests/paging/paging_test.c
index 95f1eba..57da0de 100644
--- a/tests/paging/paging_test.c
+++ b/tests/paging/paging_test.c
@@ -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,8 +60,9 @@ 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);
 
 	ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0));
 	ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0);
@@ -76,6 +78,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 +94,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);
 
 	ASSERT_TRUE(paging_group_queue_empty(btsb->paging_state, 0));
 	ASSERT_TRUE(paging_queue_length(btsb->paging_state) == 0);
-- 
1.7.9.5





More information about the OpenBSC mailing list