[PATCH 8/8] tbf: Move the alloc_ul_tbf into tbf.c and change signature

Holger Freyther hfreyther at sysmocom.de
Wed Oct 16 14:23:48 UTC 2013


From: Holger Hans Peter Freyther <holger at moiji-mobile.com>

Add the bts parameter to the method list. This would be a static
method of the class (in case the TBF would be a class)
---
 src/gprs_rlcmac_data.cpp | 41 +++--------------------------------------
 src/tbf.cpp              | 35 +++++++++++++++++++++++++++++++++++
 src/tbf.h                |  5 +++++
 3 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp
index 17e1fb9..bc55c57 100644
--- a/src/gprs_rlcmac_data.cpp
+++ b/src/gprs_rlcmac_data.cpp
@@ -21,6 +21,7 @@
 #include <gprs_bssgp_pcu.h>
 #include <gprs_rlcmac.h>
 #include <pcu_l1_if.h>
+#include <tbf.h>
 
 extern void *tall_pcu_ctx;
 
@@ -230,42 +231,6 @@ static uint8_t get_ms_class_by_capability(MS_Radio_Access_capability_t *cap)
 	return 0;
 }
 
-static struct gprs_rlcmac_tbf *alloc_ul_tbf(int8_t use_trx, uint8_t ms_class,
-	uint32_t tlli, uint8_t ta, struct gprs_rlcmac_tbf *dl_tbf)
-{
-	struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
-	uint8_t trx;
-	struct gprs_rlcmac_tbf *tbf;
-	uint8_t tfi;
-
-#warning "Copy and paste with tbf_new_dl_assignment"
-	/* create new TBF, use sme TRX as DL TBF */
-	tfi = tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx, use_trx);
-	if (tfi < 0) {
-		LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
-		/* FIXME: send reject */
-		return NULL;
-	}
-	/* use multislot class of downlink TBF */
-	tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx, ms_class, 0);
-	if (!tbf) {
-		LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
-		/* FIXME: send reject */
-		return NULL;
-	}
-	tbf->tlli = tlli;
-	tbf->tlli_valid = 1; /* no contention resolution */
-	tbf->dir.ul.contention_resolution_done = 1;
-	tbf->ta = ta; /* use current TA */
-	tbf_new_state(tbf, GPRS_RLCMAC_ASSIGN);
-	tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
-	tbf_timer_start(tbf, 3169, bts->t3169, 0);
-
-	return tbf;
-}
-
-
-
 /* Received Uplink RLC control block. */
 int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
 	uint32_t fn)
@@ -412,7 +377,7 @@ int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
 		if (ul_control_block->u.Packet_Downlink_Ack_Nack.Exist_Channel_Request_Description) {
 			LOGP(DRLCMAC, LOGL_DEBUG, "MS requests UL TBF in ack "
 				"message, so we provide one:\n");
-			alloc_ul_tbf(tbf->trx, tbf->ms_class, tbf->tlli, tbf->ta, tbf);
+			tbf_alloc_ul(bts, tbf->trx, tbf->ms_class, tbf->tlli, tbf->ta, tbf);
 			/* schedule uplink assignment */
 			tbf->ul_ass_state = GPRS_RLCMAC_UL_ASS_SEND_ASS;
 		}
@@ -465,7 +430,7 @@ int gprs_rlcmac_rcv_control_block(bitvec *rlc_block, uint8_t trx, uint8_t ts,
 					ms_class = get_ms_class_by_capability(&ul_control_block->u.Packet_Resource_Request.MS_Radio_Access_capability);
 				if (!ms_class)
 					LOGP(DRLCMAC, LOGL_NOTICE, "MS does not give us a class.\n");
-				tbf = alloc_ul_tbf(trx, ms_class, tlli, ta, NULL);
+				tbf = tbf_alloc_ul(bts, trx, ms_class, tlli, ta, NULL);
 				if (!tbf)
 					break;
 				/* set control ts to current MS's TS, until assignment complete */
diff --git a/src/tbf.cpp b/src/tbf.cpp
index cb8fb19..79f1ea8 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -1,6 +1,7 @@
 /* Copied from gprs_bssgp_pcu.cpp
  *
  * Copyright (C) 2012 Ivan Klyuchnikov
+ * Copyright (C) 2012 Andreas Eversberg <jolly at eversberg.eu>
  * Copyright (C) 2013 by Holger Hans Peter Freyther
  *
  * This program is free software; you can redistribute it and/or
@@ -202,3 +203,37 @@ int tbf_handle(struct gprs_rlcmac_bts *bts,
 
 	return tbf_new_dl_assignment(bts, imsi, tlli, ms_class, data, len);
 }
+
+struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
+	int8_t use_trx, uint8_t ms_class,
+	uint32_t tlli, uint8_t ta, struct gprs_rlcmac_tbf *dl_tbf)
+{
+	uint8_t trx;
+	struct gprs_rlcmac_tbf *tbf;
+	uint8_t tfi;
+
+#warning "Copy and paste with tbf_new_dl_assignment"
+	/* create new TBF, use sme TRX as DL TBF */
+	tfi = tfi_find_free(bts, GPRS_RLCMAC_UL_TBF, &trx, use_trx);
+	if (tfi < 0) {
+		LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
+		/* FIXME: send reject */
+		return NULL;
+	}
+	/* use multislot class of downlink TBF */
+	tbf = tbf_alloc(bts, dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx, ms_class, 0);
+	if (!tbf) {
+		LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
+		/* FIXME: send reject */
+		return NULL;
+	}
+	tbf->tlli = tlli;
+	tbf->tlli_valid = 1; /* no contention resolution */
+	tbf->dir.ul.contention_resolution_done = 1;
+	tbf->ta = ta; /* use current TA */
+	tbf_new_state(tbf, GPRS_RLCMAC_ASSIGN);
+	tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
+	tbf_timer_start(tbf, 3169, bts->t3169, 0);
+
+	return tbf;
+}
diff --git a/src/tbf.h b/src/tbf.h
index 1535e8c..330eac1 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -22,6 +22,11 @@
 
 struct gprs_rlcmac_bts;
 
+/* dispatch Unitdata.DL messages */
 int tbf_handle(struct gprs_rlcmac_bts *bts,
 		const uint32_t tlli, const char *imsi, const uint8_t ms_class,
 		const uint16_t delay_csec, const uint8_t *data, const uint16_t len);
+
+struct gprs_rlcmac_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
+	int8_t use_trx, uint8_t ms_class,
+	uint32_t tlli, uint8_t ta, struct gprs_rlcmac_tbf *dl_tbf);
-- 
1.8.4.rc3





More information about the osmocom-net-gprs mailing list