aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax <msuraev@sysmocom.de>2017-12-14 15:02:33 +0100
committerMax <msuraev@sysmocom.de>2018-01-12 15:29:42 +0100
commit9d7357e4fe67ad4a2f00d173ab769f56afb23980 (patch)
tree4a7687e22b5c2060dda0fb8f5cfaf464f5c50c5c /src
parentd0532b53ebcafc1e71ac6478b03ee9ebe4ac386d (diff)
TBF: unify EGPRS window calculation
Move actual calculation into shared function and use it to set window size for TBF. TBT test output requires cosmetic adjuestements due to extended debug output. Change-Id: Ib9f4a277082da3c71007f5f3b4f2acac8b994540 Related: OS#1759
Diffstat (limited to 'src')
-rw-r--r--src/tbf.cpp14
-rw-r--r--src/tbf.h6
-rw-r--r--src/tbf_dl.cpp20
-rw-r--r--src/tbf_ul.cpp19
4 files changed, 23 insertions, 36 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 48cfb6f3..4878a079 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -487,6 +487,14 @@ void tbf_free(struct gprs_rlcmac_tbf *tbf)
talloc_free(tbf);
}
+uint16_t egprs_window_size(const struct gprs_rlcmac_bts *bts_data, uint8_t slots)
+{
+ uint8_t num_pdch = pcu_bitcount(slots);
+
+ return OSMO_MIN((num_pdch != 1) ? (128 * num_pdch) : 192,
+ OSMO_MAX(64, (bts_data->ws_base + num_pdch * bts_data->ws_pdch) / 32 * 32));
+}
+
int gprs_rlcmac_tbf::update()
{
struct gprs_rlcmac_bts *bts_data = bts->bts_data();
@@ -509,7 +517,7 @@ int gprs_rlcmac_tbf::update()
if (is_egprs_enabled()) {
gprs_rlcmac_dl_tbf *dl_tbf = as_dl_tbf(this);
if (dl_tbf)
- dl_tbf->egprs_calc_window_size();
+ dl_tbf->set_window_size();
}
return 0;
@@ -946,7 +954,7 @@ struct gprs_rlcmac_ul_tbf *tbf_alloc_ul_tbf(struct gprs_rlcmac_bts *bts,
rc = setup_tbf(tbf, ms, use_trx, ms_class, egprs_ms_class, single_slot);
if (tbf->is_egprs_enabled())
- tbf->egprs_calc_ulwindow_size();
+ tbf->set_window_size();
/* if no resource */
if (rc < 0) {
@@ -1044,7 +1052,7 @@ struct gprs_rlcmac_dl_tbf *tbf_alloc_dl_tbf(struct gprs_rlcmac_bts *bts,
}
if (tbf->is_egprs_enabled()) {
- tbf->egprs_calc_window_size();
+ tbf->set_window_size();
tbf->m_dl_egprs_ctrs = rate_ctr_group_alloc(tbf, &tbf_dl_egprs_ctrg_desc, 0);
if (!tbf->m_dl_egprs_ctrs) {
LOGP(DRLCMAC, LOGL_ERROR, "Couldn't allocate EGPRS DL counters\n");
diff --git a/src/tbf.h b/src/tbf.h
index 059bc785..6c9946e5 100644
--- a/src/tbf.h
+++ b/src/tbf.h
@@ -492,7 +492,7 @@ struct gprs_rlcmac_dl_tbf : public gprs_rlcmac_tbf {
int release();
int abort();
uint16_t window_size() const;
- void egprs_calc_window_size();
+ void set_window_size();
void update_coding_scheme_counter_dl(const GprsCodingScheme cs);
/* TODO: add the gettimeofday as parameter */
@@ -594,8 +594,8 @@ struct gprs_rlcmac_ul_tbf : public gprs_rlcmac_tbf {
struct gprs_rlc_data *block,
uint8_t *data, const uint8_t block_idx);
- void egprs_calc_ulwindow_size();
uint16_t window_size() const;
+ void set_window_size();
void update_coding_scheme_counter_ul(const GprsCodingScheme cs);
/* Please note that all variables here will be reset when changing
@@ -676,4 +676,6 @@ inline gprs_rlcmac_dl_tbf *as_dl_tbf(gprs_rlcmac_tbf *tbf)
return NULL;
}
+uint16_t egprs_window_size(const struct gprs_rlcmac_bts *bts_data, uint8_t slots);
+
#endif
diff --git a/src/tbf_dl.cpp b/src/tbf_dl.cpp
index 45c9a8f4..6b8eda79 100644
--- a/src/tbf_dl.cpp
+++ b/src/tbf_dl.cpp
@@ -1366,23 +1366,11 @@ enum egprs_rlcmac_dl_spb gprs_rlcmac_dl_tbf::get_egprs_dl_spb(const int bsn)
return EGPRS_RLCMAC_DL_NO_RETX;
}
-void gprs_rlcmac_dl_tbf::egprs_calc_window_size()
+void gprs_rlcmac_dl_tbf::set_window_size()
{
- struct gprs_rlcmac_bts *bts_data = bts->bts_data();
- unsigned int num_pdch = pcu_bitcount(dl_slots());
- unsigned int ws = bts_data->ws_base + num_pdch * bts_data->ws_pdch;
-
- ws = (ws / 32) * 32;
- ws = OSMO_MAX(64, ws);
-
- if (num_pdch == 1)
- ws = OSMO_MIN(192, ws);
- else
- ws = OSMO_MIN(128 * num_pdch, ws);
-
- LOGP(DRLCMAC, LOGL_INFO, "%s: Setting EGPRS window size to %d\n",
- name(), ws);
-
+ uint16_t ws = egprs_window_size(bts->bts_data(), dl_slots());
+ LOGP(DRLCMAC, LOGL_INFO, "%s: setting EGPRS DL window size to %u, base(%u) slots(%u) ws_pdch(%u)\n",
+ name(), ws, bts->bts_data()->ws_base, pcu_bitcount(dl_slots()), bts->bts_data()->ws_pdch);
m_window.set_ws(ws);
}
diff --git a/src/tbf_ul.cpp b/src/tbf_ul.cpp
index 6442b8f9..83ac08f4 100644
--- a/src/tbf_ul.cpp
+++ b/src/tbf_ul.cpp
@@ -606,21 +606,10 @@ void gprs_rlcmac_ul_tbf::update_coding_scheme_counter_ul(const GprsCodingScheme
}
}
-void gprs_rlcmac_ul_tbf::egprs_calc_ulwindow_size()
+void gprs_rlcmac_ul_tbf::set_window_size()
{
- struct gprs_rlcmac_bts *bts_data = bts->bts_data();
- unsigned int num_pdch = pcu_bitcount(ul_slots());
- unsigned int ws = bts_data->ws_base + num_pdch * bts_data->ws_pdch;
- ws = (ws / 32) * 32;
- ws = OSMO_MAX(64, ws);
-
- if (num_pdch == 1)
- ws = OSMO_MIN(192, ws);
- else
- ws = OSMO_MIN(128 * num_pdch, ws);
-
- LOGP(DRLCMAC, LOGL_INFO, "%s: Setting EGPRS window size to %d, base(%d) slots(%d) ws_pdch(%d)\n",
- name(), ws, bts_data->ws_base, num_pdch, bts_data->ws_pdch);
-
+ uint16_t ws = egprs_window_size(bts->bts_data(), ul_slots());
+ LOGP(DRLCMAC, LOGL_INFO, "%s: setting EGPRS UL window size to %u, base(%u) slots(%u) ws_pdch(%u)\n",
+ name(), ws, bts->bts_data()->ws_base, pcu_bitcount(ul_slots()), bts->bts_data()->ws_pdch);
m_window.set_ws(ws);
}