aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf.cpp
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2015-05-22 17:48:04 +0200
committerJacob Erlbeck <jerlbeck@sysmocom.de>2015-05-28 13:58:23 +0200
commit9200ce60196a289968144582f1acfac25e17eed5 (patch)
tree34b047174ff64bf5365fcb96ac531d39adccfc17 /src/tbf.cpp
parentddfc0d57632c5f57aeb123f6506d3923fcec69dc (diff)
tbf: Store the timing advance (TA) value in the GprsMs object
The TA value rather relates to an MS and not to a single TBF. So all TBFs share the same TA value. Currently the TA value is stored per TBF and eventually copied from an old TBF to a new one. It is in general only passed with an RACH request when the TLLI and thus the MS is not yet known. This commit adds a TA member to the GprsMs class and uses that one when the TBF is associated to an MS object. Since the TBF is not always associated with an MS object (after RACH or when it has been replaced by another TBF), the TA value is still stored in each TBF and that value is used as long as no MS object is being associated. Sponsored-by: On-Waves ehf
Diffstat (limited to 'src/tbf.cpp')
-rw-r--r--src/tbf.cpp32
1 files changed, 26 insertions, 6 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index ac0cdf3f..53f1ae13 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -89,13 +89,32 @@ void gprs_rlcmac_tbf::assign_imsi(const char *imsi_)
m_ms->set_imsi(imsi_);
}
+uint8_t gprs_rlcmac_tbf::ta() const
+{
+ return m_ms ? m_ms->ta() : m_ta;
+}
+
+void gprs_rlcmac_tbf::set_ta(uint8_t ta)
+{
+ if (ms())
+ ms()->set_ta(ta);
+
+ m_ta = ta;
+}
+
void gprs_rlcmac_tbf::set_ms(GprsMs *ms)
{
if (m_ms == ms)
return;
- if (m_ms)
+ if (m_ms) {
+ /* Save the TA locally. This will also be called, if the MS
+ * object detaches itself from the TBF, for instance if
+ * attach_tbf() is called */
+ m_ta = m_ms->ta();
+
m_ms->detach_tbf(this);
+ }
m_ms = ms;
@@ -110,6 +129,9 @@ void gprs_rlcmac_tbf::update_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction di
if (!new_ms)
new_ms = bts->ms_store().create_ms(tlli, dir);
+ if (dir == GPRS_RLCMAC_UL_TBF)
+ new_ms->set_ta(m_ta);
+
set_ms(new_ms);
return;
}
@@ -144,11 +166,13 @@ gprs_rlcmac_ul_tbf *tbf_alloc_ul(struct gprs_rlcmac_bts *bts,
return NULL;
}
tbf->m_contention_resolution_done = 1;
- tbf->ta = ta; /* use current TA */
tbf->set_state(GPRS_RLCMAC_ASSIGN);
tbf->state_flags |= (1 << GPRS_RLCMAC_FLAG_PACCH);
tbf_timer_start(tbf, 3169, bts->t3169, 0);
tbf->update_ms(tlli, GPRS_RLCMAC_UL_TBF);
+ OSMO_ASSERT(tbf->ms());
+
+ tbf->ms()->set_ta(ta);
return tbf;
}
@@ -786,8 +810,6 @@ void gprs_rlcmac_tbf::free_all(struct gprs_rlcmac_pdch *pdch)
void gprs_rlcmac_tbf::update_tlli(uint32_t tlli)
{
- /* update the timing advance for the new tlli */
- bts->timing_advance()->update(0, tlli, ta);
}
int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
@@ -843,8 +865,6 @@ int gprs_rlcmac_tbf::extract_tlli(const uint8_t *data, const size_t len)
tbf_free(ul_tbf);
ul_tbf = NULL;
}
- /* store current timing advance */
- bts->timing_advance()->remember(tlli(), ta);
return 1;
}