Change in osmo-pcu[master]: ul_tbf: Clean up handle_tbf_reject()

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/gerrit-log@lists.osmocom.org/.

pespin gerrit-no-reply at lists.osmocom.org
Tue Apr 27 10:05:17 UTC 2021


pespin has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/23907 )

Change subject: ul_tbf: Clean up handle_tbf_reject()
......................................................................

ul_tbf: Clean up handle_tbf_reject()

Document the function, make it look similar to usual TBF creation path
tbf_alloc_ul()->tbf_alloc_ul_tbf->tbf::setup(), which it mimics with
some differences.
Get rid of unneeded stuff like creating MS and settings its TLLI (that's
already done in only caller of the function). There's no need for
calling update_ms() either.

Change-Id: I61df2e4f0f0df1f8db941741a2d35a2319252c5e
---
M src/pdch.cpp
M src/tbf_ul.cpp
M src/tbf_ul.h
M tests/tbf/TbfTest.cpp
M tests/tbf/TbfTest.err
5 files changed, 24 insertions(+), 26 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, but someone else must approve
  pespin: Looks good to me, approved



diff --git a/src/pdch.cpp b/src/pdch.cpp
index 76ca1d0..5389763 100644
--- a/src/pdch.cpp
+++ b/src/pdch.cpp
@@ -685,8 +685,7 @@
 
 		ul_tbf = tbf_alloc_ul(bts(), ms, trx_no(), tlli);
 		if (!ul_tbf) {
-			handle_tbf_reject(bts(), ms, tlli,
-				trx_no(), ts_no);
+			handle_tbf_reject(bts(), ms, trx_no(), ts_no);
 			goto return_unref;
 		}
 
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 7a4e3a3..c41793d 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -96,6 +96,7 @@
 	return 0;
 }
 
+/* Generic function to alloc a UL TBF, later configured to be assigned either over CCCH or PACCH */
 struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx, bool single_slot)
 {
 	struct gprs_rlcmac_ul_tbf *tbf;
@@ -139,19 +140,16 @@
 	return tbf;
 }
 
-
+/* Alloc a UL TBF to be assigned over PACCH */
 gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, GprsMs *ms, int8_t use_trx,
 				 uint32_t tlli)
 {
 	struct gprs_rlcmac_ul_tbf *tbf;
 
-/* FIXME: Copy and paste with tbf_new_dl_assignment */
-	/* create new TBF, use same TRX as DL TBF */
-	/* use multislot class of downlink TBF */
 	tbf = tbf_alloc_ul_tbf(bts, ms, use_trx, false);
 	if (!tbf) {
 		LOGPMS(ms, DTBF, LOGL_NOTICE, "No PDCH resource\n");
-		/* FIXME: send reject */
+		/* Caller will most probably send a Imm Ass Reject after return */
 		return NULL;
 	}
 	tbf->m_contention_resolution_done = 1;
@@ -162,30 +160,23 @@
 	return tbf;
 }
 
+/* Create a temporary dummy TBF to Tx a ImmAssReject if allocating a new one during
+ * packet resource Request failed. This is similar as tbf_alloc_ul() but without
+ * calling tbf->setup() (in charge of TFI/USF allocation), and reusing resources
+ * from Packet Resource Request we received. See TS 44.060 sec 7.1.3.2.1  */
 struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
-			GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts)
+			GprsMs *ms, uint8_t trx_no, uint8_t ts)
 {
 	struct gprs_rlcmac_ul_tbf *ul_tbf = NULL;
 	struct gprs_rlcmac_trx *trx = &bts->trx[trx_no];
-
-	if (!ms)
-		ms = bts_alloc_ms(bts, 0, 0);
-	ms_set_tlli(ms, tlli);
+	OSMO_ASSERT(ms);
 
 	ul_tbf = talloc(tall_pcu_ctx, struct gprs_rlcmac_ul_tbf);
 	if (!ul_tbf)
 		return ul_tbf;
-
 	talloc_set_destructor(ul_tbf, ul_tbf_dtor);
 	new (ul_tbf) gprs_rlcmac_ul_tbf(bts, ms);
 
-	llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)ul_tbf), &bts->ul_tbfs);
-	bts_do_rate_ctr_inc(ul_tbf->bts, CTR_TBF_UL_ALLOCATED);
-	TBF_SET_ASS_ON(ul_tbf, GPRS_RLCMAC_FLAG_PACCH, false);
-
-	ms_attach_tbf(ms, ul_tbf);
-	ul_tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
-	TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
 	ul_tbf->control_ts = ts;
 	ul_tbf->trx = trx;
 	ul_tbf->m_ctrs = rate_ctr_group_alloc(ul_tbf, &tbf_ctrg_desc, next_tbf_ctr_group_id++);
@@ -201,6 +192,12 @@
 		return NULL;
 	}
 
+	ms_attach_tbf(ms, ul_tbf);
+	llist_add(tbf_bts_list((struct gprs_rlcmac_tbf *)ul_tbf), &bts->ul_tbfs);
+	bts_do_rate_ctr_inc(ul_tbf->bts, CTR_TBF_UL_ALLOCATED);
+	TBF_SET_ASS_ON(ul_tbf, GPRS_RLCMAC_FLAG_PACCH, false);
+	TBF_SET_ASS_STATE_UL(ul_tbf, GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ);
+
 	return ul_tbf;
 }
 
diff --git a/src/tbf_ul.h b/src/tbf_ul.h
index a2ad25e..53c7ad8 100644
--- a/src/tbf_ul.h
+++ b/src/tbf_ul.h
@@ -121,7 +121,7 @@
 struct gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts, GprsMs *ms,
 					int8_t use_trx, uint32_t tlli);
 struct gprs_rlcmac_ul_tbf *handle_tbf_reject(struct gprs_rlcmac_bts *bts,
-	GprsMs *ms, uint32_t tlli, uint8_t trx_no, uint8_t ts_no);
+	GprsMs *ms, uint8_t trx_no, uint8_t ts_no);
 
 #else /* ifdef __cplusplus */
 struct gprs_rlcmac_ul_tbf;
diff --git a/tests/tbf/TbfTest.cpp b/tests/tbf/TbfTest.cpp
index c839ee0..cf8e083 100644
--- a/tests/tbf/TbfTest.cpp
+++ b/tests/tbf/TbfTest.cpp
@@ -3160,7 +3160,8 @@
 	int ts_no = 7;
 	uint8_t trx_no = 0;
 	uint32_t tlli = 0xffeeddcc;
-	struct gprs_rlcmac_ul_tbf *ul_tbf = NULL;
+	struct gprs_rlcmac_ul_tbf *ul_tbf;
+	struct GprsMs *ms;
 
 	fprintf(stderr, "=== start %s ===\n", __func__);
 
@@ -3168,8 +3169,9 @@
 
 	int rc = 0;
 
-	ul_tbf = handle_tbf_reject(bts, NULL, tlli,
-				trx_no, ts_no);
+	ms = bts_alloc_ms(bts, 0, 0);
+	ms_set_tlli(ms, tlli);
+	ul_tbf = handle_tbf_reject(bts, ms, trx_no, ts_no);
 
 	OSMO_ASSERT(ul_tbf != 0);
 
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index 4b38aec..e700fe2 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -7956,8 +7956,8 @@
 [UL] algo A <multi> (suggested TRX: 0): failed to allocate a TS, no USF available
 TBF(TFI=0 TLLI=0xffeeddd3 DIR=UL STATE=NULL EGPRS) Timeslot Allocation failed: trx = 0, single_slot = 0
 MS(TLLI=0xffeeddd3, IMSI=, TA=7, 11/11,) No PDCH resource
+MS(TLLI=0xffeeddd3, IMSI=, TA=7, 11/11,) Attaching UL TBF: TBF(TFI=0 TLLI=0xffeeddd3 DIR=UL STATE=NULL)
 TBF(TFI=0 TLLI=0xffeeddd3 DIR=UL STATE=NULL) changes state from NULL to ASSIGN
-MS(TLLI=0xffeeddd3, IMSI=, TA=7, 11/11,) Attaching UL TBF: TBF(TFI=0 TLLI=0xffeeddd3 DIR=UL STATE=ASSIGN)
 TBF(TFI=0 TLLI=0xffeeddd3 DIR=UL STATE=ASSIGN) changes UL ASS state from GPRS_RLCMAC_UL_ASS_NONE to GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ
 PDCH(bts=0,trx=0,ts=7) Expiring FN=82 but previous FN=2654231 is still reserved!
 PDCH(bts=0,trx=0,ts=7) Timeout for registered POLL (FN=2654231): TBF(TFI=6 TLLI=0xffeeddd2 DIR=UL STATE=ASSIGN EGPRS)
@@ -7974,8 +7974,8 @@
 === start test_packet_access_rej_prr_no_other_tbfs ===
 Creating MS object, TLLI = 0xffffffff
 Modifying MS object, UL TLLI: 0xffffffff -> 0xffeeddcc, not yet confirmed
+MS(TLLI=0xffeeddcc, IMSI=, TA=220, 0/0,) Attaching UL TBF: TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=NULL)
 TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=NULL) changes state from NULL to ASSIGN
-MS(TLLI=0xffeeddcc, IMSI=, TA=220, 0/0,) Attaching UL TBF: TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=ASSIGN)
 TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=ASSIGN) changes UL ASS state from GPRS_RLCMAC_UL_ASS_NONE to GPRS_RLCMAC_UL_ASS_SEND_ASS_REJ
 TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=ASSIGN) starting timer T0 [reject (PACCH)] with 0 sec. 2000 microsec, cur_fn=2654167
 PDCH(bts=0,trx=0,ts=7) FN=2654218 Scheduling control message at RTS for TBF(TFI=0 TLLI=0xffeeddcc DIR=UL STATE=ASSIGN)

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/23907
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I61df2e4f0f0df1f8db941741a2d35a2319252c5e
Gerrit-Change-Number: 23907
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de>
Gerrit-Reviewer: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210427/2eca06ca/attachment.htm>


More information about the gerrit-log mailing list