aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-06-29 13:45:05 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-07-03 13:17:22 +0200
commitccc34e4d30b962a2963c004d003d3851801ffb3b (patch)
tree63ab4167148ae54cc8858e5cc6a5821e569e9a57 /src
parentc6d4ceeda6e6b96cc5bbc07fb9489587ed181f60 (diff)
tbf: Maintain the number of TBF per PDCH
Currently the PDCH object do not know anything about the TBFs using them. To make the slot allocation load dependant, at least some numbers are required. This commit adds TBF counters (one per direction) and the related methods attach_tbf, detach_tbf, and num_tbfs to gprs_rlcmac_pdch. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src')
-rw-r--r--src/bts.cpp16
-rw-r--r--src/bts.h12
-rw-r--r--src/gprs_rlcmac_ts_alloc.cpp14
-rw-r--r--src/tbf.cpp15
4 files changed, 49 insertions, 8 deletions
diff --git a/src/bts.cpp b/src/bts.cpp
index bc5ac94..6da8cdd 100644
--- a/src/bts.cpp
+++ b/src/bts.cpp
@@ -1131,3 +1131,19 @@ gprs_rlcmac_dl_tbf *gprs_rlcmac_pdch::dl_tbf_by_tfi(uint8_t tfi)
{
return static_cast<gprs_rlcmac_dl_tbf *>(tbf_from_list_by_tfi(&bts_data()->dl_tbfs, tfi, GPRS_RLCMAC_DL_TBF));
}
+
+void gprs_rlcmac_pdch::attach_tbf(gprs_rlcmac_tbf *tbf)
+{
+ m_num_tbfs[tbf->direction] += 1;
+ LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Attaching %s, %d TBFs.\n",
+ ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction]);
+}
+
+void gprs_rlcmac_pdch::detach_tbf(gprs_rlcmac_tbf *tbf)
+{
+ OSMO_ASSERT(m_num_tbfs[tbf->direction] > 0);
+
+ m_num_tbfs[tbf->direction] -= 1;
+ LOGP(DRLCMAC, LOGL_INFO, "PDCH(TS %d, TRX %d): Detaching %s, %d TBFs.\n",
+ ts_no, trx_no(), tbf->name(), m_num_tbfs[tbf->direction]);
+}
diff --git a/src/bts.h b/src/bts.h
index 7e34db5..f6cc88f 100644
--- a/src/bts.h
+++ b/src/bts.h
@@ -66,6 +66,11 @@ struct gprs_rlcmac_pdch {
struct gprs_rlcmac_ul_tbf *ul_tbf_by_tfi(uint8_t tfi);
struct gprs_rlcmac_dl_tbf *dl_tbf_by_tfi(uint8_t tfi);
+
+ void attach_tbf(gprs_rlcmac_tbf *tbf);
+ void detach_tbf(gprs_rlcmac_tbf *tbf);
+
+ unsigned num_tbfs(enum gprs_rlcmac_tbf_direction dir) const;
#endif
uint8_t m_is_enabled; /* TS is enabled */
@@ -93,6 +98,8 @@ private:
gprs_rlcmac_tbf *tbf_from_list_by_tfi(struct llist_head *tbf_list, uint8_t tfi,
enum gprs_rlcmac_tbf_direction dir);
#endif
+
+ uint8_t m_num_tbfs[2];
};
struct gprs_rlcmac_trx {
@@ -299,6 +306,11 @@ inline BTS *gprs_rlcmac_pdch::bts() const
return trx->bts;
}
+inline unsigned gprs_rlcmac_pdch::num_tbfs(enum gprs_rlcmac_tbf_direction dir) const
+{
+ return m_num_tbfs[dir];
+}
+
inline struct rate_ctr_group *BTS::rate_counters() const
{
return m_ratectrs;
diff --git a/src/gprs_rlcmac_ts_alloc.cpp b/src/gprs_rlcmac_ts_alloc.cpp
index bae1ea5..29749b8 100644
--- a/src/gprs_rlcmac_ts_alloc.cpp
+++ b/src/gprs_rlcmac_ts_alloc.cpp
@@ -117,13 +117,23 @@ static int find_enabled_pdch(struct gprs_rlcmac_trx *trx, const uint8_t start_ts
return 8;
}
+static void attach_tbf_to_pdch(struct gprs_rlcmac_pdch *pdch,
+ struct gprs_rlcmac_tbf *tbf)
+{
+ if (tbf->pdch[pdch->ts_no])
+ tbf->pdch[pdch->ts_no]->detach_tbf(tbf);
+
+ tbf->pdch[pdch->ts_no] = pdch;
+ pdch->attach_tbf(tbf);
+}
+
static void assign_uplink_tbf_usf(
struct gprs_rlcmac_pdch *pdch,
struct gprs_rlcmac_ul_tbf *tbf, int8_t usf)
{
tbf->trx->ul_tbf[tbf->tfi()] = tbf;
- tbf->pdch[pdch->ts_no] = pdch;
tbf->m_usf[pdch->ts_no] = usf;
+ attach_tbf_to_pdch(pdch, tbf);
}
static void assign_dlink_tbf(
@@ -131,7 +141,7 @@ static void assign_dlink_tbf(
struct gprs_rlcmac_dl_tbf *tbf)
{
tbf->trx->dl_tbf[tbf->tfi()] = tbf;
- tbf->pdch[pdch->ts_no] = pdch;
+ attach_tbf_to_pdch(pdch, tbf);
}
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 9bdc1f7..ddc3b91 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -209,14 +209,17 @@ static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf)
{
int ts;
- if (tbf->direction == GPRS_RLCMAC_UL_TBF) {
+ if (tbf->direction == GPRS_RLCMAC_UL_TBF)
tbf->trx->ul_tbf[tbf->tfi()] = NULL;
- for (ts = 0; ts < 8; ts++)
- tbf->pdch[ts] = NULL;
- } else {
+ else
tbf->trx->dl_tbf[tbf->tfi()] = NULL;
- for (ts = 0; ts < 8; ts++)
- tbf->pdch[ts] = NULL;
+
+ for (ts = 0; ts < 8; ts++) {
+ if (!tbf->pdch[ts])
+ continue;
+
+ tbf->pdch[ts]->detach_tbf(tbf);
+ tbf->pdch[ts] = NULL;
}
}