rlcmac: Reduce the depedency on the global gprs_rlcmac_bts variable
For mocking/unit-testing/emulation (and a dual trx-systems) having
global state is quite bad. Cut back on the usage of the global
struct gprs_rlcmac_bts. It also makes the complexity of certain
routines more clear.
diff --git a/src/gprs_rlcmac_data.cpp b/src/gprs_rlcmac_data.cpp
index 99fac1b..4d5acb9 100644
--- a/src/gprs_rlcmac_data.cpp
+++ b/src/gprs_rlcmac_data.cpp
@@ -239,14 +239,14 @@
uint8_t tfi;
/* create new TBF, use sme TRX as DL TBF */
- tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, use_trx);
+ tfi = tfi_alloc(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(dl_tbf, GPRS_RLCMAC_UL_TBF, tfi, trx, ms_class, 0);
+ 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 */
@@ -273,6 +273,7 @@
uint32_t tlli = 0;
struct gprs_rlcmac_tbf *tbf;
struct gprs_rlcmac_sba *sba;
+ struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
int rc;
RlcMacUplink_t * ul_control_block = (RlcMacUplink_t *)talloc_zero(tall_pcu_ctx, RlcMacUplink_t);
@@ -478,14 +479,14 @@
} else {
if (ul_control_block->u.Packet_Resource_Request.ID.u.Global_TFI.UnionType) {
tfi = ul_control_block->u.Packet_Resource_Request.ID.u.Global_TFI.u.DOWNLINK_TFI;
- tbf = tbf_by_tfi(tfi, trx, GPRS_RLCMAC_DL_TBF);
+ tbf = tbf_by_tfi(bts, tfi, trx, GPRS_RLCMAC_DL_TBF);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "PACKET RESSOURCE REQ unknown downlink TBF=%d\n", tlli);
break;
}
} else {
tfi = ul_control_block->u.Packet_Resource_Request.ID.u.Global_TFI.u.UPLINK_TFI;
- tbf = tbf_by_tfi(tfi, trx, GPRS_RLCMAC_UL_TBF);
+ tbf = tbf_by_tfi(bts, tfi, trx, GPRS_RLCMAC_UL_TBF);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "PACKET RESSOURCE REQ unknown uplink TBF=%d\n", tlli);
break;
@@ -876,7 +877,7 @@
}
/* find TBF inst from given TFI */
- tbf = tbf_by_tfi(rh->tfi, trx, GPRS_RLCMAC_UL_TBF);
+ tbf = tbf_by_tfi(bts, rh->tfi, trx, GPRS_RLCMAC_UL_TBF);
if (!tbf) {
LOGP(DRLCMACUL, LOGL_NOTICE, "UL DATA unknown TBF=%d\n",
rh->tfi);
@@ -1173,14 +1174,14 @@
"(AGCH)\n");
} else {
// Create new TBF
- tfi = tfi_alloc(GPRS_RLCMAC_UL_TBF, &trx, -1);
+ tfi = tfi_alloc(bts, GPRS_RLCMAC_UL_TBF, &trx, -1);
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */
return -EBUSY;
}
/* set class to 0, since we don't know the multislot class yet */
- tbf = tbf_alloc(NULL, GPRS_RLCMAC_UL_TBF, tfi, trx, 0, 1);
+ tbf = tbf_alloc(bts, NULL, GPRS_RLCMAC_UL_TBF, tfi, trx, 0, 1);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
/* FIXME: send reject */