aboutsummaryrefslogtreecommitdiffstats
path: root/src/gprs_bssgp_pcu.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-07-28 18:55:14 +0200
committerIvan Kluchnikov <kluchnikovi@gmail.com>2013-09-04 21:28:53 +0400
commitb67a8a348a21c75cad063ca53195a3c425b5cc01 (patch)
tree10a2c4123b50dd3c8cc538cccdad4e8c3f49628f /src/gprs_bssgp_pcu.cpp
parent90d5df4ae757c4261c8cb0cd8cc73c2db43fcb0c (diff)
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.
Diffstat (limited to 'src/gprs_bssgp_pcu.cpp')
-rw-r--r--src/gprs_bssgp_pcu.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gprs_bssgp_pcu.cpp b/src/gprs_bssgp_pcu.cpp
index a0ef2064..acd30a4b 100644
--- a/src/gprs_bssgp_pcu.cpp
+++ b/src/gprs_bssgp_pcu.cpp
@@ -25,6 +25,8 @@ struct osmo_pcu {
struct gprs_nsvc *nsvc;
struct bssgp_bvc_ctx *bctx;
+ struct gprs_rlcmac_bts *bts;
+
struct osmo_timer_list bvc_timer;
int nsvc_unblocked;
@@ -187,15 +189,14 @@ static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp)
} else {
/* the TBF exists, so we must write it in the queue
* we prepend lifetime in front of PDU */
- struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
struct timeval *tv;
struct msgb *llc_msg = msgb_alloc(len + sizeof(*tv),
"llc_pdu_queue");
if (!llc_msg)
return -ENOMEM;
tv = (struct timeval *)msgb_put(llc_msg, sizeof(*tv));
- if (bts->force_llc_lifetime)
- delay_csec = bts->force_llc_lifetime;
+ if (the_pcu.bts->force_llc_lifetime)
+ delay_csec = the_pcu.bts->force_llc_lifetime;
/* keep timestap at 0 for infinite delay */
if (delay_csec != 0xffff) {
/* calculate timestamp of timeout */
@@ -247,14 +248,14 @@ static int gprs_bssgp_pcu_rx_dl_ud(struct msgb *msg, struct tlv_parsed *tp)
}
// Create new TBF (any TRX)
- tfi = tfi_alloc(GPRS_RLCMAC_DL_TBF, &trx, use_trx);
+ tfi = tfi_alloc(the_pcu.bts, GPRS_RLCMAC_DL_TBF, &trx, use_trx);
if (tfi < 0) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH resource\n");
/* FIXME: send reject */
return -EBUSY;
}
/* set number of downlink slots according to multislot class */
- tbf = tbf_alloc(tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ms_class,
+ tbf = tbf_alloc(the_pcu.bts, tbf, GPRS_RLCMAC_DL_TBF, tfi, trx, ms_class,
ss);
if (!tbf) {
LOGP(DRLCMAC, LOGL_NOTICE, "No PDCH ressource\n");
@@ -560,8 +561,6 @@ int gprs_bssgp_tx_fc_bvc(void)
static void bvc_timeout(void *_priv)
{
- struct gprs_rlcmac_bts *bts = gprs_rlcmac_bts;
-
if (!the_pcu.bvc_sig_reset) {
LOGP(DBSSGP, LOGL_INFO, "Sending reset on BVCI 0\n");
bssgp_tx_bvc_reset(the_pcu.bctx, 0, BSSGP_CAUSE_OML_INTERV);
@@ -588,11 +587,12 @@ static void bvc_timeout(void *_priv)
LOGP(DBSSGP, LOGL_DEBUG, "Sending flow control info on BVCI %d\n",
the_pcu.bctx->bvci);
gprs_bssgp_tx_fc_bvc();
- osmo_timer_schedule(&the_pcu.bvc_timer, bts->fc_interval, 0);
+ osmo_timer_schedule(&the_pcu.bvc_timer, the_pcu.bts->fc_interval, 0);
}
/* create BSSGP/NS layer instances */
-int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip,
+int gprs_bssgp_create_and_connect(struct gprs_rlcmac_bts *bts,
+ uint16_t local_port, uint32_t sgsn_ip,
uint16_t sgsn_port, uint16_t nsei, uint16_t nsvci, uint16_t bvci,
uint16_t mcc, uint16_t mnc, uint16_t lac, uint16_t rac,
uint16_t cell_id)
@@ -607,6 +607,8 @@ int gprs_bssgp_create_and_connect(uint16_t local_port, uint32_t sgsn_ip,
if (the_pcu.bctx)
return 0; /* if already created, must return 0: no error */
+ the_pcu.bts = bts;
+
bssgp_nsi = gprs_ns_instantiate(&sgsn_ns_cb, tall_pcu_ctx);
if (!bssgp_nsi) {
LOGP(DBSSGP, LOGL_ERROR, "Failed to create NS instance\n");